Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc generates illegal <h3> in <span> for struct-like enums #64146

Closed
kentfredric opened this issue Sep 4, 2019 · 1 comment · Fixed by #64175
Closed

rustdoc generates illegal <h3> in <span> for struct-like enums #64146

kentfredric opened this issue Sep 4, 2019 · 1 comment · Fixed by #64175
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@kentfredric
Copy link

See also #7529, #60403 and #60865

When using a struct-like enum, rustdoc generates the following code for the enums fields:

(hand formatted)

<span class='autohide sub-variant' id='variant.ParseU64Error.fields'>
  <h3>Fields of <b>ParseU64Error</b></h3>
  <div>
    <span id="variant.ParseU64Error.field.input_value" class="variant small-section-header"><a href="#variant.ParseU64Error.field.input_value" class="anchor field"></a><code id='ParseU64Error.v.input_value.v'>input_value:&nbsp;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code></span>
    <div class='docblock'><p>The string that was attempted to be parsed</p></div>
    <span id="variant.ParseU64Error.field.input_line" class="variant small-section-header"><a href="#variant.ParseU64Error.field.input_line" class="anchor field"></a><code id='ParseU64Error.v.input_line.v'>input_line:&nbsp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span>
    <div class='docblock'><p>The line of the file that was trying to be decoded</p></div>
    <span id="variant.ParseU64Error.field.input_file" class="variant small-section-header"><a href="#variant.ParseU64Error.field.input_file" class="anchor field"></a><code id='ParseU64Error.v.input_file.v'>input_file:&nbsp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a></code></span>
    <div class='docblock'><p>The file that was being read</p></div>
  </div>
</span>

htmltidy hates this.

line 18 column 7 - Warning: missing </span> before <h3>
line 18 column 80 - Warning: inserting implicit <span>
line 18 column 120 - Warning: inserting implicit <span>
line 18 column 120 - Warning: missing </span> before <div>
line 21 column 13 - Warning: discarding unexpected </span>
line 1 column 3935 - Warning: <a> attribute "href" lacks value

Spans may only contain Phrasing Content but h1 et. al is only "Heading Content".

So what htmltidy ends up doing is closing the first <span> before the <h3>, and this breaks the layout substantially :)

@kentfredric
Copy link
Author

kentfredric commented Sep 4, 2019

( Those <div>'s inside the <span> are probably also illegal )

line 18 column 120 - Warning: missing </span> before <div>

@Centril Centril added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Sep 5, 2019
Centril added a commit to Centril/rust that referenced this issue Sep 5, 2019
…-should-be-div, r=Mark-Simulacrum

Fix invalid span generation when it should be div

Fixes rust-lang#64146.

It changes basically nothing in the display... Can be checked with:

```rust
pub enum X {
    /// Some doc?
    ///
    /// with lines!
    Foo {
        /// a
        ///
        /// b
        x: u32,
        /// Doc!
        ///
        /// ```
        /// yolo
        /// ```
        y: String,
    },
    /// Doc!
    ///
    /// ```
    /// yolo
    /// ```
    Bar(String),
}
```

r? @Mark-Simulacrum
Centril added a commit to Centril/rust that referenced this issue Sep 5, 2019
…-should-be-div, r=Mark-Simulacrum

Fix invalid span generation when it should be div

Fixes rust-lang#64146.

It changes basically nothing in the display... Can be checked with:

```rust
pub enum X {
    /// Some doc?
    ///
    /// with lines!
    Foo {
        /// a
        ///
        /// b
        x: u32,
        /// Doc!
        ///
        /// ```
        /// yolo
        /// ```
        y: String,
    },
    /// Doc!
    ///
    /// ```
    /// yolo
    /// ```
    Bar(String),
}
```

r? @Mark-Simulacrum
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Sep 6, 2019
…-should-be-div, r=Mark-Simulacrum

Fix invalid span generation when it should be div

Fixes rust-lang#64146.

It changes basically nothing in the display... Can be checked with:

```rust
pub enum X {
    /// Some doc?
    ///
    /// with lines!
    Foo {
        /// a
        ///
        /// b
        x: u32,
        /// Doc!
        ///
        /// ```
        /// yolo
        /// ```
        y: String,
    },
    /// Doc!
    ///
    /// ```
    /// yolo
    /// ```
    Bar(String),
}
```

r? @Mark-Simulacrum
@bors bors closed this as completed in 2cb02ad Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants