From e439c6f33f8d8e7bc06b4f6f25dadfda74869ee0 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Fri, 19 Jul 2024 08:38:52 +0100 Subject: [PATCH] Ensure that old-style object description options are respected (#12620) --- CHANGES.rst | 2 ++ sphinx/directives/__init__.py | 23 ++++++++++++++--------- sphinx/domains/javascript.py | 2 +- sphinx/domains/python/__init__.py | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index db054a86271..1e7d811b48f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Bugs fixed * #12096: Warn when files are overwritten in the build directory. Patch by Adam Turner. +* #12620: Ensure that old-style object description options are respected. + Patch by Adam Turner. Release 7.4.6 (released Jul 18, 2024) ===================================== diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index a9699f168ad..0c0c0cc519b 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -220,21 +220,26 @@ def run(self) -> list[Node]: node['domain'] = self.domain # 'desctype' is a backwards compatible attribute node['objtype'] = node['desctype'] = self.objtype + + # Copy old option names to new ones + # xref RemovedInSphinx90Warning + # deprecate noindex, noindexentry, and nocontentsentry in Sphinx 9.0 + if 'no-index' not in self.options and 'noindex' in self.options: + self.options['no-index'] = self.options['noindex'] + if 'no-index-entry' not in self.options and 'noindexentry' in self.options: + self.options['no-index-entry'] = self.options['noindexentry'] + if 'no-contents-entry' not in self.options and 'nocontentsentry' in self.options: + self.options['no-contents-entry'] = self.options['nocontentsentry'] + node['no-index'] = node['noindex'] = no_index = ( 'no-index' in self.options - # xref RemovedInSphinx90Warning - # deprecate noindex in Sphinx 9.0 - or 'noindex' in self.options) + ) node['no-index-entry'] = node['noindexentry'] = ( 'no-index-entry' in self.options - # xref RemovedInSphinx90Warning - # deprecate noindexentry in Sphinx 9.0 - or 'noindexentry' in self.options) + ) node['no-contents-entry'] = node['nocontentsentry'] = ( 'no-contents-entry' in self.options - # xref RemovedInSphinx90Warning - # deprecate nocontentsentry in Sphinx 9.0 - or 'nocontentsentry' in self.options) + ) node['no-typesetting'] = ('no-typesetting' in self.options) if self.domain: node['classes'].append(self.domain) diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py index 4a65945e08e..540b7a6c68e 100644 --- a/sphinx/domains/javascript.py +++ b/sphinx/domains/javascript.py @@ -309,7 +309,7 @@ class JSModule(SphinxDirective): def run(self) -> list[Node]: mod_name = self.arguments[0].strip() self.env.ref_context['js:module'] = mod_name - no_index = 'no-index' in self.options or 'noindex' in self.options + no_index = 'no-index' in self.options content_nodes = self.parse_content_to_nodes(allow_section_headings=True) diff --git a/sphinx/domains/python/__init__.py b/sphinx/domains/python/__init__.py index 8f1c7d6d22d..ad189f474d1 100644 --- a/sphinx/domains/python/__init__.py +++ b/sphinx/domains/python/__init__.py @@ -452,7 +452,7 @@ def run(self) -> list[Node]: domain = cast(PythonDomain, self.env.get_domain('py')) modname = self.arguments[0].strip() - no_index = 'no-index' in self.options or 'noindex' in self.options + no_index = 'no-index' in self.options self.env.ref_context['py:module'] = modname content_nodes = self.parse_content_to_nodes(allow_section_headings=True)