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); } }
/** * Read the theme option and load the paths of any recognised built in themes * Otherwise pass the path through to the Renderer */ onResolveBegin() { const options = this.application.options; const theme = (options.getValue('platform') as string) || (options.getValue('theme') as string); // if the theme is 'default' or 'markdown' load the base markdown theme if (theme === 'default' || theme === 'markdown') { options.setValue('theme', path.join(__dirname)); } // load any built in sub themes const subThemes = ['docusaurus', 'docusaurus2', 'vuepress', 'gitbook', 'bitbucket']; if (subThemes.includes(theme)) { options.setValue('theme', path.join(__dirname, 'subthemes', theme)); } }
constructor(renderer: Renderer, basePath: string) { super(renderer, basePath); this.listenTo(renderer, PageEvent.END, this.onPageEnd, 1024); // cleanup html specific components renderer.removeComponent('assets'); renderer.removeComponent('javascript-index'); renderer.removeComponent('toc'); renderer.removeComponent('pretty-print'); // add markdown related componenets renderer.addComponent('helpers', new ContextAwareHelpersComponent(renderer)); renderer.addComponent('options', new OptionsComponent(renderer)); this.indexName = this.application.options.getValue('name'); if (!this.indexName) { throw new Error('`--name` must be provided') } }
initialize() { super.initialize(); const namedAnchors = this.application.options.getValue('namedAnchors'); const hideBreadcrumbs = this.application.options.getValue('hideBreadcrumbs'); const hideIndexes = this.application.options.getValue('hideIndexes'); const hideSourceFiles = this.application.options.getValue('hideSources'); MarkdownTheme.handlebars.registerHelper('ifNamedAnchors', function(options) { return namedAnchors ? options.fn(this) : options.inverse(this); }); MarkdownTheme.handlebars.registerHelper('ifBreadcrumbs', function(options) { return hideBreadcrumbs ? options.inverse(this) : options.fn(this); }); MarkdownTheme.handlebars.registerHelper('ifIndexes', function(options) { return hideIndexes ? options.inverse(this) : options.fn(this); }); MarkdownTheme.handlebars.registerHelper('ifSources', function(options) { return hideSourceFiles ? options.inverse(this) : options.fn(this); }); }
initialize() { super.initialize(); this.includes = this.application.options.getValue('includes'); this.mediaDirectory = this.application.options.getValue('media'); this.listInvalidSymbolLinks = this.application.options.getValue('listInvalidSymbolLinks'); this.listenTo( this.owner, { [RendererEvent.END]: this.onEndRenderer, }, undefined, 100, ); const component = this; MarkdownTheme.handlebars.registerHelper('comment', function(this: string) { return component.parseComments(this); }); MarkdownTheme.handlebars.registerHelper('breadcrumbs', function(this: PageEvent) { return component.breadcrumb(this.model, this.project, []); }); MarkdownTheme.handlebars.registerHelper('relativeURL', (url: string) => { return url ? this.getRelativeUrl(url) : url; }); }
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); } }