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

Update python-docs-theme to work with Sphinx 5 & 6 #99

Merged
merged 9 commits into from
Apr 13, 2023

Conversation

AA-Turner
Copy link
Member

Updated remaining jQuery scripts to standard JavaScript, and a few fixes for CSS changes.

A

@AA-Turner
Copy link
Member Author

Turns out this is required for Sphinx 5... python/cpython#99381

A

@AA-Turner AA-Turner changed the title Update for Sphinx 6 Update for Sphinx 5 and 6 Nov 11, 2022
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ezio-melotti ezio-melotti left a comment

Choose a reason for hiding this comment

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

In addition to the inline comments, I have two generic comments:

  • The use of semicolons at the end of the line seems inconsistent. Unless there is a specific reason to keep them, I would just remove them all.
  • I would avoid the use of if (...) return; or if (...) break; or even if (...) some_functions(). The expression after the condition should go on a new line, and it should be surrounded by { }, e.g.:
    if (...) {
       ...
    }

Fun fact: I originally implemented both the collapsible sidebar (~12 years ago in python/cpython#47393) and the copybutton (~11 years ago in python/cpython@59dba38) and since then they have traveled around a number of dirs and repos. It's nice to see that in the meanwhile things got standardized and JS evolved to the point that JQuery is no longer needed.

.github/workflows/tests.yml Outdated Show resolved Hide resolved
python_docs_theme/static/copybutton.js Outdated Show resolved Hide resolved
python_docs_theme/static/copybutton.js Outdated Show resolved Hide resolved
python_docs_theme/static/copybutton.js Outdated Show resolved Hide resolved
@hugovk
Copy link
Member

hugovk commented Feb 6, 2023

Is this ready to merge?

@hugovk
Copy link
Member

hugovk commented Feb 13, 2023

Rebased on main to build RTD preview:

And there's an error in the console:

sidebar.js:34 Uncaught TypeError: Cannot read properties of null (reading 'querySelector')
    at HTMLDocument.initialiseSidebar (sidebar.js:34:38)

From the last line of:

  const bodyWrapper = document.getElementsByClassName("bodywrapper")[0]
  const sidebar = document.getElementsByClassName("sphinxsidebar")[0]
  const sidebarWrapper = document.getElementsByClassName('sphinxsidebarwrapper')[0]
  const sidebarButton = document.getElementById("sidebarbutton")
  const sidebarArrow = sidebarButton.querySelector('span')

@m-aciek m-aciek mentioned this pull request Mar 13, 2023
@AA-Turner
Copy link
Member Author

Updated the JavaScript, the previous version was attempting to access an element that had yet to be created. Thank you for the review!

A

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Working fine now, thanks!

@AA-Turner AA-Turner requested review from ezio-melotti and JulienPalard and removed request for JulienPalard April 11, 2023 20:27
@AA-Turner AA-Turner changed the title Update for Sphinx 5 and 6 Update python-docs-theme to work with Sphinx 5 & 6 Apr 12, 2023
@JulienPalard JulienPalard merged commit 32115c4 into python:main Apr 13, 2023
@JulienPalard
Copy link
Member

I just built https://docs.python.org/3.12/ after merging this PR.

@AA-Turner
Copy link
Member Author

I just built docs.python.org/3.12 after merging this PR.

Working for me in Firefox 112 on Windows! If you have time over the next few weeks, please would we be able to make a 2023.4 release, to unblock python/cpython#99381?

A

@JulienPalard
Copy link
Member

JulienPalard commented Apr 17, 2023

Releasing: #126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants