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

Integration with typedoc-plugin-missing-exports #86

Open
csantos1113 opened this issue Dec 14, 2022 · 1 comment
Open

Integration with typedoc-plugin-missing-exports #86

csantos1113 opened this issue Dec 14, 2022 · 1 comment

Comments

@csantos1113
Copy link

csantos1113 commented Dec 14, 2022

Hey @milesj - thanks for the quick fix for #84

I'm unfortunately having a new/similar error now with the typedoc-plugin-missing-exports plugin and docusaurus-plugin-typedoc-api.

The TL;DR of that plugin:

After TypeDoc has finished converting packages, it will look for types which are referenced, but not exported, and place them into an internal module for that entry point (called <internal> by default).

And you can see where my issue is going to, With the following config:

const __dirname = dirname(url.fileURLToPath(import.meta.url));
const projectRoot = join(__dirname, '..');

[
  'docusaurus-plugin-typedoc-api',
  {
    projectRoot,
    packages: ['packages/web'],
    changelogs: false,
    readmes: true,
    gitRefName: 'main',
    typedocOptions: {
      plugin: ['typedoc-plugin-missing-exports']
    }
  }
],

I get this .docusaurus/api-typedoc-default.json output:

{
  "id": 0,
  "name": "web",
  "kind": 1,
  "kindString": "Project",
  "flags": {},
  "originalName": "",
  "children": [
    { "kindString": "Reference", "...": 58 },
    { "kindString": "Reference", "...": 100 },
     // ...
    {
      "id": 5380,
      "name": "<internal>",
      "kind": 2,
      "kindString": "Module",
      "flags": {},
      "children": [{}, {}]
      }
  ]
}

const hasNoModules = project.children?.every((child) => child.kind !== ReflectionKind.Module);
if (hasNoModules) {
// No "module" children:
// - Polyrepos
// - Monorepos with 1 package
modules.push(project);
} else {
// Has "module" children:
// - Polyrepos with deep imports
// - Polyrepos with multi-imports
// - Monorepos
inheritChildren();
}

☝️ these lines are finding the <internal> Module as the module, instead of handling the web project as the module itself.

Question

Is there any way from the top of your head on how to make this work?

I almost wonder if docusaurus-plugin-typedoc-api should receive an explicit config property where we can indicate whether or not it's a monorepo so the plugin doesn't need to do all the magic, but not sure if that is a good idea (I'm not too familiar with TypeDoc)

@milesj
Copy link
Owner

milesj commented Dec 15, 2022

@csantos1113 A few things:

I have no plans to directly support typedoc plugins, but I'll review any contributions/PRs for it.

Also, it's not just a polyrepo vs monorepo problem. As shown in the code snippet above, it also takes into account deep imports, multi imports, index imports, etc. This applies to both poly and mono, so there's a handful of combinations to support. This wouldn't be as easy as a flag.

At minimum, the hasNoModules can probably just ignore <internal> modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants