-
Notifications
You must be signed in to change notification settings - Fork 9
feat: introduced CLI mode to the parser #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8f6d415
feat: introduced CLI mode to the parser
canerakdas 3513f2c
fix: top level await
canerakdas 32ccb22
chore: resolve conflict
canerakdas 09dd7ff
chore: remove .gitkeep
canerakdas 0a238c7
Merge branch 'main' into feat/cli-parser
canerakdas 4c4c5ec
refactor: uses loaders, parsers, and generators
canerakdas 32ed6d2
refactor: multiple target mode
canerakdas 0ab7045
refactor: import order changed
canerakdas a47ee14
chore: package name added
canerakdas a147844
refactor: code review
canerakdas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
|
||
import { argv } from 'node:process'; | ||
import { resolve } from 'node:path'; | ||
|
||
import { Command, Option } from 'commander'; | ||
|
||
import createGenerator from '../src/generators.mjs'; | ||
import createLoader from '../src/loader.mjs'; | ||
import createParser from '../src/parser.mjs'; | ||
import generators from '../src/generators/index.mjs'; | ||
|
||
const program = new Command(); | ||
|
||
program | ||
.name('api-docs-tooling') | ||
.description('CLI tool to generate API documentation of a Node.js project.') | ||
.requiredOption( | ||
'-i, --input <patterns...>', | ||
'Specify input file patterns using glob syntax' | ||
) | ||
.requiredOption('-o, --output <path>', 'Specify the output directory path') | ||
.addOption( | ||
new Option( | ||
'-t, --target [mode...]', | ||
'Set the processing target mode' | ||
).choices(Object.keys(generators)) | ||
) | ||
.parse(argv); | ||
|
||
/** | ||
* @typedef {keyof generators} Target A list of the available generator names. | ||
* | ||
* @typedef {Object} Options | ||
* @property {Array<string>|string} input Specifies the glob/path for input files. | ||
* @property {string} output Specifies the directory where output files will be saved. | ||
* @property {Target} target Specifies the generator target mode. | ||
* | ||
* @name ProgramOptions | ||
* @type {Options} | ||
* @description The return type for values sent to the program from the CLI. | ||
*/ | ||
const { input, output, target } = program.opts(); | ||
|
||
const { loadFiles } = createLoader(); | ||
const { parseApiDocs } = createParser(); | ||
|
||
const apiDocFiles = loadFiles(input); | ||
|
||
const parsedApiDocs = await parseApiDocs(apiDocFiles); | ||
|
||
const { runGenerators } = createGenerator(parsedApiDocs); | ||
|
||
await runGenerators({ | ||
generators: target, | ||
output: resolve(output), | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.