-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Proposal for sphinxcontrib-jquery #9665
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
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c2b18d0
WIP: design doc for sphinxcontrib-jquery
benjaoming d0160d2
First draft of sphinxcontrib-jquery design doc
benjaoming 170822f
Updates to clarify add_jquery_if_sphinx_lt_6
benjaoming 7b32111
Wrong year
benjaoming 020e8cb
Move comment deadline to dl
benjaoming e3abead
Adds further references
benjaoming 970d54d
Update docs/dev/design/sphinx-jquery.rst
benjaoming 9094143
First iteration on comments from @humitos
benjaoming 56287af
Update docs/dev/design/sphinx-jquery.rst
benjaoming 0452b1b
Adds 2 @humitos suggestions manually after GitHub suggestions stopped…
benjaoming 22eeafc
Merge branch 'sphinxcontrib-jquery' of github.com:benjaoming/readthed…
benjaoming 3b16ca2
Add force=False kwarg and have only one function ``add_jquery``.
benjaoming 1762cb3
Use `setup_extension` + add config value for forcing jquery inclusion
benjaoming 093c873
Adds dependencies, Python 2.7 and Sphinx 1.8, cc: @AA-Turner
benjaoming 76e8a55
Change dependencies to read Python 3+ and Sphinx 1.8+ for now, let's …
benjaoming c9eb6a8
Update docs/dev/design/sphinx-jquery.rst
benjaoming 9e36fee
Merge branch 'main' of github.com:readthedocs/readthedocs.org into sp…
benjaoming 86c6c3f
Remove release cycle proposal, it's up to @AA-Turner :)
benjaoming c361683
Merge branch 'sphinxcontrib-jquery' of github.com:benjaoming/readthed…
benjaoming 02a53ed
Update docs/dev/design/sphinx-jquery.rst
benjaoming 8e84d00
Update docs/dev/design/sphinx-jquery.rst
benjaoming 039606e
Remove specific mentioning of jQuery versions, add a note about bundl…
benjaoming 36ff76e
Merge branch 'sphinxcontrib-jquery' of github.com:benjaoming/readthed…
benjaoming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| sphinxcontrib-jquery | ||
| ==================== | ||
|
|
||
| jQuery will be removed from Sphinx 6.0.0. We can expect 6.0.0 to ship in late 2022. | ||
|
|
||
| .. seealso:: | ||
|
|
||
| * https://github.com/sphinx-doc/sphinx/issues/7405 | ||
| * https://github.com/sphinx-doc/sphinx/issues/10070 | ||
| * https://github.com/readthedocs/sphinx-hoverxref/issues/160 | ||
| * https://github.com/readthedocs/sphinx_rtd_theme/issues/1253 | ||
| * https://github.com/pydata/pydata-sphinx-theme/issues/764 | ||
|
|
||
| This is a "request for comments" for a community-owned Sphinx extension that bundles jQuery. | ||
|
|
||
|
|
||
| Overview | ||
| -------- | ||
|
|
||
| Comment deadline: | ||
| November 1st, 2022 | ||
|
|
||
| Package-name: | ||
| ``sphinxcontrib-jquery`` | ||
|
|
||
| Python package: | ||
| ``sphinxcontrib.jquery`` | ||
|
|
||
| Dependencies: | ||
| Python 3+, Sphinx 1.8+ (or perhaps no lower bound?) | ||
|
|
||
| Ownership: | ||
| Read the Docs core team will implement the initial releases of an otherwise community-owned package that lives in https://github.com/sphinx-contrib/jquery | ||
|
|
||
| Functionality: | ||
| sphinxcontrib-jquery is a Sphinx extension that provides a simple mechanism for other Sphinx extensions and themes to ensure that jQuery is included into the HTML build outputs and loaded in the HTML DOM itself. | ||
| More specifically, the extension ensures that jQuery is loaded exactly once no matter how many themes and extensions that request to include jQuery nor the version of Sphinx. | ||
|
|
||
| Scope: | ||
| This extension assumes that it's enough to provide a single version of jQuery for all of its dependent extensions and themes. | ||
| As the name implies, this extension is built to handle jQuery only. | ||
| It's not a general asset manager and it's not looking to do dependency resolution of jQuery versions. | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| The primary users of this package are | ||
| **theme and extension developers** and | ||
| **documentation project owners**. | ||
|
|
||
|
|
||
| Theme and extension developers | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The following 2 steps need to be completed: | ||
|
|
||
| #. A Sphinx theme or extension should depend on the python package ``sphinxcontrib-jquery``. | ||
| #. In your extension's or theme's ``setup(app)``, call ``app.setup_extension("sphinxcontrib.jquery")``. | ||
|
|
||
| In addition to this, we recommend extension and theme developers to log to the browser's ``console.error`` in case jQuery isn't found. The log message could for instance say:: | ||
|
|
||
| if (typeof $ == "undefined") console.error("<package-name> depends on sphinxcontrib-jquery. Please ensure that <package-name>.setup(app) is called or add 'sphinxcontrib-jquery' to your conf.py extensions setting.") | ||
|
|
||
|
|
||
| Documentation project owners | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| If you are depending on a theme or extension that did not itself address the removal of jQuery from Sphinx 6, you can patch up your project like this: | ||
|
|
||
| #. Add ``sphinxcontrib-jquery`` to your installed dependencies. | ||
| #. Add ``sphinxcontrib.jquery`` to your ``extensions`` setting in ``conf.py``. | ||
|
|
||
|
|
||
| Calling ``app.setup_extension("sphinxcontrib.jquery")`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| When a Sphinx theme or extension calls `setup_extension() <https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.setup_extension>`_, a call to ``sphinxcontrib.jquery.setup(app)`` will happen. Adding ``sphinxcontrib.jquery`` to a documentation project's ``conf.extensions`` will also call ``sphinxcontrib.jquery.setup(app)`` (at most once). | ||
|
|
||
| In ``sphinxcontrib.jquery.setup(app)``, jQuery is added. The default behaviour is to detect the Sphinx version and include jQuery via `app.add_js_file <https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_js_file>`__ when Sphinx is from version 6 and up. jQuery is added at most once. | ||
|
|
||
|
|
||
| Config value: ``jquery_force_enable`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| When setting ``jquery_force_enable=True``, jQuery is added no matter the Sphinx version, but at most once. This is useful if you want to handle alternative conditions for adding jQuery. | ||
benjaoming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. warning:: | ||
|
|
||
| If you set ``jquery_force_enable=True``, you most likely should also add ``Sphinx>=6`` to your theme's/extension's dependencies since versions before this already bundles jQuery! | ||
|
|
||
|
|
||
| jQuery version and inclusion | ||
| ---------------------------- | ||
|
|
||
| jQuery should be be shipped together with the Python package and not be referenced from a CDN. | ||
|
|
||
| Sphinx has kept relatively up to date with jQuery, and this package intends to follow. | ||
| The most recently bundled jQuery version was v3.5.1 and only two releases have happened since: 3.6.0 and 3.6.1. | ||
| The 3.6.0 release had a very small backwards incompatibility which illustrates how harmless these upgrades are for the general purpose Sphinx package. | ||
|
|
||
| Therefore, we propose to start the release of ``sphinxcontrib-jquery`` at 3.5.1 (the currently shipped version) and subsequently release 3.6.1 in an update. This will give users that need 3.5.1 a choice of a lower version. | ||
|
|
||
| The bundled jQuery version will be NPM pre-minified and distributed together with the PyPI package. | ||
|
|
||
| The minified jQuery JS file is ultimately included by calling `app.add_js_file <https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_js_file>`__, which is passed the following arguments: | ||
|
|
||
| .. code:: python | ||
|
|
||
| app.add_js_file( | ||
| get_jquery_url_path(), | ||
| loading_method="defer", | ||
| priority=200, | ||
benjaoming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| integrity="sha256-{}".format(get_jquery_sha256_checksum()) | ||
| ) | ||
benjaoming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| .. note:: It's possible to include jQuery in other ways, but this ultimately doesn't require this extension and is therefore not supported. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.