Skip to content

Commit 42f300e

Browse files
authored
Rename the :nowrap and :nosignatures: directive options (sphinx-doc#13264)
Rename the ``:nowrap`` and ``:nosignatures:`` directive options to ``:no-wrap`` and ``:no-signatures:``, for readability. This mirrors changes already made to `:no-index`, `:no-index-entry`, `:no-contents-entry`, and `:no-search` in Sphinx 7.2 and 7.3.
1 parent ca2ab35 commit 42f300e

File tree

11 files changed

+48
-13
lines changed

11 files changed

+48
-13
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ Features added
6060
:confval:`python_trailing_comma_in_multi_line_signatures` and
6161
:confval:`javascript_trailing_comma_in_multi_line_signatures`
6262
configuration options.
63+
* #13264: Rename the :rst:dir:`math` directive's ``nowrap``option
64+
to :rst:dir:`no-wrap``,
65+
and rename the :rst:dir:`autosummary` directive's ``nosignatures``option
66+
to :rst:dir:`no-signatures``.
67+
Patch by Adam Turner.
6368

6469
Bugs fixed
6570
----------

doc/usage/extensions/autosummary.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,20 @@ The :mod:`sphinx.ext.autosummary` extension does this in two parts:
102102
103103
.. versionadded:: 3.1
104104
105-
.. rst:directive:option:: nosignatures
105+
.. rst:directive:option:: no-signatures
106106
107107
Do not show function signatures in the summary.
108108
109109
.. versionadded:: 0.6
110110
111+
.. versionchanged:: 8.2
112+
113+
The directive option ``:nosignatures:`` was renamed to ``:no-signatures:``.
114+
115+
The previous name has been retained as an alias,
116+
but will be deprecated and removed
117+
in a future version of Sphinx.
118+
111119
.. rst:directive:option:: template: filename
112120
113121
Specify a custom template for rendering the summary.

doc/usage/restructuredtext/directives.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,21 +1553,29 @@ or use Python raw strings (``r"raw"``).
15531553
number to be issued. See :rst:role:`eq` for an example. The numbering
15541554
style depends on the output format.
15551555
1556-
.. rst:directive:option:: nowrap
1556+
.. rst:directive:option:: no-wrap
15571557
15581558
Prevent wrapping of the given math in a math environment.
15591559
When you give this option, you must make sure
15601560
yourself that the math is properly set up.
15611561
For example::
15621562
15631563
.. math::
1564-
:nowrap:
1564+
:no-wrap:
15651565
15661566
\begin{eqnarray}
15671567
y & = & ax^2 + bx + c \\
15681568
f(x) & = & x^2 + 2xy + y^2
15691569
\end{eqnarray}
15701570
1571+
.. versionchanged:: 8.2
1572+
1573+
The directive option ``:nowrap:`` was renamed to ``:no-wrap:``.
1574+
1575+
The previous name has been retained as an alias,
1576+
but will be deprecated and removed
1577+
in a future version of Sphinx.
1578+
15711579
.. _AmSMath LaTeX package: https://www.ams.org/publications/authors/tex/amslatex
15721580

15731581
.. seealso::

sphinx/directives/patches.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@ class MathDirective(SphinxDirective):
143143
'label': directives.unchanged,
144144
'name': directives.unchanged,
145145
'class': directives.class_option,
146+
'no-wrap': directives.flag,
146147
'nowrap': directives.flag,
147148
}
148149

149150
def run(self) -> list[Node]:
151+
# Copy the old option name to the new one
152+
# xref RemovedInSphinx90Warning
153+
# deprecate nowrap in Sphinx 9.0
154+
if 'no-wrap' not in self.options and 'nowrap' in self.options:
155+
self.options['no-wrap'] = self.options['nowrap']
156+
150157
latex = '\n'.join(self.content)
151158
if self.arguments and self.arguments[0]:
152159
latex = self.arguments[0] + '\n\n' + latex
@@ -158,8 +165,8 @@ def run(self) -> list[Node]:
158165
docname=self.env.docname,
159166
number=None,
160167
label=label,
161-
nowrap='nowrap' in self.options,
162168
)
169+
node['no-wrap'] = node['nowrap'] = 'no-wrap' in self.options
163170
self.add_name(node)
164171
self.set_source_info(node)
165172

sphinx/ext/autosummary/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
The autosummary directive has the form::
1212
1313
.. autosummary::
14-
:nosignatures:
14+
:no-signatures:
1515
:toctree: generated/
1616
1717
module.function_1
@@ -237,12 +237,19 @@ class Autosummary(SphinxDirective):
237237
'caption': directives.unchanged_required,
238238
'class': directives.class_option,
239239
'toctree': directives.unchanged,
240-
'nosignatures': directives.flag,
240+
'no-signatures': directives.flag,
241241
'recursive': directives.flag,
242242
'template': directives.unchanged,
243+
'nosignatures': directives.flag,
243244
}
244245

245246
def run(self) -> list[Node]:
247+
# Copy the old option name to the new one
248+
# xref RemovedInSphinx90Warning
249+
# deprecate nosignatures in Sphinx 9.0
250+
if 'no-signatures' not in self.options and 'nosignatures' in self.options:
251+
self.options['no-signatures'] = self.options['nosignatures']
252+
246253
self.bridge = DocumenterBridge(
247254
self.env, self.state.document.reporter, Options(), self.lineno, self.state
248255
)
@@ -462,7 +469,7 @@ def append_row(*column_texts: str) -> None:
462469

463470
for name, sig, summary, real_name in items:
464471
qualifier = 'obj'
465-
if 'nosignatures' not in self.options:
472+
if 'no-signatures' not in self.options:
466473
col1 = f':py:{qualifier}:`{name} <{real_name}>`\\ {rst.escape(sig)}'
467474
else:
468475
col1 = f':py:{qualifier}:`{name} <{real_name}>`'

sphinx/ext/imgmath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def html_visit_math(self: HTML5Translator, node: nodes.math) -> None:
366366

367367

368368
def html_visit_displaymath(self: HTML5Translator, node: nodes.math_block) -> None:
369-
if node['nowrap']:
369+
if node['no-wrap'] or node['nowrap']:
370370
latex = node.astext()
371371
else:
372372
latex = wrap_displaymath(node.astext(), None, False)

sphinx/ext/mathjax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def html_visit_math(self: HTML5Translator, node: nodes.math) -> None:
4747

4848
def html_visit_displaymath(self: HTML5Translator, node: nodes.math_block) -> None:
4949
self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight'))
50-
if node['nowrap']:
50+
if node['no-wrap']:
5151
self.body.append(self.encode(node.astext()))
5252
self.body.append('</div>')
5353
raise nodes.SkipNode

sphinx/writers/latex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2465,7 +2465,7 @@ def visit_math_block(self, node: nodes.math_block) -> None:
24652465
else:
24662466
label = None
24672467

2468-
if node.get('nowrap'):
2468+
if node.get('no-wrap'):
24692469
if label:
24702470
self.body.append(r'\label{%s}' % label)
24712471
self.body.append(node.astext())

tests/roots/test-ext-autosummary-ext/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
.. autosummary::
3-
:nosignatures:
3+
:no-signatures:
44
:toctree:
55

66
dummy_module

tests/roots/test-ext-math/math.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This is inline math: :math:`a^2 + b^2 = c^2`.
2424
n \in \mathbb N
2525
2626
.. math::
27-
:nowrap:
27+
:no-wrap:
2828
2929
a + 1 < b
3030

0 commit comments

Comments
 (0)