Skip to content

Commit 9f292d9

Browse files
committed
feat: --ignore flag
Signed-off-by: flakey5 <[email protected]>
1 parent e54e152 commit 9f292d9

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 1 deletion
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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,27 @@ 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 resolvedFiles = globSync(searchPath).filter(
25+
const loadFiles = (searchPath, ignorePath) => {
26+
let resolvedFiles = globSync(searchPath).filter(
2627
filePath => extname(filePath) === '.md'
2728
);
2829

30+
if (ignorePath) {
31+
const ignoredFiles = globSync(ignorePath).filter(
32+
filePath => extname(filePath) === '.md'
33+
);
34+
35+
resolvedFiles = resolvedFiles.filter(
36+
value => !ignoredFiles.includes(value)
37+
);
38+
}
39+
2940
return resolvedFiles.map(async filePath => {
3041
const fileContents = await readFile(filePath, 'utf-8');
3142

0 commit comments

Comments
 (0)