Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Aug 30, 2024
1 parent 060eb30 commit 36b65b8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 77 deletions.
4 changes: 2 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import commandLineArgs from 'command-line-args'
import commandLineUsage from 'command-line-usage'
import jsdoc2md from 'jsdoc-to-markdown'
import omit from 'lodash.omit'
import assert from 'assert'
import fs from 'fs'
import loadConfig from 'config-master'
Expand Down Expand Up @@ -33,7 +32,8 @@ if (options.help) {

/* jsdoc2md --config */
if (options.config) {
console.log(JSON.stringify(omit(options, 'config'), null, ' '))
delete options.config
console.log(JSON.stringify(options, null, ' '))
process.exit(0)
}

Expand Down
35 changes: 16 additions & 19 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ class JsdocToMarkdown {
* @returns {Promise}
* @category async
*/
clear () {
return jsdocApi.cache.clear().then(() => dmd.cache.clear())
async clear () {
await jsdocApi.cache.clear();
await dmd.cache.clear();
}

/**
Expand All @@ -121,23 +122,19 @@ class JsdocToMarkdown {
* @returns {object}
* @category async
*/
getNamepaths (options) {
return this.getTemplateData(options)
.then(data => {
const namepaths = {};
const kinds = [
'module', 'class', 'constructor', 'mixin', 'member',
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
];
kinds.forEach(kind => {
namepaths[kind] = data
.filter(identifier => {
return identifier.kind === kind
})
.map(identifier => identifier.longname);
});
return namepaths
})
async getNamepaths (options) {
const data = await this.getTemplateData(options);
const namepaths = {};
const kinds = [
'module', 'class', 'constructor', 'mixin', 'member',
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
];
for (const kind of kinds) {
namepaths[kind] = data
.filter(identifier => identifier.kind === kind)
.map(identifier => identifier.longname);
}
return namepaths
}
}

Expand Down
35 changes: 16 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ class JsdocToMarkdown {
* @returns {Promise}
* @category async
*/
clear () {
return jsdocApi.cache.clear().then(() => dmd.cache.clear())
async clear () {
await jsdocApi.cache.clear()
await dmd.cache.clear()
}

/**
Expand All @@ -100,23 +101,19 @@ class JsdocToMarkdown {
* @returns {object}
* @category async
*/
getNamepaths (options) {
return this.getTemplateData(options)
.then(data => {
const namepaths = {}
const kinds = [
'module', 'class', 'constructor', 'mixin', 'member',
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
]
kinds.forEach(kind => {
namepaths[kind] = data
.filter(identifier => {
return identifier.kind === kind
})
.map(identifier => identifier.longname)
})
return namepaths
})
async getNamepaths (options) {
const data = await this.getTemplateData(options)
const namepaths = {}
const kinds = [
'module', 'class', 'constructor', 'mixin', 'member',
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
]
for (const kind of kinds) {
namepaths[kind] = data
.filter(identifier => identifier.kind === kind)
.map(identifier => identifier.longname)
}
return namepaths
}
}

Expand Down
40 changes: 4 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"command-line-args": "^6.0.0",
"command-line-usage": "^7.0.3",
"config-master": "^3.1.0",
"dmd": "next",
"dmd": "^7.0.0",
"jsdoc-api": "^9.3.0",
"jsdoc-parse": "^6.2.3",
"walk-back": "^5.1.1"
Expand Down

0 comments on commit 36b65b8

Please sign in to comment.