GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Make the theme responsive by obulat · Pull Request #46 · python/python-docs-theme Conversation
Contributor
I have been reading on my phone a lot lately, and was disappointed by the fact that I couldn't read python docs: the fonts are too small, and, if I try to zoom in, the text doesn't fit on the page, so I have to swipe to see the whole line. This is my attempt to add responsiveness to python docs theme, fixing #30. On screen widths smaller than 900 px, it:
Screenshot with menu closed: Problems that need to be solved:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
septatrix
suggested changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overall a great idea and I would also really like a responsive theme though there seem to be some unrelated changes and implementation details which should be discussed
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+2
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By moving the checkbox up in the dom tree it may be possible to implement this using only javascript and make it more accessible for people without javascript
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I replaced the checkbox with a button. Is this better for people without javascript?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I would have done is move the input as a checkbox directly next to the sidebar, reference it in the label via id and apply the styles based on whether the checkbox is checked or not. I may have time tomorrow to create a PR on your fork repo if you want to.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have done it like this at first (checkbox input and applying styles based on :checked property). Then I was checking for accessibility and found this article which shows that a button as menu opener has some advantages regarding accessibility: namely, it is easier to set up keyboard handling. On the other hand, I just realized that people probably don't use keyboard for navigation on mobile, and it is more important to set up No-script solution than keyboard navigation on mobile.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition if you follow this guide you also get a working css only solution with added accesibility using javascript
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. - Remove unnecessary `show` call for searchbox. - Remove `box-sizing:border-box` for all elements. - Add `aria-label` to search input instead of visually-hiding labels for accessibility - Some style fixes
|
There was an error while loading. Please reload this page.
|
Beware, i'm working on moving the switchers generation code to docsbuild scripts instead of cpython. See python/docsbuild-scripts#90 I did not think about switchers being located in different places, we have to check if there is something to fix either in docsbuild side or here. As the switchers are no longer to be maintained in cpython, I was removing the placeholders and the switchers variable in python/cpython#20969 I'm on my phone right know so I can't test it, but we need to agree on how to "communicate" to docsbuild the switchers places. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hi @obulat! Took the time to think about it, but beware, I'm particularily bad at HTML/JS:
The current
What about adding all needed placeholders in python-docs-theme, so How to test with docsbuild-script locally: $ # In a clone of docsbuild-scripts $ mkdir -p www logs build_root $ python3 -m venv build_root/venv/ $ build_root/venv/bin/python -m pip install -r requirements.txt $ build_root/venv/bin/python -m pip install path_to_your_python-docs-theme $ python3 ./build_docs.py --quick --build-root build_root --www-root www --log-directory logs --group $(id -g) --skip-cache-invalidation --language en --branch master (Currently testing it and wow, that's really nice, thanks a lot for working on this topic!) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi, @julien, thank you for your comments, that's really helpful! I will try to look into it as soon as I have time. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think a problem which should be tackled first is overflowing stuff like |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Menu is opened/closed using only css (invisible checkbox), works without js enabled - Accessibility added using javascript
I've added wrapping |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| z-index: 1; | ||
| } | ||
| .mobile-nav * { | ||
| box-sizing: border-box; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If possibly I would stay with the sphinx default of not modifying the box-sizing property
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I tried removing it, but I couldn't get the searchbox to fit the screen on all the different sizes: flexbox and padding and border in content-box sizing model are too complex. I don't think adding a different box-sizing property should be a problem because the new box-sizing applies only to the .mobile-nav part.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I don't see any reason to avoid doing this, as long as whoever works on this theme finds that model easier to work with. There are variants of normalise.css that set this on the entire page, so setting this for a whole bunch of elements, is A-OK in my opinion.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Wheee! This is amazing. Is there anything I can do to help move this forward? :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi, should I close this issue due to the new theme added in pypa/pip#9012 ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@obulat No no. I don’t imagine docs.python.org would be changing to that theme anytime soon, and this PR is a pretty great improvement over status quo. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
And even if the theme were to change there may still be other projects using this theme |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Hi, @JulienPalard , I'm on Windows, so originally I couldn't test the However, I did add empty placeholder divs: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm sorry it took me so long to get back to implementing the requested changes. The index page still doesn't look too good, with the main reason being that the layout used for contents is a table, which doesn't look good on a small screen. I think we should convert it into a two-column layout that can be converted into a one-column layout on smaller screens. However, I would say it is a to-do for another PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There's no Windows support on docsbuild-scripts, and I don't except to add it anytime.
This is really strange, can you open an issue on docsbuild-script with the steps you followed so I can try reproduce and we fix this? I often build the docs locally (on Debian), and have no theme issues. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@obulat I was able to build a local version, I had to patch docsbuild-scripts (hardening a regex detecting the version part in the URL in case the URL contains an IP like 0.0.0.0 ...). It works: it gets replaced \o/ but only on mobile, as the placeholder only exist for mobile. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I completely understand, just wanted to add this bit of information for context.
I will try to do that as soon as I can. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
As this PR is for the mobile version, I did not touch the placeholders for the desktop version. I could add them here, or in a new PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I can understand, but this is a bit dangerous: if there's a release between your two PRs, language and version switchers will disaperar on desktop (as paceholders are found on the new mobile part, my code don't try to add them on the desktop part). I mean, in switchers.js I have two branches : either the placeholders are found and I use them, or they are not found and I create them, so if they're found, they're not created. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I didn't realize that. I tend to include too much in my PRs, so I was trying to improve myself 😄 I added the placeholders. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The plan sounds good to me! And, as I'm probably over-stating now, we can iterate too! :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| </label> | ||
| <nav class="nav-content" role="navigation"> | ||
| <img src="{{ pathto('_static/' + 'py.svg', 1) }}" alt="Logo"/> | ||
| <a href="{{ pathto('index') }}"> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
pathto(master_doc) would be more appropriate here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Or does CPython documentation use contents for the toctree?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you for such a quick review! :) I know what I added doesn't work for sure. Let me try pathto(master_doc).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I need help!
I don't know how to add the correct link to the docs.python.org/3.9/.
In line 88 in layout.html I added <a href="{{ pathto(theme_root_url) }}" , and it creates file:///.../doc-html(3)/3.9/https://www.python.org/.html
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Don't wrap it in pathto, just {{ theme_root_url }} is enough.
That should fix it. :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In other words, that is behaviour I'd expect and I thought that's what you wanted?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I guess I was confusing the two kind of links (to the docs home and the language/framework home). On the sites I used a lot lately (eg Vue.js) the style of the framework home page and the style of the documentation homepage are the same. And it feels like I just go to the documentation home, not the general home, when I click on the logo.
But you are right, now we have the correct behavior, linking to python.org.
We still don't have a way of going to the documentation homepage, docs.python.org/3 from other pages on mobile. Is it necessary to add it, and add it in this PR specifically?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If you want to have a link to the documentation homepage, that'd be {{ pathto(master_doc) }} or {{ pathto("index") }}. No need for a |e on either of them.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Honestly, this feels like something we can do in a follow up PR.
I'd really like to push for getting this landed soon, so that we can start moving other things forward without needing to come back and update this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please, let me know if I need to change anything? I would be happy to get this landed soon, too!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
LGTM. @pradyunsg if it's OK for you too, I'm ok for a merge :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Way to go @obulat 🎉 🐍! Thanks for the great teamwork @JulienPalard and @pradyunsg. Happy to see this merged soon 👍🏼 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you everyone! I'm really excited for this change! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🚀
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks a lot @obulat, I hope this can go to production soon. @willingc do you know the release process? I don't have the upload rights to pypi/p/python-docs-theme. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't @JulienPalard, but I can look into it tomorrow. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks also from me - when I originally put together this theme I hadn't even expected it to live so long :D |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Mariatta @ncoghlan @theacodes If one of you can deploy this awesome update or give @JulienPalard or me privileges that would be great. Would love to see @obulat's work in production 🎉 @birkenfeld Thank you for all that you have done for docs over the years. You rock. 🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@willingc you now have permissions on PyPI ✨ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If there are already so many people taking a look at this right now I would like to mention the dark theme PR which also is ready for review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@septatrix I just saw this now. After the dark theme lands we can do a dot release to get that in. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The CSS in the base template was updated to include this directive in #7695 and released in sphinx v3.1.0. The original implementation was in python#46, prior to the basic theme including it, and now we have the same meta tag duplicated. Remove the block, and reduce the duplication. Signed-off-by: Mike Fiedler <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.