Skip to content

Commit

Permalink
If options.configure is passed, neither .files nor .source are mandat…
Browse files Browse the repository at this point in the history
…ory. #27
  • Loading branch information
75lb committed Aug 25, 2024
1 parent baf0551 commit 00bbf84
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ util.inspect.defaultOptions.depth = 6
util.inspect.defaultOptions.breakLength = process.stdout.columns
util.inspect.defaultOptions.maxArrayLength = Infinity

const data = await jsdoc.explain({ files: process.argv.slice(2), cache: true, pedantic: true })
const data = await jsdoc.explain({ files: process.argv.slice(2), cache: true })
console.log(data)
8 changes: 8 additions & 0 deletions example/using-config-explain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import jsdoc from 'jsdoc-api'
import util from 'node:util'
util.inspect.defaultOptions.depth = 6
util.inspect.defaultOptions.breakLength = process.stdout.columns
util.inspect.defaultOptions.maxArrayLength = Infinity

const data = await jsdoc.explain({ cache: true, configure: './example/using-config.json' })
console.log(data)
4 changes: 4 additions & 0 deletions example/using-config-input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* A documented function.
*/
function something () {}
3 changes: 3 additions & 0 deletions example/using-config-render.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import jsdoc from 'jsdoc-api'

await jsdoc.render({ configure: './example/using-config.json' })
8 changes: 8 additions & 0 deletions example/using-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"source": {
"include": [ "example/using-config-input.js" ]
},
"opts": {
"destination": "./config-out/"
}
}
4 changes: 2 additions & 2 deletions lib/jsdoc-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const { __dirname } = currentModulePaths(import.meta.url)
class JsdocCommand {
constructor (options = {}, cache) {
assert.ok(
options.files?.length || options.source,
'Must set either .files or .source'
options.files?.length || options.source || options.configure,
'Must set at least one of .files, .source or .configure'
)
options.files = arrayify(options.files)

Expand Down
2 changes: 1 addition & 1 deletion test/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test.set('.explain({ files }): generate a warning', async function () {
test.set('.explain({ files }): files is empty', async function () {
a.rejects(
() => jsdoc.explain({ files: [] }),
/Must set either .files or .source/
/Must set at least one of .files, .source or .configure/
)
})

Expand Down

0 comments on commit 00bbf84

Please sign in to comment.