-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
singlehtml: Use same-document hyperlinks for internal project references #12551
singlehtml: Use same-document hyperlinks for internal project references #12551
Conversation
…RIs. Relates-to commit 413e740.
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
…is-samedocument Conflicts: CHANGES.rst
…octree` hyperlinks are intradocument.
…perlinks in `tocdepth` testroot content area are intradocument.
… `_intradocument_hyperlink_check`.
Two more commits planned (one to fix my codestyle errors, and then one to confirm that external links are unmodified during these |
…rs` dir; it is implicitly an HTML builder unit test collection.
…are retained in `toctree` testroot project.
…ternal project reference pagenames.
Ok; no changes planned, and this should be ready for further review (apologies for my over-eager review request earlier @picnixz. I should have added more of these tests before that). |
Hmm.. working on this might have helped me figure out a way that we could remove the |
Ok, yep - that cleanup seems straightforward I think. I can push that here, or as a separate branch/PR. |
I think this is ready -- but to mention again: I think it may be possible to remove |
Sorry for the late reply. I started a review, then went (physically) somewhere else, and forgot about it... |
No problem - thanks for the review! I wasn't sure how to phrase the changelog credit either; I do think it is basically a continuation/completion of the previous change. While going through some other changesets I've learned about |
…_check` node-presence check.
…ck` to HTML test module.
…t-node to xpath. Relates-to commit c514c4f.
…ath_html_util` module.
I am travelling this week so I won't be able to review except on a phone (which is a bit hard...). I'll reply next week..By the way, thank you very much Jay for the work, you've been helping a lot while I left quite a lot of work on autodoc since I'm working on CPython.. I'll try to get some fixes on autodoc next week or the week after (I now have time to formalize autodoc v2). |
I just noticed this today. This PR looks good to me, although I'm not able to understand why some CI docutils tests are failing. Thanks for adding tests to ensure that all same-document links are removed. |
Conflicts due to the tests/ formatting |
…is-samedocument Conflicts: tests/test_builders/test_build_html_tocdepth.py
This is intended primarily to resolve a problem with `singlehtml` documentation projects when viewed on narrow (typically mobile) displays. Under those circumstances, the `.current` CSS selector does not match any sidebar menu elements, because there is no logical notion of a 'current' page in `singlehtml` -- every item is on the same page. Therefore this change proposes an alternative way to identify sidebar links that are 'current' -- it checks for anchors that have an `href` beginning with the query-string fragment identifier (`#`). This is intended to be compatible with both `singlehtml` and `html` project builds. It depends upon sphinx-doc/sphinx#12551
Feature or Bugfix
Purpose
singlehtml
are same-document references, containing a relevant HTML fragment identifier in the query-string, but without a filename part (e.g.#document-directives
instead of the previousindex.html#document-directives
). That's a nice feature, because it allows some browsers to avoid a complete page reload when following the link. However: some URI fixup logic elsewhere in thesinglehtml
builder has still been constructing filename-inclusive hyperlinks. This pull request fixes that.Detail
SingleFileHTMLBuilder.get_target_uri
provides a same-document (anchor-only) hyperlink, modify theSingleFileHTMLBuilder.fix_refuris
method to do the same thing.html_additional_pages
items don't need to be handled in this case, because they would not have anchor targets, andfix_refuris
skips those.class="reference internal"
continue to point to different filenames in a standardhtml
build -- these aregenindex.html
,py-modindex.html
, andsearch.html
-- links to special pages in the Sphinx HTML build output.Relates
singlehtml
).Edit: add missing backtick
Edit: add explanatory note about special pages