onRendererEnd(renderer: RendererEvent) { if (!this.application.options.getValue('skipSidebar')) { const docusarusRoot = this.findDocusaurus2Root(renderer.outputDirectory); if (docusarusRoot === null) { this.application.logger.warn( `[typedoc-markdown-plugin] ${this.sidebarName} not written as could not locate docusaurus root directory. In order to to implemnent ${this.sidebarName} functionality, the output directory must be a child of a 'docs' directory.`, ); return; } this.writeSideBar(renderer, docusarusRoot); } }
writeSummary(renderer: RendererEvent) { const outputDirectory = renderer.outputDirectory; const summaryMarkdown = this.getSummaryMarkdown(renderer); try { fs.writeFileSync(`${outputDirectory}/SUMMARY.md`, summaryMarkdown); this.application.logger.write(`[typedoc-plugin-markdown] SUMMARY.md written to ${outputDirectory}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to write SUMMARY at ${outputDirectory}`); } }
onRendererEnd(renderer: RendererEvent) { const root = this.findRoot(renderer.outputDirectory); if (root === null) { this.application.logger.warn( `[typedoc-markdown-plugin] sidebars.json not written as could not locate VuePress root directory. In order to to implemnent sidebars.json functionality, the output directory must be a child of a 'docs' directory.`, ); return; } this.writeSideBar(renderer, root); }
writeSideBar(renderer: RendererEvent, root: string) { const childDirectory = renderer.outputDirectory.split(root + 'docs/')[1]; const docsRoot = childDirectory ? childDirectory + '/' : ''; const vuePressRoot = root + 'docs/.vuepress'; const navObject = this.getNavObject(renderer, docsRoot); const sidebarPath = vuePressRoot + '/api-sidebar.json'; const relativeNavObject = this.getNavObject(renderer); const relativeSidebarPath = vuePressRoot + '/api-sidebar-relative.json'; if (!fs.existsSync(vuePressRoot)) { fs.mkdirSync(vuePressRoot); } try { fs.writeFileSync(sidebarPath, JSON.stringify(navObject, null, 2)); fs.writeFileSync(relativeSidebarPath, JSON.stringify(relativeNavObject, null, 2)); this.application.logger.write(`[typedoc-plugin-markdown] sidebars.json updated at ${sidebarPath}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to update sidebars.json at ${sidebarPath}`); } }
writeSideBar(renderer: RendererEvent, docusarusRoot: string) { const childDirectory = renderer.outputDirectory.split(docusarusRoot + 'docs/')[1]; const docsRoot = childDirectory ? childDirectory + '/' : ''; const websitePath = docusarusRoot + 'website'; const packageName = renderer.project.packageInfo.name; const navObject = this.getNavObject(renderer, docsRoot); const sidebarPath = websitePath + '/sidebars.json'; let contents: any; if (!fs.existsSync(sidebarPath)) { contents = '{}'; if (!fs.existsSync(websitePath)) { fs.mkdirSync(websitePath); } } else { contents = fs.readFileSync(sidebarPath); } const jsonContent = JSON.parse(contents.toString()); const update = { ...jsonContent, [packageName]: navObject, }; try { fs.writeFileSync(sidebarPath, JSON.stringify(update, null, 2)); this.application.logger.write(`[typedoc-plugin-markdown] sidebars.json updated at ${sidebarPath}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to update sidebars.json at ${sidebarPath}`); } }
this.application.logger.warn( `Found inheritance chain with depth > 20, stopping no inherit check: ${current.getFullName()}` );
/** * Triggered when [[Renderer]] is finished */ onEndRenderer(event: RendererEvent) { if (this.listInvalidSymbolLinks && this.warnings.length > 0) { this.application.logger.write(''); this.application.logger.warn( 'Found invalid symbol reference(s) in JSDocs, ' + 'they will not render as links in the generated documentation.', ); for (const warning of this.warnings) { this.application.logger.write(' ' + warning); } } }
onRendererEnd(renderer: RendererEvent) { if (!this.application.options.getValue('skipSidebar')) { const docusarusRoot = this.findDocusaurusRoot(renderer.outputDirectory); if (docusarusRoot === null) { this.application.logger.warn( `[typedoc-markdown-plugin] sidebars.json not written as could not locate docusaurus root directory. In order to to implemnent sidebars.json functionality, the output directory must be a child of a 'docs' directory.`, ); return; } this.writeSideBar(renderer, docusarusRoot); } }
writeSideBar(renderer: RendererEvent, docusarusRoot: string) { const childDirectory = renderer.outputDirectory.split(docusarusRoot + 'docs/')[1]; const docsRoot = childDirectory ? childDirectory + '/' : ''; const websitePath = docusarusRoot; const navObject = this.getNavObject(renderer, docsRoot); const sidebarPath = websitePath + this.sidebarName; let jsonContent: any; if (!fs.existsSync(sidebarPath)) { if (!fs.existsSync(websitePath)) { fs.mkdirSync(websitePath); } jsonContent = JSON.parse('{}'); } else { jsonContent = require(sidebarPath); } let firstKey = Object.keys(jsonContent)[0]; if (!firstKey) { firstKey = 'docs'; } jsonContent[firstKey] = Object.assign({}, jsonContent[firstKey], navObject); try { fs.writeFileSync(sidebarPath, 'module.exports = ' + JSON.stringify(jsonContent, null, 2) + ';'); this.application.logger.write(`[typedoc-plugin-markdown] ${this.sidebarName} updated at ${sidebarPath}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to update ${this.sidebarName} at ${sidebarPath}`); } }
/** * Copy of default theme DefaultTheme.getEntryPoint * @param project */ getEntryPoint(project: ProjectReflection): ContainerReflection { const entryPoint = this.owner.entryPoint; // if (project.children?.[0].comment.tags?.[0] !== undefined) { // project.children[0].comment.tags[0].text = 'hello , World'; // return project.children[0].children[0]; // } if (entryPoint) { const reflection = project.getChildByName(entryPoint); if (reflection) { if (reflection instanceof ContainerReflection) { return reflection; } else { this.application.logger.warn('The given entry point `%s` is not a container.', entryPoint); } } else { this.application.logger.warn('The entry point `%s` could not be found.', entryPoint); } } return project; }