docusaurus-plugin-typedoc-api icon indicating copy to clipboard operation
docusaurus-plugin-typedoc-api copied to clipboard

Types across monorepo packages are not linked

Open nazarhussain opened this issue 3 years ago • 4 comments

Hi,

I am using this plugin to generate API docs for a mono repo. There is one concern I could not resolve, the types reference across mono-repo packages are not linked.

There is a typeodc plugin for this purpose, which is loaded but not performs what's expected. https://github.com/luizstacio/typedoc-monorepo-link-types

When we have following snippet.

// packages/package-1/src/index.ts

import {BaseClass} from 'package-2';

class ExtendedClass extends BaseClass { }

The docs for the ExtendedClass under hierarchy section does not link the BaseClass.

If we use the @link for those imported types these works fine.

// packages/package-1/src/index.ts

import {BaseClass} from 'package-2';

/**
* {@link BaseClass}
*/
class ExtendedClass extends BaseClass { }

In above snippet the @link modifier works fine and points to the right package in the API docs. That means the type info is available but not rendered properly. This seems to be a very basic behavior for a mono-repo packages.

Is there some configuration to enable this or is it a bug?

nazarhussain avatar Jun 22 '22 15:06 nazarhussain

I tried the typedoc-monorepo-link-types plugin, but it doesn't seem like the JSON output is altered in anyway, so I still don't have access to the linked data.

milesj avatar Jul 10 '22 23:07 milesj

Hey @milesj! It looks to be a limitation of TypeDoc itself - https://github.com/TypeStrong/typedoc/issues/1612

I tried typedoc-monorepo-link-types and it seems like it might be part of the solution. However, instead of "linking" to types from other packages, it creates an artificial "internal" namespace in each package, where it aggregates any types TypeDoc couldn't resolve within the package itself, copying their documentation.

Screenshot 2022-08-01 at 00 37 25

Here's the "internal" namespace with Interaction (internal class) docs copied over from the core package:

Screenshot 2022-08-01 at 00 43 26

And here's the Interaction documented within the core package:

Screenshot 2022-08-01 at 00 43 54

Apart from duplication of documentation, another problem with typedoc-monorepo-link-types is that links to types in aggregate pages link to incorrect internal packages.


I do wonder if we could take some inspiration from typedoc-monorepo-link-types, but instead of producing aggregate pages link to correct internal packages?

jan-molak avatar Jul 31 '22 22:07 jan-molak

I do wonder if we could take some inspiration from typedoc-monorepo-link-types, but instead of producing aggregate pages link to correct internal packages?

that will be a nice idea.

nazarhussain avatar Aug 01 '22 06:08 nazarhussain

Yeah, I feel like we might need to build our own plugin, or at least fork typedoc-monorepo-link-types to get it to work the way we want.

milesj avatar Aug 01 '22 17:08 milesj