Rename no-section-label to section-label-toc#3091
Open
ChrisJr404 wants to merge 3 commits intorust-lang:masterfrom
Open
Rename no-section-label to section-label-toc#3091ChrisJr404 wants to merge 3 commits intorust-lang:masterfrom
ChrisJr404 wants to merge 3 commits intorust-lang:masterfrom
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2761.
The
no-section-labelHTML config key was a negative flag whose default wasfalse, which made the meaning awkward (double negative). This renames it tosection-label-tocwith a default oftrue, preserving the existing behavior of showing numeric section labels in the table of contents.The
-tocsuffix anticipates a possible futuresection-label-titlecompanion flag for #2760.Per @ehuss in #2761, this is a clean rename for 0.5 with no deprecation warning. The existing
HtmlConfig::Defaultimpl is updated to setsection_label_toc: true. Withdeny_unknown_fieldsalready onHtmlConfig, books that still setno-section-labelwill fail to deserialize with a message that listssection-label-tocamong the expected fields, so the migration path is discoverable.Changes
crates/mdbook-core/src/config.rs: rename theHtmlConfigfield and flip the default totrue.crates/mdbook-html/src/html_handlebars/helpers/toc.rs: renameRenderToc::no_section_labeltosection_label_tocand 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 thataria-hiddensection-number spans appear only when the flag istrue(or absent, since default istrue), and disappear when set tofalse. With the old key, the build now fails withunknown field 'no-section-label', expected one of ...section-label-toc....cargo build,cargo clippy --workspace --all-targets,cargo fmt --check, andcargo test --workspaceall pass.