8000 Docs search: Replace jQuery with vanilla JavaScript by hugovk · Pull Request #106743 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Docs search: Replace jQuery with vanilla JavaScript #106743

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 2 commits into from
Jul 16, 2023
Merged

Conversation

hugovk
Copy link
Member
@hugovk hugovk commented Jul 14, 2023

Good

  1. Go to https://docs.python.org/3/ (built with Sphinx 4.5.0)
  2. Search for "asynchronous generator iterator"

Expected result:

https://docs.python.org/3/search.html?q=asynchronous+generator+iterator&check_keywords=yes&area=default

The glossary item is highlighted:

image

Bad

  1. Go to https://docs.python.org/3.13/ (built with Sphinx 6.2.0)
  2. Open the devtools console (ignore the switchers.js error, that's switchers.js not compatible with Sphinx 6 / requires jQuery docsbuild-scripts#159)
  3. Search for "asynchronous generator iterator"

Actual result:

https://docs.python.org/3.13/search.html?q=asynchronous+generator+iterator

There's no glossary summary, and there are search.html errors in the console:

image

Problem

This is because Sphinx 6 removed jQuery:

#7405: Removed the jQuery and underscore.js JavaScript frameworks.

These frameworks are no longer be automatically injected into themes from Sphinx 6.0. If you develop a theme or extension that uses the jQuery, $, or $u global objects, you need to update your JavaScript to modern standards, or use the mitigation below.

https://www.sphinx-doc.org/en/master/changes.html#release-6-0-0-released-dec-29-2022 has a couple of options on how to re-add jQuery, but it would be better rewrite https://github.com/python/docsbuild-scripts/blob/main/templates/switchers.js to use vanilla JavaScript.

Fix

Rewrite using vanilla JavaScript.

image

📚 Documentation preview 📚: https://cpython-previews--106743.org.readthedocs.build/en/106743/search.html?q=asynchronous+generator+iterator

@hugovk hugovk changed the title Replace jQuery with vanilla JavaScript Docs search: Replace jQuery with vanilla JavaScript Jul 14, 2023
@hugovk hugovk added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jul 14, 2023
@hugovk hugovk merged commit c02ee45 into python:main Jul 16, 2023
@hugovk hugovk deleted the rm-jquery branch July 16, 2023 07:26
@miss-islington
Copy link
Contributor

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-106802 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 16, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 16, 2023
* Replace jQuery with vanilla JavaScript
* Switch 'var' to 'const' or 'let'
(cherry picked from commit c02ee45)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 16, 2023
* Replace jQuery with vanilla JavaScript
* Switch 'var' to 'const' or 'let'
(cherry picked from commit c02ee45)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
@bedevere-bot
Copy link

GH-106803 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 16, 2023
hugovk added a commit that referenced this pull request Jul 16, 2023
#106802)

Docs search: Replace jQuery with vanilla JavaScript (GH-106743)

* Replace jQuery with vanilla JavaScript
* Switch 'var' to 'const' or 'let'
(cherry picked from commit c02ee45)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
hugovk added a commit that referenced this pull request Jul 16, 2023
#106803)

Docs search: Replace jQuery with vanilla JavaScript (GH-106743)

* Replace jQuery with vanilla JavaScript
* Switch 'var' to 'const' or 'let'
(cherry picked from commit c02ee45)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
428D
Development

Successfully merging this pull request may close these issues.

4 participants
0