Skip to content

Commit

Permalink
Merge pull request #124 from edchapel/add-skip-sidebar-for-docusaurus2
Browse files Browse the repository at this point in the history
Adds skipSidebar option for docusaurus2
  • Loading branch information
tgreyuk committed Jun 2, 2020
2 parents 9bb38da + dfda3fd commit b35a4d9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -43,7 +43,7 @@ The following arguments can be used in addition to the default [TypeDoc argument
- `--hideBreadcrumbs`<br>
Do not print breadcrumbs.
- `--skipSidebar`<br>
Do not update the `sidebar.json` file when used with `docusaurus` theme.
Do not update the `sidebar.json` file when used with `docusaurus` or `docusaurus2` theme.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -54,7 +54,7 @@ export = (PluginHost: Application) => {
});

app.options.addDeclaration({
help: 'Skips updating of the sidebar.json file when used with docusaurus theme',
help: 'Skips updating of the sidebar.json file when used with docusaurus or docusaurus2 theme',
name: 'skipSidebar',
type: ParameterType.Boolean,
});
Expand Down
16 changes: 9 additions & 7 deletions src/subthemes/docusaurus/theme.ts
Expand Up @@ -15,14 +15,16 @@ export default class DocusaurusTheme extends MarkdownTheme {
}

onRendererEnd(renderer: RendererEvent) {
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;
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);
}
if (!this.application.options.getValue('skipSidebar')) { this.writeSideBar(renderer, docusarusRoot); }
}

writeSideBar(renderer: RendererEvent, docusarusRoot: string) {
Expand Down
16 changes: 9 additions & 7 deletions src/subthemes/docusaurus2/theme.ts
Expand Up @@ -17,14 +17,16 @@ export default class Docusaurus2Theme extends MarkdownTheme {
}

onRendererEnd(renderer: RendererEvent) {
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;
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);
}
this.writeSideBar(renderer, docusarusRoot);
}

writeSideBar(renderer: RendererEvent, docusarusRoot: string) {
Expand Down

0 comments on commit b35a4d9

Please sign in to comment.