typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
689 stars 172 forks source link

Error: Invalid sidebar file #558

Closed axel7083 closed 5 months ago

axel7083 commented 5 months ago

Using the following dependencies

I am using integrations/docusaurus/sidebar as recommended by @tgreyuk in https://github.com/tgreyuk/typedoc-plugin-markdown/issues/557#issuecomment-1917384674

However, I am getting a small issue about the document ids:

[info] Documentation generated at ./api
[ERROR] Loading of version failed for version current
Error: Invalid sidebar file at "sidebars-api.js".
These sidebar document ids do not exist:
- /classes/Disposable
- /classes/EventEmitter
....
Available document ids are:
- classes/Disposable
- classes/EventEmitter
....

It seems that a / is prefixed and not expected. Leading to an error.

Current configuration

I am generating the documentation in its own documentation (./api).

Here is the interesting part of docusaurus.config.js

...
[
  '@docusaurus/plugin-content-docs',
  {
    id: 'api',
    path: 'api',
    routeBasePath: 'api',
    sidebarPath: resolve('./sidebars-api.js'),
  },
],
[
  'docusaurus-plugin-typedoc',
  {
    id: 'api',
    plugin: ['typedoc-plugin-markdown'],
    entryPoints: [resolve('../packages/extension-api.d.ts')],
    out: 'api',
    hideBreadcrumbs: true,
    readme: 'none',
    tsconfig: resolve('../packages/extension-api/tsconfig.json'),
  },
],
...

The sidebars-api.json

const sidebars = {
  typedocSidebar: [
    {
      type: 'category',
      label: 'Typedoc API',
      link: {
        type: 'doc',
        id: 'api',
      },
      items: require('./api/typedoc-sidebar.cjs'),
    },
  ],
};
module.exports = sidebars;
tgreyuk commented 5 months ago

Thanks. Yeah the plugin wasn't handling an alternative routeBasePath.

Should be working correctly in following versions:

docusaurus-plugin-typedoc@1.0.0-next.27 typedoc-plugin-markdown@4.0.0-next.45

axel7083 commented 5 months ago

Perfect, @tgreyuk thanks you very much for your great work !

To make it work with the new version I just had to change the link property in the sidebars-api.js

link: {
        type: 'doc',
        id: 'index,
      },