-
Notifications
You must be signed in to change notification settings - Fork 182
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
Verify expected Table of Contents (toc) implementation and behaviour #743
Comments
Options
vernak2539/astro-rehype-relative-markdown-links#72
@techfg thanks.
The initial intention was to add the toc heading as equivalent to where the html theme adds the "Index" section. The html theme only adds Index sections to Classes, Interfaces and Enums, I suppose with the rationale that these symbols always contain groups of Properties, Methods etc. However your use case does illustrate how it would also be useful for Type Aliases when there is a properties list. However a toc might not always be desirable. We could potentially end up with undesirable headings for simple Types: I am not entirely sure what the best solution to this is? It might be as simple as adding the toc heading when there is at least one other than the "Defined In" heading?
Would be very happy to have some more active contributors. I appreciate that the code is probably not that intuitive or well documented. I have actually created a new branch for this bit of work named feature/remark-toc. If you were to look into it I would branch off that. This contains a few tweaks:
|
Thanks @tgreyuk! You've made me re-think the original intent of this issue and (probably) change my perspective lol Firstly, I was always thinking of the The other thing that you made me realize, after doing some more testing, is that the html version does not have an In short, I think the first thing to decide for this plugin is if the intent is to replace the The other thing to note is the Ok, getting lengthy here so I'll wrap up for now 😄 Beyond the above comments:
FWIW, my recommendation:
Happy to contribute to the PR you started once you have a chance to think through all this and let me know which direction you ultimately want to go. Thank you again! Edit: Submitted TypeStrong/typedoc#2817 to add support for toc & index in default html theme for type alias when it has properties. |
@techfg thanks
Agree on points 1,2,3 here.
I notice that group descriptions are missing from module index pages - i will add that. (this is not an inline toc so a slightly different use-case). A) For inline "indexes" or inline tocs i notice that html theme adds the group description only to the index and not with the group content. I am not sure that this pattern is better, or at least not compatible with the markdown theme where many users reply on auto generated toc sidebars for inline linking. B)
Previous versions of the plugin did actually provide the inline toc, but it seemed most people switched it off in favour of auto sidebars generated from content headings as per users markdown environment. It was also quite challenging to manage manually with additional context required of if things if items are rendered within tables etc. The other benefit it that the toc includes any tagged content headings created by document comments such as
Potentially not - this is actually something that has been grappled with in the past. The rationale is that headings provide a better semantic hierarchy to the pages. For example what I don't quite like about this example is that the "Defined In" text is grouped within the "Type declaration" heading: Having it as a separate heading provides a better integrity of heading heirarchy: Another example here from the html theme is that "Returns" and "Defined in" are both placed under the "Parameters" heading where they are actually distinctive content elements in their own right: Markdown equivalent is probably semantically better: Anyway that is the rationale, could potentially move defined in up to the top of the symbol like html theme does for interfaces (it is not completely consistent the where think link is placed in html theme either). Edit: Having reviewed this I think we can definitely make work as inline text by moving the position of the link (see linked issue).
I'll add what have done so far (basically remove heading restrictions) but keep other logic and monitor the response from TypeDoc on the linked issue. |
Yeah, I noticed this as well. I actually prefer the way markdown does this over what html does, putting the descriptions within the "group content" and not the "index" if it's going to be one or the other. There is something to be said for putting in both, but at same time, that might be overkill. I can understand why html does it in the index as it's a quick reference type of concept but I can also see scenarios where people don't look at the index, go straight to the group content and then miss out on the extra contextual information. My $0.02 is markdown maintain its current behavior.
Not sure I 100% follow you here. Understood what markdown used to do (build it itself) vs. what it now does (defer to remark-toc). Are you saying remark-toc would be able to handle things like
Possibly I'm misunderstanding what you're saying but in html they are all siblings
Agreed!!
Didn't see feature/remark-toc updated yet, will take a look once you push. Thanks! |
Apologies, I guess I was just outlining the reason for opting for the remark-toc route (simple toc following page headings) over bespoke solution more in line with html theme. When block tags are used in doc comments they are converted into page headings so the remark plugins adds these to the toc whereas the html theme index will ignore them. But the two approaches are different and the Contents area on markdown theme intention is currently to be a simple heading based opt-in toc.
Ah! I provided an invalid example so stand corrected. Html has the benefit of using block elements to separate the content and in this example the sources block is in an
|
Ah, misunderstood, thought you were going to implement the |
Yes defo still going to do, but the main plugin requires a lot more due diligence around the release process. Can track the progress on that with #746. |
Cool, makes sense! Given the discussion, for anyone that might stumble upon this in the future and try to reverse-engineer all the discussion, here's where I think things have landed:
I think that sums it up unless I'm missing something? EDIT Tested with v1.2.2 of |
typedoc-plugin-remark
& remark-toc
typedoc-plugin-remark
& remark-toc
typedoc-plugin-remark
& remark-toc
@techfg I will leave this one open and have a think about it. On reflection it might be better to move inline toc functionality into the core package rather than rely on |
@techfg having looked at this I think we can cover this with a new option I think the name Currently this will replicate the behaviour of the default html theme and include an inline index section for Classes, Interfaces and Enums. We could expand to variables and types that have type declarations if required though. Do let me know if you have a particular preference of how this should behave. I do think this is more preferable than pulling in remark just for this. (the remark plugin is still very useful but perhaps not for this). |
@tgreyuk - I do think there are some advantages to rolling the index/toc internally vs. deferring to remark, that said, I think the current approach does meet the need of a toc with minimal configuration. The benefit of changing the approach to internal would be ability to provide additional information (e.g., group descriptions, etc.). It would be nice to support the ability to generate for types/variables but given html does not do this (and likely won't for the forseeable future), if supported, it should likely require an additional flag. Possibly I think the first question is whether or not you are thinking |
The current thinking it would mirror the heading structure of html theme without the group description, with the reason being the group descriptions are already included in the main content. |
Ok, assumed that was the case and makes sense, just wanted to be sure. Given that, I think using the |
Yes i think you are right. In which case maybe an option name of |
I think Whatever the name, if you are thinking of supporting types & variables, I think Regarding title, html uses "On This Page" but that seems inappropriate for markdown - I think either "Contents" or "Table of Contents" would be preferrable. With all this said, I guess the question now is why change from remark-toc - the only advantage I'm seeing is the ability to provide a TOC for types/variables, am I missing other advantages beyond that and no longer requiring users to include remark-toc? |
Having talked this through I am no longer sure there is much advantage after all :). If sticking with |
I think the current remark-toc approach has feature parity with html toc and therefore yes, I think this issue can be closed and always revisited if needed. That said, the only additional thing I would add is that adding toc to types/variables could likely be easily supported using the |
ok sounds good. I will probably bounce some ideas over regarding how to handle this via remark-plugin. May aswell keep the discussion going on this issue. |
Sounds good but just to re-emphasize, I think the current approach which does not include types/variables does match html toc and therefore I don't think it's a must have, just a nice to have 😄 |
What package is the bug related to?
typedoc-plugin-markdown
Describe the issue
When configured to use
typedoc-plugin-remark
andremark-toc
, the generated markdown forType Alias
pages do not contain a Table of contents even when they contain at least two##
headings.The reason appears to be that type aliases are not included in the kinds of reflections that are eligible for table of contents.
Not sure if this is a bug and it should be working or if this is by design and Type Aliases are intentionally bypassed. Given a type alias can have lots of properties, having a TOC can be very helpful. If this is intentionally by design, happy to change this to a feature request to allow for config option (or similar) to control the types that toc is automatically added to.
Repro: https://stackblitz.com/edit/vitejs-vite-wc5ogkjb?file=src%2Findex.ts%3AL10
Interface
Type Alias
TypeDoc configuration
Expected behavior
Contents
heading should be generated so thatremark-toc
has somewhere to put it :)Happy to work on a PR for this once its determined the correct direction (if any) to go.
The text was updated successfully, but these errors were encountered: