Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ CLI tool to generate API documentation of a Node.js project.

Options:
-i, --input [patterns...] Specify input file patterns using glob syntax
--ignore [patterns...] Specify files to be ignored from the input using glob syntax
-o, --output <path> Specify the relative or absolute output directory
-v, --version <semver> Specify the target version of Node.js, semver compliant (default: "v22.6.0")
-c, --changelog <url> Specify the path (file: or https://) to the CHANGELOG.md file (default: "https://raw.githubusercontent.com/nodejs/node/HEAD/CHANGELOG.md")
Expand Down
9 changes: 8 additions & 1 deletion bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ program
'Specify input file patterns using glob syntax'
).makeOptionMandatory()
)
.addOption(
new Option(
'--ignore [patterns...]',
'Specify which input files to ignore using glob syntax'
)
)
.addOption(
new Option(
'-o, --output <path>',
Expand Down Expand Up @@ -87,6 +93,7 @@ program
*/
const {
input,
ignore,
output,
target = [],
version,
Expand All @@ -101,7 +108,7 @@ const linter = createLinter(lintDryRun, disableRule);
const { loadFiles } = createMarkdownLoader();
const { parseApiDocs } = createMarkdownParser();

const apiDocFiles = loadFiles(input);
const apiDocFiles = loadFiles(input, ignore);

const parsedApiDocs = await parseApiDocs(apiDocFiles);

Expand Down
10 changes: 8 additions & 2 deletions src/loaders/markdown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ const createLoader = () => {
* Loads API Doc files and transforms it into VFiles
*
* @param {string} searchPath A glob/path for API docs to be loaded
* @param {string | undefined} ignorePath A glob/path of files to ignore
* The input string can be a simple path (relative or absolute)
* The input string can also be any allowed glob string
*
* @see https://code.visualstudio.com/docs/editor/glob-patterns
*/
const loadFiles = searchPath => {
const loadFiles = (searchPath, ignorePath) => {
const ignoredFiles = ignorePath
? globSync(ignorePath).filter(filePath => extname(filePath) === '.md')
: [];

const resolvedFiles = globSync(searchPath).filter(
filePath => extname(filePath) === '.md'
filePath =>
extname(filePath) === '.md' && !ignoredFiles.includes(filePath)
);

return resolvedFiles.map(async filePath => {
Expand Down
Loading