From f67b47126ecc3c69647332944f6279f40b45001e Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 23 Jan 2025 04:23:16 +0000 Subject: [PATCH] fixup! Rename the ``:nowrap`` and ``:nosignatures:`` directive options --- sphinx/directives/patches.py | 8 +++++++- sphinx/ext/autosummary/__init__.py | 13 ++++++++----- sphinx/ext/mathjax.py | 2 +- sphinx/writers/latex.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 0d52fe96b4c..94184de502c 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -148,6 +148,12 @@ class MathDirective(SphinxDirective): } def run(self) -> list[Node]: + # Copy the old option name to the new one + # xref RemovedInSphinx90Warning + # deprecate nowrap in Sphinx 9.0 + if 'no-wrap' not in self.options and 'nowrap' in self.options: + self.options['no-wrap'] = self.options['nowrap'] + latex = '\n'.join(self.content) if self.arguments and self.arguments[0]: latex = self.arguments[0] + '\n\n' + latex @@ -159,8 +165,8 @@ def run(self) -> list[Node]: docname=self.env.docname, number=None, label=label, - nowrap='no-wrap' in self.options or 'nowrap' in self.options, ) + node['no-wrap'] = node['nowrap'] = 'no-wrap' in self.options self.add_name(node) self.set_source_info(node) diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 46f765d0c16..ff83a4b1f0c 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -11,7 +11,7 @@ The autosummary directive has the form:: .. autosummary:: - :nosignatures: + :no-signatures: :toctree: generated/ module.function_1 @@ -244,6 +244,12 @@ class Autosummary(SphinxDirective): } def run(self) -> list[Node]: + # Copy the old option name to the new one + # xref RemovedInSphinx90Warning + # deprecate nosignatures in Sphinx 9.0 + if 'no-signatures' not in self.options and 'nosignatures' in self.options: + self.options['no-signatures'] = self.options['nosignatures'] + self.bridge = DocumenterBridge( self.env, self.state.document.reporter, Options(), self.lineno, self.state ) @@ -463,10 +469,7 @@ def append_row(*column_texts: str) -> None: for name, sig, summary, real_name in items: qualifier = 'obj' - if ( - 'no-signatures' not in self.options - and 'nosignatures' not in self.options - ): + if 'no-signatures' not in self.options: col1 = f':py:{qualifier}:`{name} <{real_name}>`\\ {rst.escape(sig)}' else: col1 = f':py:{qualifier}:`{name} <{real_name}>`' diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py index 99f9e173eee..b3592263690 100644 --- a/sphinx/ext/mathjax.py +++ b/sphinx/ext/mathjax.py @@ -47,7 +47,7 @@ def html_visit_math(self: HTML5Translator, node: nodes.math) -> None: def html_visit_displaymath(self: HTML5Translator, node: nodes.math_block) -> None: self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) - if node['no-wrap'] or node['nowrap']: + if node['no-wrap']: self.body.append(self.encode(node.astext())) self.body.append('') raise nodes.SkipNode diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 8f9f6998f63..c6a78344059 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -2465,7 +2465,7 @@ def visit_math_block(self, node: nodes.math_block) -> None: else: label = None - if node.get('no-wrap', False) or node.get('nowrap', False): + if node.get('no-wrap'): if label: self.body.append(r'\label{%s}' % label) self.body.append(node.astext())