Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3ad74f7

Browse files
authoredMar 10, 2025··
feat: --ignore flag (#206)
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
1 parent e54e152 commit 3ad74f7

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ CLI tool to generate API documentation of a Node.js project.
3636

3737
Options:
3838
-i, --input [patterns...] Specify input file patterns using glob syntax
39+
--ignore [patterns...] Specify files to be ignored from the input using glob syntax
3940
-o, --output <path> Specify the relative or absolute output directory
4041
-v, --version <semver> Specify the target version of Node.js, semver compliant (default: "v22.6.0")
4142
-c, --changelog <url> Specify the path (file: or https://) to the CHANGELOG.md file (default: "https://raw.githubusercontent.com/nodejs/node/HEAD/CHANGELOG.md")

‎bin/cli.mjs

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ program
2929
'Specify input file patterns using glob syntax'
3030
).makeOptionMandatory()
3131
)
32+
.addOption(
33+
new Option(
34+
'--ignore [patterns...]',
35+
'Specify which input files to ignore using glob syntax'
36+
)
37+
)
3238
.addOption(
3339
new Option(
3440
'-o, --output <path>',
@@ -87,6 +93,7 @@ program
8793
*/
8894
const {
8995
input,
96+
ignore,
9097
output,
9198
target = [],
9299
version,
@@ -101,7 +108,7 @@ const linter = createLinter(lintDryRun, disableRule);
101108
const { loadFiles } = createMarkdownLoader();
102109
const { parseApiDocs } = createMarkdownParser();
103110

104-
const apiDocFiles = loadFiles(input);
111+
const apiDocFiles = loadFiles(input, ignore);
105112

106113
const parsedApiDocs = await parseApiDocs(apiDocFiles);
107114

‎src/loaders/markdown.mjs

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ const createLoader = () => {
1616
* Loads API Doc files and transforms it into VFiles
1717
*
1818
* @param {string} searchPath A glob/path for API docs to be loaded
19+
* @param {string | undefined} ignorePath A glob/path of files to ignore
1920
* The input string can be a simple path (relative or absolute)
2021
* The input string can also be any allowed glob string
2122
*
2223
* @see https://code.visualstudio.com/docs/editor/glob-patterns
2324
*/
24-
const loadFiles = searchPath => {
25+
const loadFiles = (searchPath, ignorePath) => {
26+
const ignoredFiles = ignorePath
27+
? globSync(ignorePath).filter(filePath => extname(filePath) === '.md')
28+
: [];
29+
2530
const resolvedFiles = globSync(searchPath).filter(
26-
filePath => extname(filePath) === '.md'
31+
filePath =>
32+
extname(filePath) === '.md' && !ignoredFiles.includes(filePath)
2733
);
2834

2935
return resolvedFiles.map(async filePath => {

0 commit comments

Comments
 (0)
Please sign in to comment.