type2docfx
Version:
A tool to convert json format output from TypeDoc to universal reference model for DocFx to consume.
37 lines (31 loc) • 1.01 kB
text/typescript
import { YamlModel, Root } from './interfaces/YamlModel';
import { TocItem } from './interfaces/TocItem';
export function generateModules(tocRoots: TocItem[]): Root[] {
let result: Root[] = [];
tocRoots.forEach(tocRoot => {
let root: Root = {
items: [],
references: []
};
let moduleModel: YamlModel = {
uid: tocRoot.uid,
name: tocRoot.name,
summary: '',
langs: [ 'typeScript' ],
type: 'module',
children: []
};
if (tocRoot.items && tocRoot.items.length) {
tocRoot.items.forEach(item => {
(moduleModel.children as string[]).push(item.uid);
root.references.push({
uid: item.uid,
name: item.name
});
});
root.items.push(moduleModel);
result.push(root);
}
});
return result;
}