Skip to content

Rename no-section-label to section-label-toc#3091

Open
ChrisJr404 wants to merge 3 commits intorust-lang:masterfrom
ChrisJr404:feat/rename-section-label-toc-2761
Open

Rename no-section-label to section-label-toc#3091
ChrisJr404 wants to merge 3 commits intorust-lang:masterfrom
ChrisJr404:feat/rename-section-label-toc-2761

Conversation

@ChrisJr404
Copy link
Copy Markdown

Closes #2761.

The no-section-label HTML config key was a negative flag whose default was false, which made the meaning awkward (double negative). This renames it to section-label-toc with a default of true, preserving the existing behavior of showing numeric section labels in the table of contents.

The -toc suffix anticipates a possible future section-label-title companion flag for #2760.

Per @ehuss in #2761, this is a clean rename for 0.5 with no deprecation warning. The existing HtmlConfig::Default impl is updated to set section_label_toc: true. With deny_unknown_fields already on HtmlConfig, books that still set no-section-label will fail to deserialize with a message that lists section-label-toc among the expected fields, so the migration path is discoverable.

Changes

  • crates/mdbook-core/src/config.rs: rename the HtmlConfig field and flip the default to true.
  • crates/mdbook-html/src/html_handlebars/helpers/toc.rs: rename RenderToc::no_section_label to section_label_toc and invert the gate.
  • crates/mdbook-html/src/html_handlebars/hbs_renderer.rs: pass through the renamed field.
  • guide/src/format/configuration/renderers.md: update the example and the docs entry.

Verification

Built a small book locally with section-label-toc = false, section-label-toc = true, and the key omitted; confirmed that aria-hidden section-number spans appear only when the flag is true (or absent, since default is true), and disappear when set to false. With the old key, the build now fails with unknown field 'no-section-label', expected one of ...section-label-toc....

cargo build, cargo clippy --workspace --all-targets, cargo fmt --check, and cargo test --workspace all pass.

Closes rust-lang#2761.

The previous `no-section-label` config key was a negative flag whose
default was `false`, which made the meaning awkward to reason about
(double negative). Rename it to `section-label-toc` with a default of
`true`, preserving the existing behavior of showing numeric section
labels in the table of contents.

The `-toc` suffix anticipates a possible future `section-label-title`
flag for rust-lang#2760.

Per @ehuss in rust-lang#2761, this is a clean rename for 0.5 with no
deprecation shim. The existing `HtmlConfig::Default` impl is updated
to set the new field to `true`. With `deny_unknown_fields`, books
that still set `no-section-label` will fail the deserialize with a
message that lists `section-label-toc` among the expected fields.
@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label May 6, 2026
ChrisJr404 added 2 commits May 7, 2026 07:38
cargo-semver-checks correctly flags removing the no_section_label
field as a major-version-required change. Bump mdbook-core (and the
workspace dep pin) to 0.6.0 so the rename is properly versioned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename no-section-label to be a positive flag e.g. section-label-toc

2 participants