Skip to content

Don't include subsections in site-wide table of contents #4065

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

Merged
merged 2 commits into from
Apr 2, 2025

Conversation

mudge
Copy link
Contributor

@mudge mudge commented Apr 1, 2025

GitHub: #4063

To reduce the number of elements included on every single page of the documentation site, no longer include subsections of every section (e.g. terminate at Pico C SDK > Hardware APIs > hardware_adc, rather than also including the subsections of "Detailed Description", "Functions", etc.) as these are available in the right-hand "On this page" TOC shown on wide-enough screens.

Note we're not yet cutting down the amount of markup to render the TOC but starting by cutting out the source data.

This removes the JavaScript logic to render the currently clicked section in bold.

mudge added 2 commits April 1, 2025 15:11
We now use Asciidoc's shorthand for IDs (e.g. `[#some_id_here]`, see
https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#ids-roles-and-options)
but this isn't being picked up by the script that builds nav.json used
to build the site-wide table of contents.

This meant that sections of the Pico SDK had incorrect anchors inferred
from their titles rather than the Asciidoc source where they would of
the form `group_hardware_base`, etc.

Fix this by adding a branch to detect shorthand IDs as well as the
"anchor" syntax of `[[some_id_here]]`.
To reduce the number of elements included on every single page of the
documentation site, no longer include subsections of every section (e.g.
terminate at Pico C SDK > Hardware APIs > hardware_adc, rather than
also including the subsections of "Detailed Description", "Functions",
etc.) as these are available in the right-hand "On this page" TOC shown
on wide-enough screens.

Note we're not yet cutting down the amount of markup to render the TOC
but starting by cutting out the source data.

This removes the JavaScript logic to render the currently clicked
section in bold.
Copy link
Contributor

@clowder clowder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a quick win. Out of curiosity, how many nodes does this trim?

@mudge
Copy link
Contributor Author

mudge commented Apr 2, 2025

Seems like a quick win. Out of curiosity, how many nodes does this trim?

In development, it comes down from 12,878 elements under <div id="toc"> to 3,339.

@mudge mudge merged commit 48b2ac2 into develop Apr 2, 2025
1 check passed
@mudge mudge deleted the reduce-depth-of-toc branch April 2, 2025 08:15
@lurch
Copy link
Contributor

lurch commented Apr 2, 2025

This removes the JavaScript logic to render the currently clicked section in bold.

I was about to reply "That seems like a shame", but then I noticed that the RHS menu does highlight the currently-being-viewed section of the page in bold 👍 E.g.
Screenshot from 2025-04-02 11-12-51

So I just need to train my eyes to look at the RHS menu instead of the LHS menu... 😂

@mudge
Copy link
Contributor Author

mudge commented Apr 2, 2025

I thought it was safe to remove as it is a little misleading: it highlights the anchor on the page you clicked but as soon as you scroll, it is no longer accurate. The "On this page" section doesn't have this problem as it live highlights and expands the page structure as you scroll.

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

Successfully merging this pull request may close these issues.

3 participants