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

Fix : Rustdoc: struct fields are spaced too closely #128541

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

xonx4l
Copy link

@xonx4l xonx4l commented Aug 2, 2024

Closes #128260

Description -:
Implement spacing between struct fields.

@rustbot
Copy link
Collaborator

rustbot commented Aug 2, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @notriddle (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 2, 2024
@notriddle
Copy link
Contributor

Before After
image image

I think the layout should try to take into account whether the field has any docs attached to it, and that there shouldn't be any padding-top.

@notriddle
Copy link
Contributor

Feedback

Here's what it looks like now. I don't think it's enough of an improvement for the case it was intended to help with:

before after
image image
image image

Suggestions

With methods, for example, rustdoc.css has a margin that only shows up if there's documentation, as this screenshot shows:

image

I think it might be a good idea to take inspiration from there.

@xonx4l
Copy link
Author

xonx4l commented Aug 5, 2024

what you think @notriddle ??

@notriddle
Copy link
Contributor

notriddle commented Aug 5, 2024

Please upload screenshots of the two pages (mir::Body and hir::Item) for these changes? It’s easier than having to tweak it myself.

@@ -10,7 +10,7 @@ <h2 id="fields" class="fields section-header"> {# #}
{% for (field, ty) in self.fields_iter() %}
{% let name = field.name.expect("union field name") %}
<span id="structfield.{{ name }}" {#+ #}
class="{{ ItemType::StructField +}} section-header"> {# #}
class="structfield {{ ItemType::StructField +}} section-header"> {# #}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the structfield class is already applied using ItemType::StructField.

Suggested change
class="structfield {{ ItemType::StructField +}} section-header"> {# #}
class="{{ ItemType::StructField +}} section-header"> {# #}

@notriddle
Copy link
Contributor

I think this version looks good when descriptions are there, but when there's no description there's a excessive amount of space between each item:

With descriptions Without descriptions
image image

@notriddle notriddle added T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 7, 2024
@GuillaumeGomez
Copy link
Member

Just a small ping @xonx4l to check with you if you still plan to work on this.

@xonx4l
Copy link
Author

xonx4l commented Aug 22, 2024

yeah I will be back at it once I get free from work.

@ismailarilik
Copy link
Contributor

I've just tried to use the changes in this PR but was unable to do so. x doc compiler is not responding the changes in src/doc/rust.css. What am I doing wrong?

@@ -350,6 +350,14 @@ a.test-arrow {
margin-bottom: 1em;
}

.structfield {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized but you didn't modify the correct css file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is wrong, how did you get those screenshots?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By modifying the CSS in the web page directly.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 11, 2024
…-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`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request 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
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustdoc: struct fields are spaced too closely
6 participants