Skip to content

DOC Reduce whitespace above h1 tag #26787

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

Merged
merged 13 commits into from
Aug 2, 2023
Merged

Conversation

thomasjpfan
Copy link
Member

@thomasjpfan thomasjpfan commented Jul 6, 2023

There is too much spacing above the sections and CSS for making section links visible does not work anymore. (Maybe something changed with newer versions of Sphinx)

On main, there is too much whitespace above the sections. This PR fixes the spacing.

This PR keeps the whitespace introduce by #26625. The difference is the white-space above the first section is reduced.

main

Screenshot 2023-07-29 at 1 42 06 PM

PR

Screenshot 2023-07-29 at 1 47 14 PM

@thomasjpfan thomasjpfan added this to the 1.3.1 milestone Jul 6, 2023
@thomasjpfan thomasjpfan added the Quick Review For PRs that are quick to review label Jul 6, 2023
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 6b54800. Link to the linter CI: here

@jeremiedbb
Copy link
Member

On my screen, this change makes the section title hidden by the top bar of the website

@thomasjpfan thomasjpfan removed the Quick Review For PRs that are quick to review label Jul 7, 2023
@betatim
Copy link
Member

betatim commented Jul 7, 2023

This PR:
Screenshot 2023-07-07 at 10 23 09

Main:
Screenshot 2023-07-07 at 10 23 01

I can't really see what changes except for the spacing above the "HDBSCAN" heading being a bit bigger. Is this the change you mean?

@thomasjpfan
Copy link
Member Author

thomasjpfan commented Jul 8, 2023

#26625 added more margin to all the section headers. I updated this PR to remove the margins. With this PR, the anchor improvement from #25783 still works. Here is the release highlights for 1.2:

Main

Screenshot 2023-07-08 at 9 27 17 AM

PR

Screenshot 2023-07-08 at 9 28 18 AM

@thomasjpfan thomasjpfan added the Quick Review For PRs that are quick to review label Jul 8, 2023
@thomasjpfan
Copy link
Member Author

thomasjpfan commented Jul 8, 2023

I'm guessing the intention of #26625 was to add more white-space above sections in the body. With 21be8be (#26787), I reintroduced the white-space:

Screenshot 2023-07-08 at 10 01 11 AM

Copy link
Member

@betatim betatim left a comment

Choose a reason for hiding this comment

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

Fine for me.

@GaelVaroquaux do you want to comment on this?

Otherwise, let's merge

@GaelVaroquaux
Copy link
Member

The spacing above section is not a bug but a feature. Empty space is really important for readability of documents.

@GaelVaroquaux
Copy link
Member

