From 32f62607c3142dfc9eb56a0bd72dee298ca43358 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Tue, 1 Feb 2022 22:11:36 -0800 Subject: Emit valid HTML from rustdoc Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `` tags can't contain `
`s. That's easily fixed by changing out the `
`s for ``s with `display: block`. However, there's also a rule that ``s can't contain heading elements. `` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `

` (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 `
` that goes around each `

`/`

`, etc. We turn that into a `
` rather than a `` because `
` 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 line 1 column 1118 - Warning: proprietary attribute "disabled" line 1 column 1193 - Warning: proprietary attribute "disabled" The empty `` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute. --- src/test/rustdoc/const-generics/add-impl.rs | 2 +- src/test/rustdoc/const-generics/const-generic-slice.rs | 4 ++-- src/test/rustdoc/const-generics/const-generics-docs.rs | 4 ++-- src/test/rustdoc/const-generics/const-impl.rs | 12 +++++------- 4 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/test/rustdoc/const-generics') diff --git a/src/test/rustdoc/const-generics/add-impl.rs b/src/test/rustdoc/const-generics/add-impl.rs index 7e38eb8369a..e54f9a57ae4 100644 --- a/src/test/rustdoc/const-generics/add-impl.rs +++ b/src/test/rustdoc/const-generics/add-impl.rs @@ -7,7 +7,7 @@ pub struct Simd { inner: T, } -// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//div/h3[@class="code-header in-band"]' 'impl Add> for Simd' +// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl Add> for Simd' impl Add for Simd { type Output = Self; diff --git a/src/test/rustdoc/const-generics/const-generic-slice.rs b/src/test/rustdoc/const-generics/const-generic-slice.rs index b20663c6d68..4279de91f56 100644 --- a/src/test/rustdoc/const-generics/const-generic-slice.rs +++ b/src/test/rustdoc/const-generics/const-generic-slice.rs @@ -5,7 +5,7 @@ pub trait Array { } // @has foo/trait.Array.html -// @has - '//div[@class="impl has-srclink"]' 'impl Array for [T; N]' -impl Array for [T; N] { +// @has - '//*[@class="impl has-srclink"]' 'impl Array for [T; N]' +impl Array for [T; N] { type Item = T; } diff --git a/src/test/rustdoc/const-generics/const-generics-docs.rs b/src/test/rustdoc/const-generics/const-generics-docs.rs index 92d2c4697e7..fc3a2731089 100644 --- a/src/test/rustdoc/const-generics/const-generics-docs.rs +++ b/src/test/rustdoc/const-generics/const-generics-docs.rs @@ -36,7 +36,7 @@ pub struct Foo where u8: Trait; // @has foo/struct.Bar.html '//pre[@class="rust struct"]' 'pub struct Bar(_)' pub struct Bar([T; N]); -// @has foo/struct.Foo.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Foo where u8: Trait' +// @has foo/struct.Foo.html '//*[@id="impl"]/h3[@class="code-header in-band"]' 'impl Foo where u8: Trait' impl Foo where u8: Trait { // @has - '//*[@id="associatedconstant.FOO_ASSOC"]' 'pub const FOO_ASSOC: usize' pub const FOO_ASSOC: usize = M + 13; @@ -47,7 +47,7 @@ impl Foo where u8: Trait { } } -// @has foo/struct.Bar.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Bar' +// @has foo/struct.Bar.html '//*[@id="impl"]/h3[@class="code-header in-band"]' 'impl Bar' impl Bar { // @has - '//*[@id="method.hey"]' \ // 'pub fn hey(&self) -> Foo where u8: Trait' diff --git a/src/test/rustdoc/const-generics/const-impl.rs b/src/test/rustdoc/const-generics/const-impl.rs index cda900773ab..a3ef084165a 100644 --- a/src/test/rustdoc/const-generics/const-impl.rs +++ b/src/test/rustdoc/const-generics/const-impl.rs @@ -1,7 +1,5 @@ #![allow(incomplete_features)] - #![feature(adt_const_params)] - #![crate_name = "foo"] #[derive(PartialEq, Eq)] @@ -11,20 +9,20 @@ pub enum Order { } // @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet' -// @has foo/struct.VSet.html '//div[@id="impl-Send"]/h3[@class="code-header in-band"]' 'impl Send for VSet' -// @has foo/struct.VSet.html '//div[@id="impl-Sync"]/h3[@class="code-header in-band"]' 'impl Sync for VSet' +// @has foo/struct.VSet.html '//*[@id="impl-Send"]/h3[@class="code-header in-band"]' 'impl Send for VSet' +// @has foo/struct.VSet.html '//*[@id="impl-Sync"]/h3[@class="code-header in-band"]' 'impl Sync for VSet' pub struct VSet { inner: Vec, } -// @has foo/struct.VSet.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl VSet' +// @has foo/struct.VSet.html '//*[@id="impl"]/h3[@class="code-header in-band"]' 'impl VSet' impl VSet { pub fn new() -> Self { Self { inner: Vec::new() } } } -// @has foo/struct.VSet.html '//div[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl VSet' +// @has foo/struct.VSet.html '//*[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl VSet' impl VSet { pub fn new() -> Self { Self { inner: Vec::new() } @@ -33,7 +31,7 @@ impl VSet { pub struct Escape; -// @has foo/struct.Escape.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escapealert("Escape");"#>' +// @has foo/struct.Escape.html '//*[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escapealert("Escape");"#>' impl Escapealert("Escape");"#> { pub fn f() {} } -- cgit 1.4.1-3-g733a5