From 8aaea906a1971fb5d4254250fa8a801b278dacc5 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 14 Feb 2021 20:41:19 +0300 Subject: [PATCH 01/10] Fix #8884: Include sphinx/search/minified-js in the tarball --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 54da42895..1114ca19f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -22,6 +22,7 @@ recursive-include sphinx/texinputs_win * recursive-include sphinx/themes * recursive-include sphinx/locale *.js *.pot *.po *.mo recursive-include sphinx/search/non-minified-js *.js +recursive-include sphinx/search/minified-js *.js recursive-include sphinx/ext/autosummary/templates * recursive-include tests * recursive-include utils * From 19ea727f1baf0f2d2f4224847f7cb6e53231a864 Mon Sep 17 00:00:00 2001 From: jfbu Date: Sun, 14 Feb 2021 21:13:09 +0100 Subject: [PATCH 02/10] Adapt our tests to Pygments 2.8.0 --- tests/test_build_html.py | 9 +- tests/test_directive_code.py | 204 ++++++++++++++++++++++++----------- 2 files changed, 150 insertions(+), 63 deletions(-) diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 8d02f5bed..ffd32d6f5 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -1621,7 +1621,14 @@ def test_html_codeblock_linenos_style_table(app): app.build() content = (app.outdir / 'index.html').read_text() - assert '
1\n2\n3\n4
' in content + pygments_version = tuple(LooseVersion(pygments.__version__).version) + if pygments_version >= (2, 8): + assert ('
1\n'
+                '2\n'
+                '3\n'
+                '4
') in content + else: + assert '
1\n2\n3\n4
' in content @pytest.mark.sphinx('html', testroot='reST-code-block', diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py index 0ae11baf3..ee67b738a 100644 --- a/tests/test_directive_code.py +++ b/tests/test_directive_code.py @@ -9,7 +9,9 @@ """ import os +from distutils.version import LooseVersion +import pygments import pytest from docutils import nodes @@ -421,46 +423,87 @@ def test_literal_include_block_start_with_comment_or_brank(app, status, warning) def test_literal_include_linenos(app, status, warning): app.builder.build(['linenos']) html = (app.outdir / 'linenos.html').read_text() + pygments_version = tuple(LooseVersion(pygments.__version__).version) # :linenos: - assert ('
'
-            ' 1\n'
-            ' 2\n'
-            ' 3\n'
-            ' 4\n'
-            ' 5\n'
-            ' 6\n'
-            ' 7\n'
-            ' 8\n'
-            ' 9\n'
-            '10\n'
-            '11\n'
-            '12\n'
-            '13
' in html) + if pygments_version >= (2, 8): + assert ('
'
+                ' 1\n'
+                ' 2\n'
+                ' 3\n'
+                ' 4\n'
+                ' 5\n'
+                ' 6\n'
+                ' 7\n'
+                ' 8\n'
+                ' 9\n'
+                '10\n'
+                '11\n'
+                '12\n'
+                '13
' in html) + else: + assert ('
'
+                ' 1\n'
+                ' 2\n'
+                ' 3\n'
+                ' 4\n'
+                ' 5\n'
+                ' 6\n'
+                ' 7\n'
+                ' 8\n'
+                ' 9\n'
+                '10\n'
+                '11\n'
+                '12\n'
+                '13
' in html) # :lineno-start: - assert ('
'
-            '200\n'
-            '201\n'
-            '202\n'
-            '203\n'
-            '204\n'
-            '205\n'
-            '206\n'
-            '207\n'
-            '208\n'
-            '209\n'
-            '210\n'
-            '211\n'
-            '212
' in html) + if pygments_version >= (2, 8): + assert ('
'
+                '200\n'
+                '201\n'
+                '202\n'
+                '203\n'
+                '204\n'
+                '205\n'
+                '206\n'
+                '207\n'
+                '208\n'
+                '209\n'
+                '210\n'
+                '211\n'
+                '212
' in html) + else: + assert ('
'
+                '200\n'
+                '201\n'
+                '202\n'
+                '203\n'
+                '204\n'
+                '205\n'
+                '206\n'
+                '207\n'
+                '208\n'
+                '209\n'
+                '210\n'
+                '211\n'
+                '212
' in html) # :lineno-match: - assert ('
'
-            '5\n'
-            '6\n'
-            '7\n'
-            '8\n'
-            '9
' in html) + if pygments_version >= (2, 8): + assert ('
'
+                '5\n'
+                '6\n'
+                '7\n'
+                '8\n'
+                '9
' in html) + else: + assert ('
'
+                '5\n'
+                '6\n'
+                '7\n'
+                '8\n'
+                '9
' in html) @pytest.mark.sphinx('latex', testroot='directive-code') @@ -594,45 +637,82 @@ def test_linenothreshold(app, status, warning): app.builder.build(['linenothreshold']) html = (app.outdir / 'linenothreshold.html').read_text() + pygments_version = tuple(LooseVersion(pygments.__version__).version) lineos_head = '
'
     lineos_tail = '
' # code-block using linenothreshold - _, matched, html = html.partition(lineos_head + - '1\n' - '2\n' - '3\n' - '4\n' - '5\n' - '6' + lineos_tail) + if pygments_version >= (2, 8): + _, matched, html = html.partition(lineos_head + + '1\n' + '2\n' + '3\n' + '4\n' + '5\n' + '6' + lineos_tail) + else: + _, matched, html = html.partition(lineos_head + + '1\n' + '2\n' + '3\n' + '4\n' + '5\n' + '6' + lineos_tail) assert matched # code-block not using linenothreshold - html, matched, _ = html.partition(lineos_head + - '1\n' - '2' + lineos_tail) + if pygments_version >= (2, 8): + html, matched, _ = html.partition(lineos_head + + '1\n' + '2' + lineos_tail) + else: + html, matched, _ = html.partition(lineos_head + + '1\n' + '2' + lineos_tail) assert not matched # literal include using linenothreshold - _, matched, html = html.partition(lineos_head + - ' 1\n' - ' 2\n' - ' 3\n' - ' 4\n' - ' 5\n' - ' 6\n' - ' 7\n' - ' 8\n' - ' 9\n' - '10\n' - '11\n' - '12\n' - '13' + lineos_tail) + if pygments_version >= (2, 8): + _, matched, html = html.partition(lineos_head + + ' 1\n' + ' 2\n' + ' 3\n' + ' 4\n' + ' 5\n' + ' 6\n' + ' 7\n' + ' 8\n' + ' 9\n' + '10\n' + '11\n' + '12\n' + '13' + lineos_tail) + else: + _, matched, html = html.partition(lineos_head + + ' 1\n' + ' 2\n' + ' 3\n' + ' 4\n' + ' 5\n' + ' 6\n' + ' 7\n' + ' 8\n' + ' 9\n' + '10\n' + '11\n' + '12\n' + '13' + lineos_tail) assert matched # literal include not using linenothreshold - html, matched, _ = html.partition(lineos_head + - '1\n' - '2\n' - '3' + lineos_tail) + if pygments_version >= (2, 8): + html, matched, _ = html.partition(lineos_head + + '1\n' + '2\n' + '3' + lineos_tail) + else: + html, matched, _ = html.partition(lineos_head + + '1\n' + '2\n' + '3' + lineos_tail) assert not matched From 5fe6a62aaafbd8f970dbcf95aa6344c4b784a68e Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Mon, 15 Feb 2021 00:16:58 -0500 Subject: [PATCH 03/10] Sometimes _viewcode_modules can be False; don't crash when it is - Fixes #8880 --- sphinx/ext/viewcode.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py index 21cff6a03..6bedf2e1c 100644 --- a/sphinx/ext/viewcode.py +++ b/sphinx/ext/viewcode.py @@ -152,7 +152,11 @@ def env_merge_info(app: Sphinx, env: BuildEnvironment, docnames: Iterable[str], def env_purge_doc(app: Sphinx, env: BuildEnvironment, docname: str) -> None: modules = getattr(env, '_viewcode_modules', {}) - for modname, (code, tags, used, refname) in list(modules.items()): + for modname, entry in list(modules.items()): + if entry is False: + continue + + code, tags, used, refname = entry for fullname in list(used): if used[fullname] == docname: used.pop(fullname) From f993f769984223c2d73846f5d32c8d5de613488d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 15 Feb 2021 22:58:17 +0900 Subject: [PATCH 04/10] Update CHANGES for PR #8886 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index be9c0c5c0..18354fa92 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #8884: html: minified js stemmers not included in the distributed package + Testing -------- From 633c5ad9c6f4511e3016dd451f17ace1ad160fb2 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 15 Feb 2021 23:22:49 +0900 Subject: [PATCH 05/10] Update CHANGES for PR #8888 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 18354fa92..bcad80274 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,8 @@ Bugs fixed ---------- * #8884: html: minified js stemmers not included in the distributed package +* #8880: viewcode: ExtensionError is raised on incremental build after + unparsable python module found Testing -------- From 82052838239187b0ec0e2b2b8911e5f6263491cf Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 16 Feb 2021 01:30:45 +0900 Subject: [PATCH 06/10] refactor: html: Fix typo --- sphinx/builders/html/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 1dbde6e37..6a069c3ca 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -1036,7 +1036,7 @@ class StandaloneHTMLBuilder(Builder): # sort JS/CSS before rendering HTML ctx['script_files'].sort(key=lambda js: js.priority) - ctx['css_files'].sort(key=lambda js: js.priority) + ctx['css_files'].sort(key=lambda css: css.priority) try: output = self.templates.render(templatename, ctx) From b29ee3ded00de1d3ddc6547b171f091374a71e47 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 16 Feb 2021 01:35:29 +0900 Subject: [PATCH 07/10] Fix #8883: autodoc: AttributeError on assigning __annotations__ --- CHANGES | 2 ++ sphinx/ext/autodoc/__init__.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index bcad80274..8720eb3b8 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #8883: autodoc: AttributeError is raised on assigning __annotations__ on + read-only class * #8884: html: minified js stemmers not included in the distributed package * #8880: viewcode: ExtensionError is raised on incremental build after unparsable python module found diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index dc413b5c2..3ae6dff75 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1394,7 +1394,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ params[0] = params[0].replace(annotation=typ) try: func.__signature__ = sig.replace(parameters=params) # type: ignore - except TypeError: + except (AttributeError, TypeError): # failed to update signature (ex. built-in or extension types) return @@ -2177,7 +2177,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: params[1] = params[1].replace(annotation=typ) try: func.__signature__ = sig.replace(parameters=params) # type: ignore - except TypeError: + except (AttributeError, TypeError): # failed to update signature (ex. built-in or extension types) return @@ -2443,7 +2443,7 @@ class AttributeDocumenter(GenericAliasMixin, NewTypeMixin, SlotsMixin, # type: annotations[attrname] = annotation except (AttributeError, PycodeError): pass - except TypeError: + except (AttributeError, TypeError): # Failed to set __annotations__ (built-in, extensions, etc.) pass From 82501a6f6ff1e037d6f8fed12b257e8cdb9c34a7 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 15 Feb 2021 23:46:18 +0900 Subject: [PATCH 08/10] Fix #8885: html: AttributeError for CSS/JS files on html_context Since 3.5.0, priority has been added to control CSS/JS files. But it's not working if projects installs custom CSS/JS files via `html_context` instead of `html_css_files` and `html_js_files`. This avoids the crash to keep it "not broken". --- CHANGES | 2 ++ sphinx/builders/html/__init__.py | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index bcad80274..f666a5b16 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,8 @@ Bugs fixed ---------- * #8884: html: minified js stemmers not included in the distributed package +* #8885: html: AttributeError is raised if CSS/JS files are installed via + :confval:`html_context` * #8880: viewcode: ExtensionError is raised on incremental build after unparsable python module found diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 6a069c3ca..c799b0176 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -1035,8 +1035,20 @@ class StandaloneHTMLBuilder(Builder): templatename = newtmpl # sort JS/CSS before rendering HTML - ctx['script_files'].sort(key=lambda js: js.priority) - ctx['css_files'].sort(key=lambda css: css.priority) + try: + # Convert script_files to list to support non-list script_files (refs: #8889) + ctx['script_files'] = sorted(list(ctx['script_files']), key=lambda js: js.priority) + except AttributeError: + # Skip sorting if users modifies script_files directly (maybe via `html_context`). + # refs: #8885 + # + # Note: priority sorting feature will not work in this case. + pass + + try: + ctx['css_files'] = sorted(list(ctx['css_files']), key=lambda css: css.priority) + except AttributeError: + pass try: output = self.templates.render(templatename, ctx) From baed519b90ca0ff77748b0445dc6aec598197c80 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 16 Feb 2021 23:35:32 +0900 Subject: [PATCH 09/10] Bump to 3.5.1 final --- CHANGES | 19 ++----------------- sphinx/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index de4709dfb..b2ca0322e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,17 +1,5 @@ -Release 3.5.1 (in development) -============================== - -Dependencies ------------- - -Incompatible changes --------------------- - -Deprecated ----------- - -Features added --------------- +Release 3.5.1 (released Feb 16, 2021) +===================================== Bugs fixed ---------- @@ -24,9 +12,6 @@ Bugs fixed * #8880: viewcode: ExtensionError is raised on incremental build after unparsable python module found -Testing --------- - Release 3.5.0 (released Feb 14, 2021) ===================================== diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 61ea947d8..66e5e68fb 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -32,7 +32,7 @@ if 'PYTHONWARNINGS' not in os.environ: warnings.filterwarnings('ignore', "'U' mode is deprecated", DeprecationWarning, module='docutils.io') -__version__ = '3.5.1+' +__version__ = '3.5.1' __released__ = '3.5.1' # used when Sphinx builds its own docs #: Version info for better programmatic use. @@ -43,7 +43,7 @@ __released__ = '3.5.1' # used when Sphinx builds its own docs #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (3, 5, 1, 'beta', 0) +version_info = (3, 5, 1, 'final', 0) package_dir = path.abspath(path.dirname(__file__)) From 97de316a0218096b0ed26f43262d5e8cd0473ac9 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 16 Feb 2021 23:36:48 +0900 Subject: [PATCH 10/10] Bump version --- CHANGES | 21 +++++++++++++++++++++ sphinx/__init__.py | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index b2ca0322e..1542e8834 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,24 @@ +Release 3.5.2 (in development) +============================== + +Dependencies +------------ + +Incompatible changes +-------------------- + +Deprecated +---------- + +Features added +-------------- + +Bugs fixed +---------- + +Testing +-------- + Release 3.5.1 (released Feb 16, 2021) ===================================== diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 66e5e68fb..a5cf22064 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -32,8 +32,8 @@ if 'PYTHONWARNINGS' not in os.environ: warnings.filterwarnings('ignore', "'U' mode is deprecated", DeprecationWarning, module='docutils.io') -__version__ = '3.5.1' -__released__ = '3.5.1' # used when Sphinx builds its own docs +__version__ = '3.5.2+' +__released__ = '3.5.2' # used when Sphinx builds its own docs #: Version info for better programmatic use. #: @@ -43,7 +43,7 @@ __released__ = '3.5.1' # used when Sphinx builds its own docs #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (3, 5, 1, 'final', 0) +version_info = (3, 5, 2, 'beta', 0) package_dir = path.abspath(path.dirname(__file__))