lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.52k stars 748 forks source link

[docs] Dynamically generate TOC #1419

Closed imphil closed 4 years ago

imphil commented 4 years ago

The page https://docs.opentitan.org/ has a TOC-like structure in it, as does https://docs.opentitan.org/doc/ug/. But the contents are manually edited and don't reflect all subsections.

Can we auto-generate this content to keep it up-to-date and ensure that all content is actually linked?

sjgitty commented 4 years ago

For this one we should consider whether a true TOC is what we want. It is possibly going to look good but sometimes TOCs look ungainly. Below is what it would look like if we were to render all of the document titles as the TOC entries. Clearly it is very deep (I'm sure we could employ some .skip directives), but also the algorithm to generate this was not obvious (I had to kluge it several times), so not sure what algorithm we would want to use (perhaps there are standard Hugo things we could use here). It also shows that we need to clean up a lot of our document titles which are not self-explanatory. Thoughts?

imphil commented 4 years ago

It's not uncommon to restrict the TOC to certain levels of depth, e.g. 2. That should keep things interesting for the reader.

sjgitty commented 4 years ago

It's not uncommon to restrict the TOC to certain levels of depth, e.g. 2. That should keep things interesting for the reader.

Agreed except much of our interest stuff is buried deep beyond level 2, and some of the level 1 and level 2 stuff is just filler. I guess the compromise is that we force some catch-all documents of said "interesting stuff" at level 2 so that it is found in the TOC, the same way hw/_index.md has a map of all of the hardware specifications.

sjgitty commented 4 years ago

Perhaps the to-do part of this issue is to create what the TOC-level-2 would look like and suggest changes to our current organization where interesting content would otherwise get lost.

towoe commented 4 years ago

Do we still want this? With the "menu" now available on docs.opentitan.org I think it is better to have some hand crafted text guiding to reader to the important parts (if it would be the only content). But I can still try to get some automatically level 2 generated list which can then be added to the end for selected pages.

imphil commented 4 years ago

I'd either still go for it, or significantly reword it to not look like a TOC any more, but a summary of what's coming (as in https://opensocdebug.readthedocs.io/en/latest/). If it looks like a TOC, it should actually be one and not go out of date repeatedly.

towoe commented 4 years ago

Yes, we should not have a TOC which is not up-to-date. Either none at all or auto generated. The summary approach is also nice, should be possible with Hugo if the front matter of the documentation contains the description. I will provide a PR with a suggestion for the automatic one and then we can decide which direction we will pursue.