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

support controlling when a table content is generated #744

Closed
techfg opened this issue Dec 21, 2024 · 3 comments
Closed

support controlling when a table content is generated #744

techfg opened this issue Dec 21, 2024 · 3 comments

Comments

@techfg
Copy link

techfg commented Dec 21, 2024

What package is the feature request related to?

typedoc-plugin-markdown

Background

Currently, typedoc-plugin-remark requires that at least two ## headings exist on the page in order for a Contents section to be added where remark-toc will add the table of contents.

In some cases, a type/interface may have lots of properties but only one (1) ## heading. It would be helpful to have a TOC in this case but its not currently possible.

In the repro, only one (1) ## heading exists so there is no TOC for the interface.

Repro: https://stackblitz.com/edit/vitejs-vite-ifb3xfoh?file=src%2Findex.ts

npm run docs

image

Proposed solution

Would like to see an option added to control the "min" number of headings that must exist:

  • undefined = 2 or more (current behavior)
  • false = never add
  • true = always add
  • number = number of ## greater than equal to number (note that a value of 0 is the same as true)

Or more simply, could just be number with a default value of 2 to maintain current behavior. Also, not sure a never is really needed since it also checks for remark-toc and if it is there, can't think of a reason why Content heading shouldn't generate if number is met.

Happy to work on a PR for this if there is an appetite for it.

@tgreyuk
Copy link
Member

tgreyuk commented Dec 22, 2024

@techfg thanks

For reasons describe in #743 the min number of headings count in itself might not be the way to go. Or perhaps introduce when there is at least one h2 heading other than a "Defined In" h2 I am not too sure (there is more context in the linked issue).

One thing this has brought to light is the for interfaces there is no "Defined In" h2, whereby there is for type aliases, functions etc which is not consistent. I think this is actually another bug as there should be an overall source link for the interface itself - would you agree?

@techfg
Copy link
Author

techfg commented Dec 23, 2024

Thanks @tgreyuk!

Regarding the Defined in h2, I noticed that as well, just didn't have time to log an issue for it yet. Just created #746 so there's something official tracking it.

Regarding heading counts, etc. since this issue and #743 are kind of blending together and are closely related to begin with, might be easier to keep the convo in one-place so I'll add my further thoughts there.

@tgreyuk
Copy link
Member

tgreyuk commented Dec 23, 2024

Closing in favour of #743 as they the issues are now essentially duplicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants