From 3a0232807a769e43b3a85ce23b939d15cda477d9 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Thu, 2 Jun 2022 19:10:11 +0100 Subject: [PATCH 01/18] Fix ~Literal references --- sphinx/domains/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index a634a51d2b2..fd43b15b262 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -396,7 +396,7 @@ def make_xrefs(self, rolename: str, domain: str, target: str, results.append(self.make_xref(rolename, domain, sub_target, innernode, contnode, env, inliner, location)) - if sub_target in ('Literal', 'typing.Literal'): + if sub_target in ('Literal', 'typing.Literal', '~typing.Literal'): in_literal = True return results From f5eb5ca597f50a22d3ca7492b907feb615d058c0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 3 Jun 2022 03:13:49 +0900 Subject: [PATCH 02/18] Bump version --- CHANGES | 21 +++++++++++++++++++++ sphinx/__init__.py | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index d9fe18baff1..cb8f9ddc9a5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,24 @@ +Release 5.0.2 (in development) +============================== + +Dependencies +------------ + +Incompatible changes +-------------------- + +Deprecated +---------- + +Features added +-------------- + +Bugs fixed +---------- + +Testing +-------- + Release 5.0.1 (released Jun 03, 2022) ===================================== diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 363821209a2..113dc8bfe89 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -21,8 +21,8 @@ warnings.filterwarnings('ignore', 'The frontend.Option class .*', DeprecationWarning, module='docutils.frontend') -__version__ = '5.0.1' -__released__ = '5.0.1' # used when Sphinx builds its own docs +__version__ = '5.0.2+' +__released__ = '5.0.2' # used when Sphinx builds its own docs #: Version info for better programmatic use. #: @@ -32,7 +32,7 @@ #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (5, 0, 1, 'final', 0) +version_info = (5, 0, 2, 'beta', 0) package_dir = path.abspath(path.dirname(__file__)) From 1e30b8cd4d7a0433e59aec0e2d7fd876bf452076 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 3 Jun 2022 02:29:39 +0900 Subject: [PATCH 03/18] Fix #10509: autosummary: autosummary fails with a shared library --- CHANGES | 2 ++ sphinx/ext/autosummary/generate.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index cb8f9ddc9a5..ca68c54703c 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #10509: autosummary: autosummary fails with a shared library + Testing -------- diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index 5ef7b0352fd..3db7eb989a1 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -155,8 +155,12 @@ def is_skipped(self, name: str, value: Any, objtype: str) -> bool: def scan(self, imported_members: bool) -> List[str]: members = [] - analyzer = ModuleAnalyzer.for_module(self.object.__name__) - attr_docs = analyzer.find_attr_docs() + try: + analyzer = ModuleAnalyzer.for_module(self.object.__name__) + attr_docs = analyzer.find_attr_docs() + except PycodeError: + attr_docs = {} + for name in members_of(self.object, self.app.config): try: value = safe_getattr(self.object, name) From fbd374859ab79de65e7db78377e9824c4352bff1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 4 Jun 2022 17:09:44 +0100 Subject: [PATCH 04/18] Add `aside.topic` for Docutils 0.18+ (sphinx13) --- doc/_themes/sphinx13/static/sphinx13.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/_themes/sphinx13/static/sphinx13.css b/doc/_themes/sphinx13/static/sphinx13.css index c8fb2e5c99b..789a5d4f312 100644 --- a/doc/_themes/sphinx13/static/sphinx13.css +++ b/doc/_themes/sphinx13/static/sphinx13.css @@ -372,7 +372,8 @@ div.quotebar { margin-left: 1em; } -div.topic { +div.topic, +aside.topic { background-color: #f8f8f8; } From 7286291f9326bc023441d64eba9b26b09c2e37f1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 4 Jun 2022 17:45:09 +0100 Subject: [PATCH 05/18] Add docutils_version_info to `StandaloneHTMLBuilder.globalcontext` --- CHANGES | 3 +++ doc/templating.rst | 9 +++++++++ sphinx/builders/html/__init__.py | 1 + 3 files changed, 13 insertions(+) diff --git a/CHANGES b/CHANGES index ca68c54703c..59fe2480f83 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,9 @@ Deprecated Features added -------------- +* #10523: html theme: Expose the Docutils's version info tuple as a template variable, + ``docutils_version_info``. Patch by Adam Turner. + Bugs fixed ---------- diff --git a/doc/templating.rst b/doc/templating.rst index 3d80edd6009..41f74a715c4 100644 --- a/doc/templating.rst +++ b/doc/templating.rst @@ -383,6 +383,15 @@ in the future. .. versionadded:: 4.2 +.. data:: docutils_version_info + + The version of Docutils used to build represented as a tuple of five elements. + For Docutils version 0.16.1 beta 2 this would be `(0, 16, 1, 'beta', 1)``. + The fourth element can be one of: ``alpha``, ``beta``, ``candidate``, ``final``. + ``final`` always has 0 as the last element. + + .. versionadded:: 5.0.2 + .. data:: style The name of the main stylesheet, as given by the theme or diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index b320b0df588..f5ab2d828e0 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -536,6 +536,7 @@ def prepare_writing(self, docnames: Set[str]) -> None: 'css_files': self.css_files, 'sphinx_version': __display_version__, 'sphinx_version_tuple': sphinx_version, + 'docutils_version_info': docutils.__version_info__[:5], 'style': self._get_style_filename(), 'rellinks': rellinks, 'builder': self.name, From bbf1576277f2544327a9252f448a873fd60bc171 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 4 Jun 2022 18:08:10 +0100 Subject: [PATCH 06/18] Fix double brackets on Docutils 0.18+ --- CHANGES | 1 + sphinx/themes/basic/static/basic.css_t | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 59fe2480f83..09ae5f90152 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,7 @@ Bugs fixed ---------- * #10509: autosummary: autosummary fails with a shared library +* #10523: html theme: Fix double brackets on citation references in Docutils 0.18+. Testing -------- diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index 9e5047afe6f..67bfec755ca 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -237,6 +237,7 @@ a.headerlink { visibility: hidden; } +{%- if docutils_version_info[:2] < (0, 18) %} a.brackets:before, span.brackets > a:before{ content: "["; @@ -246,6 +247,7 @@ a.brackets:after, span.brackets > a:after { content: "]"; } +{% endif %} h1:hover > a.headerlink, h2:hover > a.headerlink, From 5ddc22baf85cd46b7a4f2175deb9fcb3359a8858 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:53:57 +0100 Subject: [PATCH 07/18] Fix an example in the templating document Co-authored-by: Matthias Geier --- doc/templating.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/templating.rst b/doc/templating.rst index 41f74a715c4..d9755a836b1 100644 --- a/doc/templating.rst +++ b/doc/templating.rst @@ -386,7 +386,7 @@ in the future. .. data:: docutils_version_info The version of Docutils used to build represented as a tuple of five elements. - For Docutils version 0.16.1 beta 2 this would be `(0, 16, 1, 'beta', 1)``. + For Docutils version 0.16.1 beta 2 this would be `(0, 16, 1, 'beta', 2)``. The fourth element can be one of: ``alpha``, ``beta``, ``candidate``, ``final``. ``final`` always has 0 as the last element. From 25656d07b79aba5917ef74c81c104c09636b656f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:56:14 +0100 Subject: [PATCH 08/18] Line length --- CHANGES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 09ae5f90152..8e8984bfa1a 100644 --- a/CHANGES +++ b/CHANGES @@ -13,8 +13,8 @@ Deprecated Features added -------------- -* #10523: html theme: Expose the Docutils's version info tuple as a template variable, - ``docutils_version_info``. Patch by Adam Turner. +* #10523: html theme: Expose the Docutils's version info tuple as a template + variable, ``docutils_version_info``. Patch by Adam Turner. Bugs fixed ---------- From 36e79d708964be486115a7192b7622a310bf715c Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 4 Jun 2022 21:07:10 +0100 Subject: [PATCH 09/18] Update credits in CHANGES --- CHANGES | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 8e8984bfa1a..3098438ac38 100644 --- a/CHANGES +++ b/CHANGES @@ -13,14 +13,15 @@ Deprecated Features added -------------- -* #10523: html theme: Expose the Docutils's version info tuple as a template +* #10523: HTML Theme: Expose the Docutils's version info tuple as a template variable, ``docutils_version_info``. Patch by Adam Turner. Bugs fixed ---------- * #10509: autosummary: autosummary fails with a shared library -* #10523: html theme: Fix double brackets on citation references in Docutils 0.18+. +* #10523: HTML Theme: Fix double brackets on citation references in Docutils 0.18+. + Patch by Adam Turner. Testing -------- @@ -32,10 +33,11 @@ Bugs fixed ---------- * #10498: gettext: TypeError is raised when sorting warning messages if a node - has no line number -* #10493: html theme: :rst:dir:`topic` directive is rendered incorrectly with - docutils-0.18 -* #10495: IndexError is raised for a :rst:role:`kbd` role having a separator + has no line number. Patch by Adam Turner. +* #10493: HTML Theme: :rst:dir:`topic` directive is rendered incorrectly with + Docutils 0.18. Patch by Adam Turner. +* #10495: IndexError is raised for a :rst:role:`kbd` role having a separator. + Patch by Adam Turner. Release 5.0.0 (released May 30, 2022) ===================================== @@ -76,6 +78,7 @@ Incompatible changes * #10474: :confval:`language` does not accept ``None`` as it value. The default value of ``language`` becomes to ``'en'`` now. + Patch by Adam Turner and Takeshi KOMIYA. Deprecated ---------- @@ -131,11 +134,12 @@ Features added non-imported * #10028: Removed internal usages of JavaScript frameworks (jQuery and underscore.js) and modernised ``doctools.js`` and ``searchtools.js`` to - EMCAScript 2018. + EMCAScript 2018. Patch by Adam Turner. * #10302: C++, add support for conditional expressions (``?:``). * #5157, #10251: Inline code is able to be highlighted via :rst:dir:`role` directive -* #10337: Make sphinx-build faster by caching Publisher object during build +* #10337: Make sphinx-build faster by caching Publisher object during build. + Patch by Adam Turner. Bugs fixed ---------- @@ -143,7 +147,7 @@ Bugs fixed 5.0.0 b1 * #10200: apidoc: Duplicated submodules are shown for modules having both .pyx - and .so files + and .so files. Patch by Adam Turner and Takeshi KOMIYA. * #10279: autodoc: Default values for keyword only arguments in overloaded functions are rendered as a string literal * #10280: autodoc: :confval:`autodoc_docstring_signature` unexpectedly generates From 0926edeb40f1bfb977582619a6a70daa61e589c6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 6 Jun 2022 23:14:27 +0900 Subject: [PATCH 10/18] Update CHANGES for PR #10511 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index ca68c54703c..1b3dec4c32b 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,7 @@ Bugs fixed ---------- * #10509: autosummary: autosummary fails with a shared library +* #10497: py domain: Failed to resolve strings in Literal Testing -------- From 8da2efb1d71ab2d384ddc90cf4fdebe5d18e91cd Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 7 Jun 2022 23:09:12 +0100 Subject: [PATCH 11/18] Rename CSS files to CSS template files --- sphinx/themes/nonav/static/{nonav.css => nonav.css_t} | 0 sphinx/themes/pyramid/static/{epub.css => epub.css_t} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sphinx/themes/nonav/static/{nonav.css => nonav.css_t} (100%) rename sphinx/themes/pyramid/static/{epub.css => epub.css_t} (100%) diff --git a/sphinx/themes/nonav/static/nonav.css b/sphinx/themes/nonav/static/nonav.css_t similarity index 100% rename from sphinx/themes/nonav/static/nonav.css rename to sphinx/themes/nonav/static/nonav.css_t diff --git a/sphinx/themes/pyramid/static/epub.css b/sphinx/themes/pyramid/static/epub.css_t similarity index 100% rename from sphinx/themes/pyramid/static/epub.css rename to sphinx/themes/pyramid/static/epub.css_t From 5806f0af2788db40661d62e5e88c2c1560ae46b6 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 7 Jun 2022 23:10:15 +0100 Subject: [PATCH 12/18] Add `nav.contents` everywhere that `div.topic` is used --- doc/_themes/sphinx13/static/sphinx13.css | 1 + sphinx/themes/basic/static/basic.css_t | 12 ++++++++++++ sphinx/themes/bizstyle/static/bizstyle.css_t | 3 +++ sphinx/themes/classic/static/classic.css_t | 3 +++ sphinx/themes/epub/static/epub.css_t | 3 +++ sphinx/themes/nature/static/nature.css_t | 3 +++ sphinx/themes/nonav/static/nonav.css_t | 3 +++ sphinx/themes/pyramid/static/epub.css_t | 3 +++ sphinx/themes/pyramid/static/pyramid.css_t | 3 +++ sphinx/themes/sphinxdoc/static/sphinxdoc.css_t | 3 +++ sphinx/themes/traditional/static/traditional.css_t | 3 +++ 11 files changed, 40 insertions(+) diff --git a/doc/_themes/sphinx13/static/sphinx13.css b/doc/_themes/sphinx13/static/sphinx13.css index 789a5d4f312..5d64eda512a 100644 --- a/doc/_themes/sphinx13/static/sphinx13.css +++ b/doc/_themes/sphinx13/static/sphinx13.css @@ -372,6 +372,7 @@ div.quotebar { margin-left: 1em; } +nav.contents, div.topic, aside.topic { background-color: #f8f8f8; diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index 67bfec755ca..0a0447f0ff4 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -337,12 +337,18 @@ p.sidebar-title { font-weight: bold; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.admonition, div.topic, aside.topic, blockquote { clear: left; } /* -- topics ---------------------------------------------------------------- */ +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { border: 1px solid #ccc; padding: 7px; @@ -381,6 +387,9 @@ div.body p.centered { div.sidebar > :last-child, aside.sidebar > :last-child, +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents > :last-child, +{% endif %} div.topic > :last-child, aside.topic > :last-child, div.admonition > :last-child { @@ -389,6 +398,9 @@ div.admonition > :last-child { div.sidebar::after, aside.sidebar::after, +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents::after, +{% endif %} div.topic::after, aside.topic::after, div.admonition::after, diff --git a/sphinx/themes/bizstyle/static/bizstyle.css_t b/sphinx/themes/bizstyle/static/bizstyle.css_t index b5c84e0bb59..47dcc7e4fb0 100644 --- a/sphinx/themes/bizstyle/static/bizstyle.css_t +++ b/sphinx/themes/bizstyle/static/bizstyle.css_t @@ -306,6 +306,9 @@ div.quotebar { border: 1px solid #ccc; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background-color: #f8f8f8; } diff --git a/sphinx/themes/classic/static/classic.css_t b/sphinx/themes/classic/static/classic.css_t index 58b55c8bf53..9107dc9344d 100644 --- a/sphinx/themes/classic/static/classic.css_t +++ b/sphinx/themes/classic/static/classic.css_t @@ -290,6 +290,9 @@ div.seealso { border: 1px solid #ff6; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background-color: #eee; } diff --git a/sphinx/themes/epub/static/epub.css_t b/sphinx/themes/epub/static/epub.css_t index bd64a1bc868..9cc47152bdc 100644 --- a/sphinx/themes/epub/static/epub.css_t +++ b/sphinx/themes/epub/static/epub.css_t @@ -245,6 +245,9 @@ p.sidebar-title { /* -- topics ---------------------------------------------------------------- */ +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; diff --git a/sphinx/themes/nature/static/nature.css_t b/sphinx/themes/nature/static/nature.css_t index f3c0d0224a6..c1a2cd6cb71 100644 --- a/sphinx/themes/nature/static/nature.css_t +++ b/sphinx/themes/nature/static/nature.css_t @@ -194,6 +194,9 @@ div.seealso { border: 1px solid #ff6; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background-color: #eee; } diff --git a/sphinx/themes/nonav/static/nonav.css_t b/sphinx/themes/nonav/static/nonav.css_t index 90c3300cf03..d62536ab230 100644 --- a/sphinx/themes/nonav/static/nonav.css_t +++ b/sphinx/themes/nonav/static/nonav.css_t @@ -234,6 +234,9 @@ p.sidebar-title { /* -- topics ---------------------------------------------------------------- */ +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; diff --git a/sphinx/themes/pyramid/static/epub.css_t b/sphinx/themes/pyramid/static/epub.css_t index 8606c8c8de0..7f59c670c84 100644 --- a/sphinx/themes/pyramid/static/epub.css_t +++ b/sphinx/themes/pyramid/static/epub.css_t @@ -254,6 +254,9 @@ div.seealso { border: 1px solid #ff6; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background-color: #eee; } diff --git a/sphinx/themes/pyramid/static/pyramid.css_t b/sphinx/themes/pyramid/static/pyramid.css_t index f093ba16493..bf18b8b156a 100644 --- a/sphinx/themes/pyramid/static/pyramid.css_t +++ b/sphinx/themes/pyramid/static/pyramid.css_t @@ -245,6 +245,9 @@ div.seealso { padding: 10px 20px 10px 60px; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background: #eeeeee; border: 2px solid #C6C9CB; diff --git a/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t index b6de4ae6f2e..f6a83840425 100644 --- a/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t +++ b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t @@ -266,6 +266,9 @@ div.quotebar { border: 1px solid #ccc; } +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background-color: #f8f8f8; } diff --git a/sphinx/themes/traditional/static/traditional.css_t b/sphinx/themes/traditional/static/traditional.css_t index b5b05dc2186..5caf48ccf6c 100644 --- a/sphinx/themes/traditional/static/traditional.css_t +++ b/sphinx/themes/traditional/static/traditional.css_t @@ -506,6 +506,9 @@ p.rubric { /* "Topics" */ +{%- if docutils_version_info[:2] >= (0, 18) %} +nav.contents, +{% endif %} div.topic, aside.topic { background-color: #eee; border: 1px solid #ccc; From 27f05328d0369ad0db85c27935d52fdadf020f6b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 7 Jun 2022 23:21:52 +0100 Subject: [PATCH 13/18] Move `aside.topic` into the conditional blocks --- sphinx/themes/basic/static/basic.css_t | 10 ++++++---- sphinx/themes/bizstyle/static/bizstyle.css_t | 3 ++- sphinx/themes/classic/static/classic.css_t | 3 ++- sphinx/themes/epub/static/epub.css_t | 3 ++- sphinx/themes/nature/static/nature.css_t | 3 ++- sphinx/themes/nonav/static/nonav.css_t | 3 ++- sphinx/themes/pyramid/static/epub.css_t | 3 ++- sphinx/themes/pyramid/static/pyramid.css_t | 3 ++- sphinx/themes/sphinxdoc/static/sphinxdoc.css_t | 3 ++- sphinx/themes/traditional/static/traditional.css_t | 3 ++- 10 files changed, 24 insertions(+), 13 deletions(-) diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index 0a0447f0ff4..d8f3fe74626 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -339,8 +339,9 @@ p.sidebar-title { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.admonition, div.topic, aside.topic, blockquote { +div.admonition, div.topic, blockquote { clear: left; } @@ -348,8 +349,9 @@ div.admonition, div.topic, aside.topic, blockquote { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { border: 1px solid #ccc; padding: 7px; margin: 10px 0 10px 0; @@ -389,9 +391,9 @@ div.sidebar > :last-child, aside.sidebar > :last-child, {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents > :last-child, +aside.topic > :last-child, {% endif %} div.topic > :last-child, -aside.topic > :last-child, div.admonition > :last-child { margin-bottom: 0; } @@ -400,9 +402,9 @@ div.sidebar::after, aside.sidebar::after, {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents::after, +aside.topic::after, {% endif %} div.topic::after, -aside.topic::after, div.admonition::after, blockquote::after { display: block; diff --git a/sphinx/themes/bizstyle/static/bizstyle.css_t b/sphinx/themes/bizstyle/static/bizstyle.css_t index 47dcc7e4fb0..a524345f9a9 100644 --- a/sphinx/themes/bizstyle/static/bizstyle.css_t +++ b/sphinx/themes/bizstyle/static/bizstyle.css_t @@ -308,8 +308,9 @@ div.quotebar { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background-color: #f8f8f8; } diff --git a/sphinx/themes/classic/static/classic.css_t b/sphinx/themes/classic/static/classic.css_t index 9107dc9344d..789bec81128 100644 --- a/sphinx/themes/classic/static/classic.css_t +++ b/sphinx/themes/classic/static/classic.css_t @@ -292,8 +292,9 @@ div.seealso { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background-color: #eee; } diff --git a/sphinx/themes/epub/static/epub.css_t b/sphinx/themes/epub/static/epub.css_t index 9cc47152bdc..a30344431a0 100644 --- a/sphinx/themes/epub/static/epub.css_t +++ b/sphinx/themes/epub/static/epub.css_t @@ -247,8 +247,9 @@ p.sidebar-title { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; margin: 10px 0 10px 0; diff --git a/sphinx/themes/nature/static/nature.css_t b/sphinx/themes/nature/static/nature.css_t index c1a2cd6cb71..93f9a594483 100644 --- a/sphinx/themes/nature/static/nature.css_t +++ b/sphinx/themes/nature/static/nature.css_t @@ -196,8 +196,9 @@ div.seealso { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background-color: #eee; } diff --git a/sphinx/themes/nonav/static/nonav.css_t b/sphinx/themes/nonav/static/nonav.css_t index d62536ab230..933365e073c 100644 --- a/sphinx/themes/nonav/static/nonav.css_t +++ b/sphinx/themes/nonav/static/nonav.css_t @@ -236,8 +236,9 @@ p.sidebar-title { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { border: 1px solid #ccc; padding: 7px 7px 0 7px; margin: 10px 0 10px 0; diff --git a/sphinx/themes/pyramid/static/epub.css_t b/sphinx/themes/pyramid/static/epub.css_t index 7f59c670c84..98741d0b8ab 100644 --- a/sphinx/themes/pyramid/static/epub.css_t +++ b/sphinx/themes/pyramid/static/epub.css_t @@ -256,8 +256,9 @@ div.seealso { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background-color: #eee; } diff --git a/sphinx/themes/pyramid/static/pyramid.css_t b/sphinx/themes/pyramid/static/pyramid.css_t index bf18b8b156a..0ced6b29f8e 100644 --- a/sphinx/themes/pyramid/static/pyramid.css_t +++ b/sphinx/themes/pyramid/static/pyramid.css_t @@ -247,8 +247,9 @@ div.seealso { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background: #eeeeee; border: 2px solid #C6C9CB; padding: 10px 20px; diff --git a/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t index f6a83840425..1817c48bcf5 100644 --- a/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t +++ b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t @@ -268,8 +268,9 @@ div.quotebar { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background-color: #f8f8f8; } diff --git a/sphinx/themes/traditional/static/traditional.css_t b/sphinx/themes/traditional/static/traditional.css_t index 5caf48ccf6c..8a2f0712fbe 100644 --- a/sphinx/themes/traditional/static/traditional.css_t +++ b/sphinx/themes/traditional/static/traditional.css_t @@ -508,8 +508,9 @@ p.rubric { {%- if docutils_version_info[:2] >= (0, 18) %} nav.contents, +aside.topic, {% endif %} -div.topic, aside.topic { +div.topic { background-color: #eee; border: 1px solid #ccc; padding: 0 7px 0 7px; From 3956cf2249d27ed63e8381c07dfde36f6c96f78f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 8 Jun 2022 15:45:27 +0100 Subject: [PATCH 14/18] Fix documenting inherited attributes --- sphinx/ext/autodoc/__init__.py | 3 ++- sphinx/ext/autodoc/importer.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index e16ab8ce5c5..642e0cfd805 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1670,7 +1670,8 @@ def add_directive_header(self, sig: str) -> None: self.add_line(' ' + _('Bases: %s') % ', '.join(base_classes), sourcename) def get_object_members(self, want_all: bool) -> Tuple[bool, ObjectMembers]: - members = get_class_members(self.object, self.objpath, self.get_attr) + members = get_class_members(self.object, self.objpath, self.get_attr, + self.config.autodoc_inherit_docstrings) if not want_all: if not self.options.members: return False, [] # type: ignore diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 85c1e81be64..d392ae75ddf 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -205,8 +205,8 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable, return members -def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable - ) -> Dict[str, "ObjectMember"]: +def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable, + inherit_docstrings: bool = True) -> Dict[str, "ObjectMember"]: """Get members and attributes of target class.""" from sphinx.ext.autodoc import INSTANCEATTR, ObjectMember @@ -290,6 +290,11 @@ def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable elif (ns == qualname and docstring and isinstance(members[name], ObjectMember) and not members[name].docstring): + if cls != subject and not inherit_docstrings: + # If we are in the MRO of the class and not the class itself, + # and we do not want to inherit docstrings, then skip setting + # the docstring below + continue # attribute is already known, because dir(subject) enumerates it. # But it has no docstring yet members[name].docstring = '\n'.join(docstring) From 29edce9243046962f5f024d510315133448dd3e1 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 14 Jun 2022 02:49:07 +0900 Subject: [PATCH 15/18] test: Add testcase for autodoc_inherit_docstring and attributes (refs: #10539) --- .../test-ext-autodoc/target/inheritance.py | 3 + tests/test_ext_autodoc.py | 8 +++ tests/test_ext_autodoc_automodule.py | 7 ++ tests/test_ext_autodoc_configs.py | 66 +++++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/tests/roots/test-ext-autodoc/target/inheritance.py b/tests/roots/test-ext-autodoc/target/inheritance.py index 485a943c872..85d95cd742e 100644 --- a/tests/roots/test-ext-autodoc/target/inheritance.py +++ b/tests/roots/test-ext-autodoc/target/inheritance.py @@ -1,4 +1,7 @@ class Base(object): + #: docstring + inheritedattr = None + def inheritedmeth(self): """Inherited function.""" diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index ecd2bbce6fc..a35c6f640e5 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -549,6 +549,7 @@ def test_autodoc_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()', ' .. py:method:: Base.inheritedmeth()', ' .. py:method:: Base.inheritedstaticmeth(cls)' @@ -569,6 +570,7 @@ def test_autodoc_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()', ' .. py:method:: Base.inheritedmeth()', ' .. py:method:: Base.inheritedstaticmeth(cls)' @@ -601,6 +603,7 @@ def test_autodoc_exclude_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()' ] @@ -618,6 +621,7 @@ def test_autodoc_exclude_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()' ] @@ -628,6 +632,7 @@ def test_autodoc_exclude_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()', ' .. py:method:: Base.inheritedstaticmeth(cls)' ] @@ -639,6 +644,7 @@ def test_autodoc_exclude_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()', ] @@ -648,6 +654,7 @@ def test_autodoc_exclude_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()', ] @@ -658,6 +665,7 @@ def test_autodoc_exclude_members(app): actual = do_autodoc(app, 'class', 'target.inheritance.Base', options) assert list(filter(lambda l: '::' in l, actual)) == [ '.. py:class:: Base()', + ' .. py:attribute:: Base.inheritedattr', ' .. py:method:: Base.inheritedclassmeth()', ' .. py:method:: Base.inheritedmeth()', ' .. py:method:: Base.inheritedstaticmeth(cls)' diff --git a/tests/test_ext_autodoc_automodule.py b/tests/test_ext_autodoc_automodule.py index 8208d86f661..71b23679d96 100644 --- a/tests/test_ext_autodoc_automodule.py +++ b/tests/test_ext_autodoc_automodule.py @@ -133,6 +133,13 @@ def test_automodule_inherited_members(app): ' :module: target.inheritance', '', '', + ' .. py:attribute:: Base.inheritedattr', + ' :module: target.inheritance', + ' :value: None', + '', + ' docstring', + '', + '', ' .. py:method:: Base.inheritedclassmeth()', ' :module: target.inheritance', ' :classmethod:', diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py index 0011f450b5a..f40f3354e11 100644 --- a/tests/test_ext_autodoc_configs.py +++ b/tests/test_ext_autodoc_configs.py @@ -277,6 +277,72 @@ def test_autodoc_inherit_docstrings(app): ] +@pytest.mark.sphinx('html', testroot='ext-autodoc') +def test_autodoc_inherit_docstrings_for_inherited_members(app): + options = {"members": None, + "inherited-members": None} + + assert app.config.autodoc_inherit_docstrings is True # default + actual = do_autodoc(app, 'class', 'target.inheritance.Derived', options) + assert list(actual) == [ + '', + '.. py:class:: Derived()', + ' :module: target.inheritance', + '', + '', + ' .. py:attribute:: Derived.inheritedattr', + ' :module: target.inheritance', + ' :value: None', + '', + ' docstring', + '', + '', + ' .. py:method:: Derived.inheritedclassmeth()', + ' :module: target.inheritance', + ' :classmethod:', + '', + ' Inherited class method.', + '', + '', + ' .. py:method:: Derived.inheritedmeth()', + ' :module: target.inheritance', + '', + ' Inherited function.', + '', + '', + ' .. py:method:: Derived.inheritedstaticmeth(cls)', + ' :module: target.inheritance', + ' :staticmethod:', + '', + ' Inherited static method.', + '', + ] + + # disable autodoc_inherit_docstrings + app.config.autodoc_inherit_docstrings = False + actual = do_autodoc(app, 'class', 'target.inheritance.Derived', options) + assert list(actual) == [ + '', + '.. py:class:: Derived()', + ' :module: target.inheritance', + '', + '', + ' .. py:method:: Derived.inheritedclassmeth()', + ' :module: target.inheritance', + ' :classmethod:', + '', + ' Inherited class method.', + '', + '', + ' .. py:method:: Derived.inheritedstaticmeth(cls)', + ' :module: target.inheritance', + ' :staticmethod:', + '', + ' Inherited static method.', + '', + ] + + @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_docstring_signature(app): options = {"members": None, "special-members": "__init__, __new__"} From 709602437df850d5538a4fe899a50625c01a0f80 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 14 Jun 2022 03:05:49 +0900 Subject: [PATCH 16/18] Update CHANGES for PR #10539 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index a2597f277d7..86605f34b25 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,8 @@ Features added Bugs fixed ---------- +* #10538: autodoc: Inherited class attribute having docstring is documented even + if :confval:`autodoc_inherit_docstring` is disabled * #10509: autosummary: autosummary fails with a shared library * #10497: py domain: Failed to resolve strings in Literal. Patch by Adam Turner. * #10523: HTML Theme: Fix double brackets on citation references in Docutils 0.18+. From ed6970311349e54ceebe24ede255378fcd9d94e5 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 15 Jun 2022 02:37:05 +0900 Subject: [PATCH 17/18] Update CHANGES for PR #10535 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 86605f34b25..a5830628092 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ Bugs fixed * #10497: py domain: Failed to resolve strings in Literal. Patch by Adam Turner. * #10523: HTML Theme: Fix double brackets on citation references in Docutils 0.18+. Patch by Adam Turner. +* #10534: Missing CSS for nav.contents in Docutils 0.18+. Patch by Adam Turner. Testing -------- From 907d27dc6506c542c11a7dd16b560eb4be7da5fc Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 17 Jun 2022 02:17:08 +0900 Subject: [PATCH 18/18] Bump to 5.0.2 final --- CHANGES | 16 ++-------------- sphinx/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/CHANGES b/CHANGES index a5830628092..d2d98db75c8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,14 +1,5 @@ -Release 5.0.2 (in development) -============================== - -Dependencies ------------- - -Incompatible changes --------------------- - -Deprecated ----------- +Release 5.0.2 (released Jun 17, 2022) +===================================== Features added -------------- @@ -27,9 +18,6 @@ Bugs fixed Patch by Adam Turner. * #10534: Missing CSS for nav.contents in Docutils 0.18+. Patch by Adam Turner. -Testing --------- - Release 5.0.1 (released Jun 03, 2022) ===================================== diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 113dc8bfe89..1fb9714058c 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -21,7 +21,7 @@ warnings.filterwarnings('ignore', 'The frontend.Option class .*', DeprecationWarning, module='docutils.frontend') -__version__ = '5.0.2+' +__version__ = '5.0.2' __released__ = '5.0.2' # used when Sphinx builds its own docs #: Version info for better programmatic use. @@ -32,7 +32,7 @@ #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (5, 0, 2, 'beta', 0) +version_info = (5, 0, 2, 'final', 0) package_dir = path.abspath(path.dirname(__file__))