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

Properly display generics in Markdown #239

Closed
yiliansource opened this issue Jun 23, 2021 · 8 comments
Closed

Properly display generics in Markdown #239

yiliansource opened this issue Jun 23, 2021 · 8 comments

Comments

@yiliansource
Copy link

I'm so sorry for having so many issues with generics in TypeDoc. 😅

The Markdown renderer seems to have issues properly representing and linking generic types inside the rendered result. At the moment, the class Spline<Color> will be rendered as Spline<Color>. Sadly, it does not seem possible to provide links inside of code snippets, so Spline<[Color](...)> would not work. The only solution I'd see at the moment for generics is to provide HTML code directly with something along

<code>Spline&lt;<a href="">Color</a>&gt;</code>

which renders as Spline<Color>.

Is this something that can feasibly be fixed, or might this even be intended/unfixable behaviour?

@tgreyuk
Copy link
Member

tgreyuk commented Jun 23, 2021

Just to clarify that this use-case is for manually adding references inside doc comments?

@yiliansource
Copy link
Author

Sorry, should have properly clarified and not rushed before work.

The use case is that generic types don't seem to be properly rendered. I don't believe this is related to doc comments. I'll add example code and the current result:


/**
 * Represents a spline that can take numeric values.
 */
export class NumericSpline extends Spline<number> {
    // ...
}

Class: NumericSpline

components.NumericSpline

Represents a spline that can take numeric values.

Hierarchy

  • Spline<number>

    NumericSpline


As you can see, in the hierarchy section, the full name of the variable is not wrapped in the <code> tags, causing the "generic" brackets to feel out of place.

I'm happy to elaborate more, if needed.

@tgreyuk
Copy link
Member

tgreyuk commented Jun 23, 2021

Ah sorry - ok i see what you are saying. I will have a proper look at this and report back.

@yiliansource
Copy link
Author

I'd be glad to take a peek aswell if you like, I'd be happy to contribute - I just don't really know how the codebase works at the moment. If you'd rather someone else bothers with this, feel free to give me a hint in the right direction!

@tgreyuk
Copy link
Member

tgreyuk commented Jun 23, 2021

Like you suggest this has been implemented like this as its not possible to nest links inside backticks in markdown and trying to avoid html in the output.

What do you think about adding each symbol in a backtick rather than the entire string? It means the symbols are consistent although maybe the angle brackets look out of place?

- [`Spline`](spline.md)<`number`, [`Color`](../color.md)\>

Screenshot 2021-06-23 at 13 36 43

Any other suggestions welcome?

I'd be glad to take a peek aswell if you like, I'd be happy to contribute

I am happy to pick this up, but yes contributions very welcome. Actually been planning on writing a contributing page but currently in the middle of refactoring to remove handlebars so got a bit sidetracked.

@yiliansource
Copy link
Author

Encapsulating each symbol in backticks is definitely an improvement - but depending on the CSS used to style the rendered Markdown, the angle brackets may look pretty out of place. I get how one would want to avoid HTML in the output though. I'd say before making that kind of concession most people would take the slightly out-of-place brackets and commas any day.

I am happy to pick this up, but yes contributions very welcome. Actually been planning on writing a contributing page but currently in the middle of refactoring to remove handlebars so got a bit sidetracked.

I'll leave you to do the magic then! Am definitely excited for the contributing page though, but obviously don't rush yourself.

@tgreyuk
Copy link
Member

tgreyuk commented Jun 23, 2021

ok have implemented in typedoc-plugin-markdown@3.10.1. Thanks I think it's an improvement. Let me know if you spot anything.

@yiliansource
Copy link
Author

Perfect, looks good to me! Thanks for the quick fix!

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