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

Use distinct styles for note lists and label lists #1209

Merged
merged 5 commits into from
Dec 8, 2024

Conversation

nevans
Copy link
Contributor

@nevans nevans commented Nov 15, 2024

Together with #1208, this brings back the original "note" and "label" list styles. It also improves on the original "note" list styling in two ways: 1) the second line and every line after it share the same indentation, and 2) commas are added between multiple dt elements.

  • Use the original label description list style #1208
    This also removes margin-bottom from dt, which is necessary for the second indentation to match subsequent lines.
  • Add closing tags for description list terms #1226
    Necessary for adding separators between dt.
  • Bring back the float: left style, for note lists only
  • Set the dt line-height to match main p.
    Otherwise, the dt has a larger line-height than the p tag inside the dd, which causes the second line to have the same indentation as the first but different from the third.
  • Add commas between note list terms.

This fixes #1199.

@nevans
Copy link
Contributor Author

nevans commented Nov 15, 2024

For the screenshot, I added an extra <dt> for every <dd> to demonstrate how that looks in various line wrapping situations.

Screenshot 2024-11-15 at 17-40-13 ExampleRDoc - rdoc Documentation

@nevans nevans changed the title Use different styles for note lists and label lists Use distinct styles for note lists and label lists Nov 15, 2024
@nevans
Copy link
Contributor Author

nevans commented Nov 15, 2024

For what it's worth, here are a few times the styles for these have been updated:

Anyway, this does not mean we need to style them differently by default. If we add the closing </dt> tag and continue to give them different classes, then I can use my own local stylesheets. But I do think it means that I'm not the only one who appreciates having distinct styles for the two list types. 🙂

If this PR is accepted, I'm willing to create a PR for similar styling for ri, so they match.

@nevans
Copy link
Contributor Author

nevans commented Nov 18, 2024

FWIW, I've experimented with four different styles.

The "label" style restored by #1208:

First described term
  Description starts on a new line below the term and is indented.  Lorem ipsum dolor
  sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
  et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
  laboris nisi ut aliquip ex ea commodo consequat.
Second described term
Riker Ipsum
  We finished our first sensor sweep of the neutral zone.  Yesterday I did not know
  how to eat gagh. And blowing into maximum warp speed, you appeared for an instant
  to be in two places at once.  They were just sucked into space.  Mr. Worf, you do
  remember how to fire phasers?

The "note" style in this PR:

First described term    Description starts on same line as its term.  Subsequent
  lines are indented by one em.  Lorem ipsum dolor sit amet, consectetur adipiscing
  elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
  minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  commodo consequat.
Second described term, Riker Ipsum    Indentation levels are independent of the
  length of the terms.  Every description indents only one level.  We finished our
  first sensor sweep of the neutral zone.  Yesterday I did not know how to eat gagh.
  And blowing into maximum warp speed, you appeared for an instant to be in two
  places at once.  They were just sucked into space.  Mr. Worf, you do remember how
  to fire phasers?

Before making these PRs, I was considering a more table-like style for "notes" (e.g. as used by hanna). This can be accomplished with dl by using display: grid. But, while that is nice for some description lists, I think it's less generically applicable. Also, it would've needed extra styling to be responsive to smaller screen widths.

First described term    Definition starts on same line as its term.  All descriptions
                        share the same indentation.  This is easy to achieve with
                        display: grid.  But it does not work well with wide terms or
                        nested lists.  Lorem ipsum dolor sit amet, consectetur
                        adipiscing elit, sed do eiusmod tempor incididunt ut labore  
                        et dolore magna aliqua.
Second described term
Riker Ipsum             I chose to style this so that the description text starts on
                        the same line as the final description term.  Every
                        description indents only one level.  We finished our first
                        sensor sweep of the neutral zone.  Yesterday I did not know
                        how to eat gagh.  And blowing into maximum warp speed, you
                        appeared for an instant to be in two places at once.  They
                        were just sucked into space.  Mr. Worf, you do remember how
                        to fire phasers?

Another reasonable approach would be to mimic how rdoc allows the comments to be formatted, indenting each dd independently, based on its corresponding terms' widths. This still doesn't work well with wide terms or nested lists, and the alternating indentations can be slightly jarring, IMO.

First term    Definition starts on same line as its term.  Each description has its
              own indentation, based on its term(s).  This still doesn't work well
              with wide terms or nested lists.  And I personally find the different
              indentation of each description to be jarring.  Lorem ipsum dolor sit
              amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
              labore et dolore magna aliqua.
Second described term
Riker Ipsum              Indented according to its widest term.  We finished our
                         first sensor sweep of the neutral zone.  Yesterday I did
                         not know how to eat gagh. And blowing into maximum warp
                         speed, you appeared for an instant to be in two places at
                         once.  They were just sucked into space.  Mr. Worf, you do
                         remember how to fire phasers?

As a default for all description lists, the original "label" style is
more readable.

This is slightly different from the original `label` dl though:
* slightly increased left margin for `dd` (to 1em)
* removed right margin on `dd`
* removed `dt` bottom margin and `dd` top margin, to reduce the gap
  between the term and its description (to only the standard line-height
  gap).
Without the closing tags, the dt elements contain whitespace after the
text.  This normally isn't a big deal, but does mess some things up,
e.g: using `::after` with `content: ", "` in stylesheets.
Unlike the original note list styles, this version sets the line-height
for all `dt` elements to be the same as the `p` elements contained
inside the `dd`, so that the second line has the same indentation as all
subsequent lines.
@flavorjones
Copy link
Collaborator

I just opened a similar issue at #1227 and I wanted to say that this PR solves my problem exactly as I'd hoped. ❤️

Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. I think the updated style looks great and thanks for fixing the tag closing issue as well 👍

Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Oops I was meant to approve

@st0012 st0012 merged commit 9e69ea6 into ruby:master Dec 8, 2024
26 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Dec 8, 2024
(ruby/rdoc#1209)

* Use the original `label` description list style

As a default for all description lists, the original "label" style is
more readable.

This is slightly different from the original `label` dl though:
* slightly increased left margin for `dd` (to 1em)
* removed right margin on `dd`
* removed `dt` bottom margin and `dd` top margin, to reduce the gap
  between the term and its description (to only the standard line-height
  gap).

* Add closing tags for description list terms

Without the closing tags, the dt elements contain whitespace after the
text.  This normally isn't a big deal, but does mess some things up,
e.g: using `::after` with `content: ", "` in stylesheets.

* Restore float:left style for note lists

Unlike the original note list styles, this version sets the line-height
for all `dt` elements to be the same as the `p` elements contained
inside the `dd`, so that the second line has the same indentation as all
subsequent lines.

* Add commas between note list terms

ruby/rdoc@9e69ea6d75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Label list and note list styling should be different
3 participants