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: struct fields are spaced too closely #128260

Closed
tgross35 opened this issue Jul 27, 2024 · 3 comments · Fixed by #131394
Closed

Rustdoc: struct fields are spaced too closely #128260

tgross35 opened this issue Jul 27, 2024 · 3 comments · Fixed by #131394
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

Sample at https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html:

image

Headings seem too close to the paragraphs around them, enough so that paragraph breaks stand out more than field breaks.

Testing with .structfield { padding-top: 0.8rem; padding-bottom: 0.2rem; }, I think this makes sections stand out better:

image
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 27, 2024
@tgross35 tgross35 added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 27, 2024
@tgross35
Copy link
Contributor Author

If somebody points me in the right direction then I can do this (unless somebody beats me to it, feel free).

@gurry
Copy link
Contributor

gurry commented Jul 27, 2024

I'm no rustdoc expert but this is the template that seems to be rendering the HTML in question: https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/templates/item_union.html

It might also help to just search for "structfield" under src/librustdoc in the repo.

@tgross35
Copy link
Contributor Author

tgross35 commented Jul 27, 2024

Thanks for taking a look - aiui that is indeed where the HTML comes from, but I was less certain about the CSS.

.section-header > a > code {
seems like a reasonable guess, but I just wanted to double check styles aren't applied in JS or something like that (I assume themes are but maybe not layout?).

@bors bors closed this as completed in 103c716 Oct 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 11, 2024
Rollup merge of rust-lang#131394 - ismailarilik:fix/rustdoc/add-space-between-struct-fields-and-their-descriptions, r=GuillaumeGomez

fix(rustdoc): add space between struct fields and their descriptions

Stolen from rust-lang#128541.
Fixes rust-lang#128260.

<table>
  <thead>
    <tr>
      <th scope="col">Before</th>
      <th scope="col">After</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td scope="row">
        <img
          src="https://github.com/user-attachments/assets/b1d3cb47-77c9-4897-a5d2-2192b11cb8a3"
        />
      </td>
      <td>
        <img
          src="https://github.com/user-attachments/assets/0b104672-d2be-49f4-ac9b-3506526fe2f1"
        />
      </td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th scope="col">Before</th>
      <th scope="col">After</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td scope="row">
        <img
          src="https://github.com/user-attachments/assets/650c3e74-a067-492a-9ba3-557f9214f875"
        />
      </td>
      <td>
        <img
          src="https://github.com/user-attachments/assets/413ef9b0-8fca-4e16-978a-7b88d05299dc"
        />
      </td>
    </tr>
  </tbody>
</table>

Unlike original PR, I didn't add space between field headers; I put it between headers and descriptions. So if there are only headers, the space is not changed. Otherwise, I put a space like the space between paragraphs (.75em) which makes sense for me but feel free to adjust it or ask me to do so.

r? `@GuillaumeGomez`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
3 participants