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

Inconsistent behaviour of `@link`, `@apiLink` and `[[...]]`

Open jan-molak opened this issue 3 years ago • 4 comments

Hey @milesj!

It seems like @link, @apiLink and [[...]] have a slightly inconsistent behaviour, so I thought I'd summarise it here.

In short, using @link with descriptions works fine when linking to classes in other modules of my monorepo, but fails when used to link to classes in the same module.

scenario example @link @apiLink [[...]]
Direct link to a class in the same module MyClass
Direct link to a class in a different module MyClass
Link to a class in the same module with description MyClass|my descr 🚫 - renders "descr", no "my", no link 🚫
Link to a class in a different module with description MyClass|my descr 🚫
Link to a method of a class in the same module MyClass.method 🚫 - renders "method", no link
Link to a method of a class in another module MyClass.method
Link to a method of a class in the same module, with description MyClass.method|my descr 🚫 - renders "descr", no link 🚫
Link to a method of a class in another same module, with description MyClass.method|my descr 🚫

Would you say it's fair to conclude that using @apiLink is preferable over @link? Or am I missing something?

Also, would you expect {@apiLink MyClass} to work when used in Docusaurus docs? Or should a regular markdown link be used instead?

Thanks!

jan-molak avatar Aug 11 '22 11:08 jan-molak

@jan-molak Both @link and @apilink use the exact same code: https://github.com/milesj/docusaurus-plugin-typedoc-api/blob/master/packages/plugin/src/utils/markdown.ts#L41 So unless TypeDoc is transforming the comments in someway, I'm surprised they're not consistent.

With that said, TypeDoc resolves entities in a much different way than this plugin does, as they have full context into the parsed data, while this plugin only has access to the raw JSON files. Because of this, we added @apilink to differentiate.

milesj avatar Aug 11 '22 16:08 milesj

Both @link and @apilink use the exact same code:

Yeah, I noticed that. This makes me think that since TypeDoc also supports @link, perhaps it "gets to it first"? 🤔

I think that once #67 is released I'll just standardise on using @apilink

jan-molak avatar Aug 11 '22 16:08 jan-molak

I believe typedoc produces different shape for @link, i was opening another (now resolved) issue about that. Iirc they are different in the json def.

B4nan avatar Aug 11 '22 18:08 B4nan