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
722 stars 177 forks source link

id in typedoc-sidebar.cjs incorrectly calculated #648

Closed shalugin closed 4 months ago

shalugin commented 4 months ago

What package is the bug related to?

docusaurus-plugin-typedoc

Describe the issue

If the documentation is in a separate folder, then the id will be calculated incorrectly.

{
  /// ...
  presets: [
    [
      'classic',
      {
        docs: {
          path: '../docs',
          routeBasePath: '/',
          sidebarPath: './sidebars.ts',
        },
        blog: false,
        theme: {
          customCss: './src/css/custom.css',
        },
      } satisfies Preset.Options,
    ],
  ],
  // ...
  plugins: [
    require.resolve('docusaurus-plugin-image-zoom'),
    [
      require.resolve('@easyops-cn/docusaurus-search-local'),
      {
        docsRouteBasePath: '/',
        docsDir: '../docs',
        indexBlog: false,
      },
    ],
    [
        'docusaurus-plugin-typedoc',
        // Options
        {
            entryPoints: [
              '../../tt/packages/myPackage',
            ],
            entryPointStrategy: 'packages',
            tsconfig: '../../tt/tsconfig.json',
            out: '../docs/api-reference',
            readme: 'none',
            sidebar: {
                autoConfiguration: true,
                pretty: true,
            },
        },
    ],
  ],

Please note that the documentation lies at a higher level (../doc).

The id field in typedoc-sidebar.cjs will look something like this: "id": "docs/api-reference/" But should be something like this: "id": "api-reference/"

It seems that the location of the documentation is not being taken into account right now - https://github.com/typedoc2md/typedoc-plugin-markdown/blob/main/packages/docusaurus-plugin-typedoc/src/plugin.ts#L79

TypeDoc configuration

Deps:

{
  "dependencies": {
    "@docusaurus/core": "3.4.0",
    "@docusaurus/preset-classic": "3.4.0",
    "@docusaurus/theme-mermaid": "^3.4.0",
    "@easyops-cn/docusaurus-search-local": "^0.44.3",
    "@mdx-js/react": "^3.0.0",
    "clsx": "^2.0.0",
    "docusaurus-plugin-image-zoom": "^2.0.0",
    "prism-react-renderer": "^2.3.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0"
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "3.4.0",
    "@docusaurus/tsconfig": "3.4.0",
    "@docusaurus/types": "3.4.0",
    "docusaurus-plugin-typedoc": "^1.0.2",
    "typedoc": "^0.26.3",
    "typedoc-plugin-frontmatter": "^1.0.0",
    "typedoc-plugin-markdown": "^4.1.2",
    "typescript": "~5.2.2"
  }
}

Expected behavior

The id field is calculated relative to the root documentation.

tgreyuk commented 4 months ago

Thanks for detailed description. Hopefully fixed in docusaurus-plugin-typedoc@1.0.3.

shalugin commented 4 months ago

Thanks for the quick fix! Now it works!