As a reference, see for instance the bootstrap documentation (eg https://getbootstrap.com/docs/5.3/getting-started/introduction/ ).

Bootstrap people know a lot about UX and readability.

@betatim
Copy link
Member

betatim commented Jul 12, 2023

In general I agree with "adding empty space helps readability". It is the number one feature to use if you need to predict if a layout was done by a professional or an amateur: look at how much empty space there is. The next feature being: is the spacing asymmetric between the top and the bottom (pros leave more space below than above).

However, I think we should not spend our time arguing about this. So for me the question is: is this PR changing something that was previously changed on purpose or is it changing something which changed as a side-effect? If the former, I'd vote to leave it as is. If the latter, then lets merge this PR.

The reason I think we are better of not arguing (and because none of us are experts I'd claim we are arguing not discussing ;)) is that I think something like #26809 could bring a lot of benefits in terms of readability, layout, reduced "fuzzing with HTML and CSS", accessibility, etc. This means we should invest our energy there, because it is going to be a big job.

@GaelVaroquaux
Copy link
Member

GaelVaroquaux commented Jul 12, 2023 via email

@GaelVaroquaux
Copy link
Member

The reason I think we are better of not arguing (and because none of us are experts I'd claim we are arguing not discussing ;)) is that I think something like #26809 could bring a lot of benefits in terms of readability, layout, reduced "fuzzing with HTML and CSS", accessibility, etc.

Transitioning a theme well is harder than it looks

@thomasjpfan thomasjpfan changed the title DOC Fixes CSS spacing above sections DOC Fixes anchor links and keep the whitespace Jul 12, 2023
@betatim
Copy link
Member

betatim commented Jul 13, 2023

https://output.circle-artifacts.com/output/job/b11ccb31-7f7e-44e7-8ae2-f591cbd412fe/artifacts/0/doc/modules/generated/sklearn.ensemble.HistGradientBoostingRegressor.html#sklearn.ensemble.HistGradientBoostingRegressor is the equivalent to the link on main, but with these changes.

For me the two (main and PR) look the same :-/

Screenshot 2023-07-13 at 10 20 37

The element that is highlighted in the screenshot is the one that the fragment in the URL refers to. At least I think so. I think the browser (Firefox in this case) is doing the correct thing, it made sure the top of the element is within the viewing area but, there is something on top of it (the menu bar). I think the only way to fix this is to "make the element bigger" so that having the top of it in the viewable area means the actual content is far enough away from the top so that the menu doesn't cover it.

Maybe there is a way to tell the browser that the menu is covering up the element and that it needs to scroll more to make it visible?

I don't know how to "make the element bigger" :-/ Adding margin to it doesn't help and we don't want to increase the padding.

What does seem to "just work" is https://output.circle-artifacts.com/output/job/b11ccb31-7f7e-44e7-8ae2-f591cbd412fe/artifacts/0/doc/modules/generated/sklearn.ensemble.HistGradientBoostingRegressor.html#sklearn-ensemble-histgradientboostingregressor (dashes in the ID instead of dots). Maybe the solution is to link to that instead?

Joy, HTML and CSS trickery :D

@thomasjpfan thomasjpfan marked this pull request as draft July 21, 2023 00:26
@thomasjpfan thomasjpfan removed the Quick Review For PRs that are quick to review label Jul 21, 2023
@thomasjpfan thomasjpfan changed the title DOC Fixes anchor links and keep the whitespace DOC Removs whitespace above h1 tag Jul 29, 2023
@thomasjpfan thomasjpfan marked this pull request as ready for review July 29, 2023 17:26
@thomasjpfan
Copy link
Member Author

thomasjpfan commented Jul 29, 2023

I updated this PR to be simpler. It only removes the space about the H1 tag. Now the whitespace is reduced instead of removed. I agree that whitespace is useful, but the H1 header feels weird to not be aligned with the sidebar. The bootstrap docs site does not have the solid blocks that we do.

main

Screenshot 2023-07-29 at 1 42 06 PM

PR (Does not apply anymore)

Screenshot 2023-07-29 at 1 42 09 PM

@thomasjpfan thomasjpfan changed the title DOC Removs whitespace above h1 tag DOC Reduce whitespace above h1 tag Jul 29, 2023
@thomasjpfan
Copy link
Member Author

thomasjpfan commented Jul 29, 2023

As a compromise, I updated the PR again to reduce the whitespace in the H1 tag. This is around the same space between the actual text and the navbar as the bootstrap site

Screenshot 2023-07-29 at 1 49 27 PM

@GaelVaroquaux
Copy link
Member

Hi @thomasjpfan
I would argue that the whitespace of the h1 is the most important, to separate it from the text above and make it more visible.

If you really feel bad about the space above the first h1 which makes that it is no longer aligned with the top of the page, I would suggest to use the ":first-of-type" to reduce the space only for the first h1.

Another, maybe even better option, would be to add vertical only on h1 that are "general siblings" of the enclosing div, using the "~" selector, which will not apply to the h1 right are the beginning of the div.

I would however argue that even on the first h1, a bit of vertical space is good.

@GaelVaroquaux
Copy link
Member

I sent a PR here thomasjpfan#121 to suggest a way to go in your direction

Copy link
Member

@GaelVaroquaux GaelVaroquaux left a comment

Choose a reason for hiding this comment

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

LGTM!

Thank you for the constructive back-and-forth @thomasjpfan

@GaelVaroquaux
Copy link
Member

I believe that this is ready for merge. @betatim , do you want to have a last look? Without reply from you in a few days, I will merge, as I think that you were OK with the changes.

@GaelVaroquaux
Copy link
Member

I'm merging this: I worry that if we wait too long it is going to get lost in the weeds (I myself had a hard time finding it amongst all the opened PRs).

@GaelVaroquaux GaelVaroquaux merged commit b4fcce8 into scikit-learn:main Aug 2, 2023
9Y5 pushed a commit to 9Y5/scikit-learn that referenced this pull request Aug 2, 2023
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Sep 18, 2023
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
jeremiedbb pushed a commit that referenced this pull request Sep 20, 2023
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants