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

Inconsistent behaviour of @link, @apiLink and [[...]] #66

Open
jan-molak opened this issue Aug 11, 2022 · 3 comments
Open

Inconsistent behaviour of @link, @apiLink and [[...]] #66

jan-molak opened this issue Aug 11, 2022 · 3 comments

Comments

@jan-molak
Copy link
Contributor

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!

@milesj
Copy link
Owner

milesj commented Aug 11, 2022

@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.

@jan-molak
Copy link
Contributor Author

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

@B4nan
Copy link
Contributor

B4nan commented Aug 11, 2022

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.

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

3 participants