Conversation
The HTML section extractor had two failure modes when used against rustdoc-generated pages (docs.rs or local `cargo doc` output). First, the section listing was polluted with page-chrome IDs (`rustdoc_body_wrapper`, `rustdoc-toc`, `rustdoc-modnav`, `main-content`). These were picked up by the ancestor-id fallback in `resolve_heading_id` because rustdoc wraps the whole page in elements carrying those IDs. A new `RUSTDOC_SCAFFOLDING_IDS` filter drops them from the listing while still allowing explicit `sections=[...]` requests to target `main-content` on non-rustdoc pages. Second, method and variant documentation was never returned. Rustdoc places the signature heading inside `<section id="method.X">` and puts the prose in a sibling `<div class="docblock">` outside the section — optionally further wrapped in a `<details>` toggle. The extractor was walking the section's own children, finding nothing, and returning an empty string. Two new helpers, `extract_rustdoc_section` and `preview_from_section_docblock`, resolve the sibling docblock in both the flat and toggle layouts. `extract_section_html_from_doc` now short-circuits into this path for any `<section>` target, and the preview walk gains a matching fallback so listing previews agree with extracted bodies. Signed-off-by: Jean Mertz <git@jeanmertz.com>
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.
The HTML section extractor had two failure modes when used against rustdoc-generated pages (docs.rs or local
cargo docoutput).First, the section listing was polluted with page-chrome IDs (
rustdoc_body_wrapper,rustdoc-toc,rustdoc-modnav,main-content). These were picked up by the ancestor-id fallback inresolve_heading_idbecause rustdoc wraps the whole page in elements carrying those IDs. A newRUSTDOC_SCAFFOLDING_IDSfilter drops them from the listing while still allowing explicitsections=[...]requests to targetmain-contenton non-rustdoc pages.Second, method and variant documentation was never returned. Rustdoc places the signature heading inside
<section id="method.X">and puts the prose in a sibling<div class="docblock">outside the section — optionally further wrapped in a<details>toggle. The extractor was walking the section's own children, finding nothing, and returning an empty string. Two new helpers,extract_rustdoc_sectionandpreview_from_section_docblock, resolve the sibling docblock in both the flat and toggle layouts.extract_section_html_from_docnow short-circuits into this path for any<section>target, and the preview walk gains a matching fallback so listing previews agree with extracted bodies.