Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds skipSidebar option for docusaurus2 #124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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