Emit more valid HTML from rustdoc#93576
Merged
bors merged 1 commit intorust-lang:masterfrom Feb 5, 2022
Merged
Conversation
Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `<summary>` tags can't contain `<div>`s. That's easily fixed by changing out the `<div>`s for `<span>`s with `display: block`. However, there's also a rule that `<span>`s can't contain heading elements. `<span>` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `<h3>` (and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements We have a wrapping `<div>` that goes around each `<h3>`/`<h4>`, etc. We turn that into a `<section>` rather than a `<span>` because `<section>` permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section After this change we get only three warnings from tidy, run on struct.String.html: line 6 column 10790 - Warning: trimming empty <span> line 1 column 1118 - Warning: <link> proprietary attribute "disabled" line 1 column 1193 - Warning: <link> proprietary attribute "disabled" The empty `<span>` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `<link>` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute.
Contributor
|
Some changes occurred in HTML/CSS/JS. |
Member
|
Thanks! @bors: r+ |
Collaborator
|
📌 Commit 32f6260 has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 5, 2022
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#90132 (Stabilize `-Z instrument-coverage` as `-C instrument-coverage`) - rust-lang#91589 (impl `Arc::unwrap_or_clone`) - rust-lang#93495 (kmc-solid: Fix off-by-one error in `SystemTime::now`) - rust-lang#93576 (Emit more valid HTML from rustdoc) - rust-lang#93608 (Clean up `find_library_crate`) - rust-lang#93612 (doc: use U+2212 for minus sign in integer MIN/MAX text) - rust-lang#93615 (Fix `isize` optimization in `StableHasher` for big-endian architectures) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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.
Previously, tidy-html5 (
tidy) would complain about a few things in our HTML. The main thing is that<summary>tags can't contain<div>s. That's easily fixed by changing out the<div>s for<span>s withdisplay: block.However, there's also a rule that
<span>s can't contain heading elements.<span>permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and<h3>(and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_ElementsWe have a wrapping
<div>that goes around each<h3>/<h4>, etc. We turn that into a<section>rather than a<span>because<section>permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sectionAfter this change we get only three warnings from tidy, run on struct.String.html:
line 6 column 10790 - Warning: trimming empty
line 1 column 1118 - Warning: proprietary attribute "disabled"
line 1 column 1193 - Warning: proprietary attribute "disabled"
The empty
<span>is a known issue - there's a span in front of the search box to work around a strange Safari issue.The
<link>attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute.We can suppress those warnings with flags to tidy, and get a run that returns 0 (success):
Note: this requires the latest version of tidy-html5, built from https://github.com/htacg/tidy-html5. Older versions (including the default version on Ubuntu 21.10) think
<section>can't occur inside<summary>.Demo: https://rustdoc.crud.net/jsha/fix-rustdoc-html/std/string/struct.String.html
r? @GuillaumeGomez