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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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
@@ -0,0 +1,104 @@
/* Inspired by https://github.com/JorelAli/mdBook-pagetoc/ */
Copy link
Member Author

Choose a reason for hiding this comment

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

@davidtwco @wesleywiser, legal question here, pagetoc.css and pagetoc.js are both heavily inspired by https://github.com/JorelAli/mdBook-pagetoc/ which is licensed under the "WTFPL" license (Do What The F*ck You Want To Public License).

Is it okay for us to re-license those files under our dual license MIT/Apache-2?

Copy link
Member

Choose a reason for hiding this comment

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

I will start a thread with the Foundation to see what they think.

@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
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-review Status: Awaiting review from the assignee but also interested parties. 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.

5 participants