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

Search: correctly remove Search.init on Sphinx >= 5.0 #100

Merged
merged 4 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commands:
type: string
sphinx-version:
type: string
default: "21,22,23,24,30,31,32,33,34,latest"
default: "21,22,23,24,30,31,32,33,34,35,40,41,42,43,44,latest"
steps:
- checkout
- run: pip install --user tox
Expand Down Expand Up @@ -48,6 +48,13 @@ jobs:
- run-tox:
version: py39

py310:
docker:
- image: 'cimg/python:3.10'
steps:
- run-tox:
version: py310

lint:
docker:
- image: 'cimg/python:3.9'
Expand All @@ -61,6 +68,7 @@ workflows:
tests:
jobs:
- lint
- py310
- py39
- py38
- py37
Expand Down
7 changes: 5 additions & 2 deletions readthedocs_ext/readthedocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,12 @@ def remove_search_init(app, exception):
replacement_text = '/* Search initialization removed for Read the Docs */'
replacement_regex = re.compile(
r'''
^\$\(document\).ready\(function\s*\(\)\s*{(?:\n|\r\n?)
^(\$\(document\).ready\(function\s*\(\)\s*{(?:\n|\r\n?)
\s*Search.init\(\);(?:\n|\r\n?)
\}\);
\}\);)
|
# Sphinx >=5.0 calls Search.init this way.
(_ready\(Search.init\);)
''',
Comment on lines +260 to 266
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@stsewd it seems you missed this comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the docstring ad92c76

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. I missed that :)

(re.MULTILINE | re.VERBOSE)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/pr-example/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
author = 'readthedocs'
version = '0.1'
release = '0.1'
language = None
language = 'en'
exclude_patterns = ['_build']
todo_include_todos = False
html_theme = 'alabaster'
Expand Down
2 changes: 1 addition & 1 deletion tests/pyexample-json/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
author = u'readthedocs'
version = '0.1'
release = '0.1'
language = None
language = 'en'
exclude_patterns = ['_build']
pygments_style = 'sphinx'
todo_include_todos = False
Expand Down
2 changes: 1 addition & 1 deletion tests/pyexample/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
author = u'readthedocs'
version = '0.1'
release = '0.1'
language = None
language = 'en'
exclude_patterns = ['_build']
pygments_style = 'sphinx'
todo_include_todos = False
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
py{27,36}-sphinx{15,16,17,18}
py{36,37,38,39}-sphinx{21,22,23,24,30,31,32,33,34,latest}
py{36,37,38,39,310}-sphinx{21,22,23,24,30,31,32,33,34,35,40,41,42,43,44,latest}
Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like sphinx 3.5, 4.0 and 4.1 aren't compatible with python 3.10 (bc of changes on the typing module). Thoughts about testing 3.10 only for sphinx>=4.2?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me.

lint

[testenv]
Expand All @@ -24,7 +24,14 @@ deps =
sphinx32: Sphinx<3.3
sphinx33: Sphinx<3.4
sphinx34: Sphinx<3.5
sphinx35: Sphinx<3.6
sphinx40: Sphinx<4.1
sphinx41: Sphinx<4.2
sphinx42: Sphinx<4.3
sphinx43: Sphinx<4.4
sphinx44: Sphinx<4.5
sphinxlatest: Sphinx
sphinxmaster: git+https://github.com/sphinx-doc/sphinx.git@master
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not running sphinxmaster on circle since it could fail, but it's useful for testing future changes locally.

commands =
py.test {posargs}

Expand Down