Skip to content

Commit

Permalink
fixup! Rename the :nowrap and :nosignatures: directive options
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 23, 2025
1 parent b0f8c58 commit f67b471
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion sphinx/directives/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
13 changes: 8 additions & 5 deletions sphinx/ext/autosummary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
The autosummary directive has the form::
.. autosummary::
:nosignatures:
:no-signatures:
:toctree: generated/
module.function_1
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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}>`'
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/mathjax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('</div>')
raise nodes.SkipNode
Expand Down
2 changes: 1 addition & 1 deletion sphinx/writers/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit f67b471

Please sign in to comment.