-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: use a processor to transform the operator decision tree data (#…
- Loading branch information
Showing
29 changed files
with
111 additions
and
154 deletions.
There are no files selected for viewing
File renamed without changes.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
apps/rxjs.dev/tools/transforms/rxjs-decision-tree-generator/index.ts
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,37 @@ | ||
import { readFile } from 'fs/promises'; | ||
import { parse } from 'yamljs'; | ||
|
||
import { TreeNodeRaw, build, flattenApiList } from './src/lib'; | ||
|
||
module.exports = function decisionTreeGenerator(log: { warn: (message: string) => void }) { | ||
return { | ||
$runBefore: ['rendering-docs'], | ||
$runAfter: ['generateApiListDoc'], | ||
$validate: { | ||
decisionTreeFile: { presence: true }, | ||
outputFolder: { presence: true }, | ||
}, | ||
$process: async function (this: any, docs: any[]) { | ||
const apiListDoc = docs.find((doc) => doc.docType === 'api-list-data'); | ||
|
||
if (!apiListDoc) { | ||
throw new Error('Can not find api-list-data for decision tree generation'); | ||
} | ||
|
||
const yamlContent = await readFile(this.decisionTreeFile, { encoding: 'utf8' }); | ||
const decisionTreeJson: TreeNodeRaw[] = parse(yamlContent); | ||
|
||
const flattenedApiList = flattenApiList(apiListDoc.data); | ||
const jsonContent = build(flattenedApiList, decisionTreeJson, log); | ||
|
||
docs.push({ | ||
docType: 'decision-tree-data', | ||
template: 'json-doc.template.json', | ||
path: this.outputFolder + '/decision-tree-data.json', | ||
outputPath: this.outputFolder + '/decision-tree-data.json', | ||
data: jsonContent, | ||
}); | ||
return docs; | ||
}, | ||
}; | ||
}; |
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
File renamed without changes.
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
Oops, something went wrong.