-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
107 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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,47 @@ | ||
import { createJsLoader } from '../../loader.mjs'; | ||
import { createJsParser } from '../../parser.mjs'; | ||
|
||
/** | ||
* This generator parses Javascript sources passed into the generator's input | ||
* field. This is separate from the Markdown parsing step since it's not as | ||
* commonly used and can take up a significant amount of memory. | ||
* | ||
* Putting this with the rest of the generators allows it to be lazily loaded | ||
* so we're only parsing the Javascript sources when we need to. | ||
* | ||
* @typedef {unknown} Input | ||
* | ||
* @type {import('../types.d.ts').GeneratorMetadata<Input, Array<JsProgram>>} | ||
*/ | ||
export default { | ||
name: 'ast-js', | ||
|
||
version: '1.0.0', | ||
|
||
description: 'Parses Javascript source files passed into the input.', | ||
|
||
dependsOn: 'ast', | ||
|
||
/** | ||
* @param {Input} _ | ||
* @param {Partial<GeneratorOptions>} options | ||
*/ | ||
async generate(_, options) { | ||
const { loadFiles } = createJsLoader(); | ||
|
||
if (!options.input) { | ||
return []; | ||
} | ||
|
||
// Load all of the Javascript sources into memory | ||
const sourceFiles = loadFiles(options.input); | ||
|
||
const { parseJsSources } = createJsParser(); | ||
|
||
// Parse the Javascript sources into ASTs | ||
const parsedJsFiles = await parseJsSources(sourceFiles); | ||
|
||
// Return the ASTs so they can be used in another generator | ||
return parsedJsFiles; | ||
}, | ||
}; |
This file contains 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 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 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export * as constants from './constants.mjs'; | ||
export { default as generators } from './generators/index.mjs'; | ||
export { default as createGenerator } from './generators.mjs'; | ||
export { default as createLoader } from './loader.mjs'; | ||
export * from './loader.mjs'; | ||
export { default as createMetadata } from './metadata.mjs'; | ||
export { default as createParser } from './parser.mjs'; | ||
export * from './parser.mjs'; | ||
export { default as createQueries } from './queries.mjs'; | ||
export { default as createNodeReleases } from './releases.mjs'; |
This file contains 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 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