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

sphinx/themes/basic/layout: Set url_root properly on index, don't use '#' #8524

Merged

Conversation

rkdarst
Copy link
Contributor

@rkdarst rkdarst commented Dec 7, 2020

  • url_root is set to # on the index page, which layout.html tries to
    change back to '' (the empty string).
  • But, this updated url_root wasn't used in the actual location, as an
    argument to documentation_options.js.
  • Thus, clever enough templates, which tried to use
    $DOCUMENTATION_OPTIONS.URL_ROOT inside javascript would fail.
    This was manifested as broken links, which led to this issue:
    copy button <img> doesn't work with dirhtml builder, only on root page executablebooks/sphinx-copybutton#110
  • I have eventually traced that back to sphinx itself, and found that
    layout.html tried to fix the problem, but the fixed value wasn't
    used.
  • This fix works in my basic test, but I will continue with more tests.
  • Review:
    • someone more clever should examine this and make sure it makes
      sense
    • This does not have tests. Should it?

@rkdarst
Copy link
Contributor Author

rkdarst commented Dec 7, 2020

It is a bit hidden in there, but this is a full analysis of what goes wrong and why this is needed: executablebooks/sphinx-copybutton#110

rkdarst added a commit to rkdarst/sphinx_rtd_theme that referenced this pull request Dec 7, 2020
- You can see a practical demonstration of the problem, fully seeing
  the effect if it is not fixed, here (though that example uses the
  alabaster theme, the effect is the same here):
  executablebooks/sphinx-copybutton#110
- This is a copy of a fix from Sphinx.  The sphinx pull request is
  sphinx-doc/sphinx#8524

Detailed description:

- url_root is set to `#` on the index page, which layout.html tries to
  change back to `''` (the empty string).
- But, this updated url_root wasn't used in the actual location, as an
  argument to `documentation_options.js`.
- Thus, clever enough templates, which tried to use
  `$DOCUMENTATION_OPTIONS.URL_ROOT` inside javascript would fail.
  This was manifested as broken links, which led to this issue:
  executablebooks/sphinx-copybutton#110
- I have eventually traced that back to sphinx itself, and found that
  layout.html tried to fix the problem, but the fixed value wasn't
  used.
- This fix works in my basic test, but I will continue with more tests.
- Review:
  - someone more clever should examine this and make sure it makes
    sense
  - This does not have tests.  Should it?
@tk0miya tk0miya added this to the 3.4.0 milestone Dec 12, 2020
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

Look good. Could you rebase this into the 3.x branch? Then I'll merge this soon.

… '#'

- url_root is set to `#` on the index page, which layout.html tries to
  change back to `''` (the empty string).
- But, this updated url_root wasn't used in the actual location, as an
  argument to `documentation_options.js`.
- Thus, clever enough templates, which tried to use
  `$DOCUMENTATION_OPTIONS.URL_ROOT` inside javascript would fail.
  This was manifested as broken links, which led to this issue:
  executablebooks/sphinx-copybutton#110
- I have eventually traced that back to sphinx itself, and found that
  layout.html tried to fix the problem, but the fixed value wasn't
  used.
- This fix works in my basic test, but I will continue with more tests.
- Review:
  - someone more clever should examine this and make sure it makes
    sense
  - This does not have tests.  Should it?
@rkdarst rkdarst force-pushed the rkdarst/template-document-options-url_root branch from 313f163 to 21aecb1 Compare December 13, 2020 17:19
@rkdarst
Copy link
Contributor Author

rkdarst commented Dec 13, 2020

Ah yes, I forgot 3.x is dev. Rebased. Thanks!

@rkdarst rkdarst changed the base branch from master to 3.x December 14, 2020 07:54
@rkdarst
Copy link
Contributor Author

rkdarst commented Dec 14, 2020

Now PR edited to have a base branch of 3.x, which I forgot to do before.

@tk0miya tk0miya merged commit 18b7202 into sphinx-doc:3.x Dec 14, 2020
@tk0miya
Copy link
Member

tk0miya commented Dec 14, 2020

Thank you for your great work!

tk0miya added a commit that referenced this pull request Dec 14, 2020
@rkdarst rkdarst deleted the rkdarst/template-document-options-url_root branch December 15, 2020 12:53
stsewd pushed a commit to readthedocs/sphinx_rtd_theme that referenced this pull request Dec 15, 2020
#1025)

- You can see a practical demonstration of the problem, fully seeing
  the effect if it is not fixed, here (though that example uses the
  alabaster theme, the effect is the same here):
  executablebooks/sphinx-copybutton#110
- This is a copy of a fix from Sphinx.  The sphinx pull request is
  sphinx-doc/sphinx#8524

Detailed description:

- url_root is set to `#` on the index page, which layout.html tries to
  change back to `''` (the empty string).
- But, this updated url_root wasn't used in the actual location, as an
  argument to `documentation_options.js`.
- Thus, clever enough templates, which tried to use
  `$DOCUMENTATION_OPTIONS.URL_ROOT` inside javascript would fail.
  This was manifested as broken links, which led to this issue:
  executablebooks/sphinx-copybutton#110
- I have eventually traced that back to sphinx itself, and found that
  layout.html tried to fix the problem, but the fixed value wasn't
  used.
- This fix works in my basic test, but I will continue with more tests.
- Review:
  - someone more clever should examine this and make sure it makes
    sense
  - This does not have tests.  Should it?
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants