Skip to content

Add per page TOC in the rustc book #140113

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 3 commits into from
May 18, 2025
Merged

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Apr 21, 2025

This PR adds per page Table of Content (TOC) in the rustc book (to be extended in the future to our other books).

The goal is to easy the navigation inside the page by providing quick overview of the page content and our position inside that page.

That functionality is unfortunately not available natively in mdbook, which prompted community members to create mdBook-pagetoc (which this PR is heavily inspired by). It's "only" a JS file (to handle the TOC) and a CSS file (to handle the margin, colors, screen size, ...), there is no "post-processor" needed (in mdbook sense).

image

Live preview at: http://urgau.rf.gd/book

r? @jieyouxu

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2025
@Urgau Urgau force-pushed the rustc-book-page-toc branch from 988a34a to b266992 Compare April 21, 2025 12:53
@jieyouxu
Copy link
Member

cc @ehuss

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Apr 21, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

I did play with the prototype quite a bit, and the per-page TOC looks very nice there to me (I tried various screen sizes and all the themes). I'll hand this review over to Eric who might have more clues about the book itself.

@jieyouxu
Copy link
Member

r? @ehuss (in case you have any concerns about the extra js/css of the book itself)

@rustbot rustbot assigned ehuss and unassigned jieyouxu Apr 22, 2025
@wesleywiser wesleywiser added the A-licensing Area: Compiler licensing label Apr 24, 2025
@wesleywiser wesleywiser self-assigned this Apr 24, 2025
@Urgau Urgau force-pushed the rustc-book-page-toc branch from 6df24a0 to 4cbcb44 Compare May 16, 2025 09:09
Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

lgtm unless @ehuss has concerns

@ehuss
Copy link
Contributor

ehuss commented May 17, 2025

Thanks! A minor thing I noticed is that the colors don't work very well with the Rust theme, but that is not a blocker.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 17, 2025

📌 Commit 4cbcb44 has been approved by ehuss

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 17, 2025
fmease added a commit to fmease/rust that referenced this pull request May 18, 2025
Add per page TOC in the `rustc` book

This PR adds per page Table of Content (TOC) in the `rustc` book (to be extended in the future to our other books).

The goal is to easy the navigation inside the page by providing quick overview of the page content and our position inside that page.

That functionality is unfortunately not available natively in `mdbook`, which prompted community members to create [mdBook-pagetoc](https://github.com/JorelAli/mdBook-pagetoc/) (which this PR is heavily inspired by). It's "only" a JS file (to handle the TOC) and a CSS file (to handle the margin, colors, screen size, ...), there is no "post-processor" needed (in mdbook sense).

![image](https://github.com/user-attachments/assets/9e790bea-059d-414e-b4a5-ac8170f57e27)

Live preview at: http://urgau.rf.gd/book

r? `@jieyouxu`
fmease added a commit to fmease/rust that referenced this pull request May 18, 2025
Add per page TOC in the `rustc` book

This PR adds per page Table of Content (TOC) in the `rustc` book (to be extended in the future to our other books).

The goal is to easy the navigation inside the page by providing quick overview of the page content and our position inside that page.

That functionality is unfortunately not available natively in `mdbook`, which prompted community members to create [mdBook-pagetoc](https://github.com/JorelAli/mdBook-pagetoc/) (which this PR is heavily inspired by). It's "only" a JS file (to handle the TOC) and a CSS file (to handle the margin, colors, screen size, ...), there is no "post-processor" needed (in mdbook sense).

![image](https://github.com/user-attachments/assets/9e790bea-059d-414e-b4a5-ac8170f57e27)

Live preview at: http://urgau.rf.gd/book

r? ``@jieyouxu``
bors added a commit to rust-lang-ci/rust that referenced this pull request May 18, 2025
Rollup of 7 pull requests

Successful merges:

 - rust-lang#140113 (Add per page TOC in the `rustc` book)
 - rust-lang#140490 (split `asm!` parsing and validation)
 - rust-lang#140924 (Make some `f32`/`f64` tests also run in const-context)
 - rust-lang#141045 ([win][arm64] Remove 'Arm64 Hazard' undocumented MSVC option and instead disable problematic test)
 - rust-lang#141071 (Enable [behind-upstream] triagebot option for rust-lang/rust)
 - rust-lang#141132 (Use `crate::` prefix for root macro suggestions)
 - rust-lang#141139 (Fix Rust for Linux ping group label)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 18, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang#140113 (Add per page TOC in the `rustc` book)
 - rust-lang#140511 (Stabilize `#![feature(non_null_from_ref)]`)
 - rust-lang#140924 (Make some `f32`/`f64` tests also run in const-context)
 - rust-lang#140966 (Remove #![feature(let_chains)] from library and src/librustdoc)
 - rust-lang#141045 ([win][arm64] Remove 'Arm64 Hazard' undocumented MSVC option and instead disable problematic test)
 - rust-lang#141071 (Enable [behind-upstream] triagebot option for rust-lang/rust)
 - rust-lang#141132 (Use `crate::` prefix for root macro suggestions)
 - rust-lang#141139 (Fix Rust for Linux ping group label)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5592f41 into rust-lang:master May 18, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 18, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 18, 2025
Rollup merge of rust-lang#140113 - Urgau:rustc-book-page-toc, r=ehuss

Add per page TOC in the `rustc` book

This PR adds per page Table of Content (TOC) in the `rustc` book (to be extended in the future to our other books).

The goal is to easy the navigation inside the page by providing quick overview of the page content and our position inside that page.

That functionality is unfortunately not available natively in `mdbook`, which prompted community members to create [mdBook-pagetoc](https://github.com/JorelAli/mdBook-pagetoc/) (which this PR is heavily inspired by). It's "only" a JS file (to handle the TOC) and a CSS file (to handle the margin, colors, screen size, ...), there is no "post-processor" needed (in mdbook sense).

![image](https://github.com/user-attachments/assets/9e790bea-059d-414e-b4a5-ac8170f57e27)

Live preview at: http://urgau.rf.gd/book

r? ```@jieyouxu```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-licensing Area: Compiler licensing S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants