Skip to content

Commit

Permalink
fix: Correctly handle sidebar ids in windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Apr 22, 2024
1 parent 68eddca commit d44e7fd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-seals-count.md
@@ -0,0 +1,5 @@
---
"docusaurus-plugin-typedoc": patch
---

- Correctly handle sidebar ids in Windows (#597).
15 changes: 6 additions & 9 deletions docs/pages/plugins/docusaurus/options.mdx
Expand Up @@ -30,8 +30,6 @@ The following options are exposed by this plugin:

> Accepts a key/value object.
> _In addition to the sidebar options listed below, you can configure the structure of the sidebar by utilizing the TypeDoc [`navigation options`](https://typedoc.org/options/output/#navigation) `includeGroups`, `includeCategories` and `includeFolders`_.
**sidebar.autoConfiguration**

Set to `false` to disable sidebar generation. Defaults to `true`.
Expand All @@ -42,13 +40,12 @@ Pretty format the sidebar JSON.

Please see the [sidebar guide](/plugins/docusaurus/guide/sidebar) for additional information on sidebar setup.

```json filename="Example"
"navigation": {
"includeGroups": true,
"includeCategories": true
},
"sidebar": {
"pretty": true
```json filename="typedoc.json"
{
"sidebar": {
"autoConfiguration": true,
"pretty": false
}
}
```

Expand Down
15 changes: 0 additions & 15 deletions packages/docusaurus-plugin-typedoc/src/options/declarations.ts
Expand Up @@ -2,9 +2,6 @@ import { ParameterType } from 'typedoc';
import { DEFAULT_SIDEBAR_OPTIONS } from '../options';

/**
*
* > *In addition to the sidebar options listed below, you can configure the structure of the sidebar by utilizing the TypeDoc [`navigation options`](https://typedoc.org/options/output/#navigation) `includeGroups`, `includeCategories` and `includeFolders`*.
*
* **sidebar.autoConfiguration**
*
* Set to `false` to disable sidebar generation. Defaults to `true`.
Expand All @@ -15,18 +12,6 @@ import { DEFAULT_SIDEBAR_OPTIONS } from '../options';
*
* Please see the [sidebar guide](/plugins/docusaurus/guide/sidebar) for additional information on sidebar setup.
*
* ```json filename="Example"
* "navigation": {
* "includeGroups": true,
* "includeCategories": true
* },
* "sidebar": {
* "pretty": true
* }
* ```
*
* @omitExample
*
*/
export const sidebar = {
help: 'Configures the autogenerated Docusaurus sidebar.',
Expand Down
14 changes: 3 additions & 11 deletions packages/docusaurus-plugin-typedoc/src/plugin.ts
Expand Up @@ -41,14 +41,14 @@ export default async function pluginDocusaurus(
}

/**
* Initiates a new typedoc Application bootstraped with plugin options
* Initiates a new typedoc Application bootstrapped with plugin options
*/
async function generateTypedoc(context: any, opts: Partial<PluginOptions>) {
const { siteDir } = context;

const pluginOpions = getPluginOptions(opts);
const pluginOptions = getPluginOptions(opts);

const { id, sidebar, ...optionsPassedToTypeDoc } = pluginOpions;
const { id, sidebar, ...optionsPassedToTypeDoc } = pluginOptions;

const app = await Application.bootstrapWithPlugins(optionsPassedToTypeDoc);

Expand All @@ -70,14 +70,6 @@ async function generateTypedoc(context: any, opts: Partial<PluginOptions>) {
async (output: MarkdownRendererEvent) => {
if (output.navigation) {
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
const sidebarJSONPath = path.resolve(
outputDir,
'typedoc-sidebar.json',
);
fs.writeFileSync(
sidebarJSONPath,
JSON.stringify(output.navigation, null, 2),
);
const baseDir = path
.relative(siteDir, outputDir)
.split(path.sep)
Expand Down
10 changes: 5 additions & 5 deletions packages/docusaurus-plugin-typedoc/src/sidebar.ts
Expand Up @@ -28,7 +28,7 @@ function getNavigationItem(
idParts.push(basePath);
}
if (parsedUrl) {
idParts.push(parsedUrl);
idParts.push(parsedUrl.replace(/\\/g, '/'));
}
if (navigationItem.path) {
return idParts.join('/').replace(/(.*)\.\w+$/, '$1');
Expand All @@ -53,9 +53,9 @@ function getNavigationItem(

return id
? {
type: 'doc',
id,
label: `${navigationItem.title}`,
}
type: 'doc',
id,
label: `${navigationItem.title}`,
}
: null;
}

0 comments on commit d44e7fd

Please sign in to comment.