Skip to content

Commit 00607a9

Browse files
authored
Merge branch 'master' into use-anchor-for-search-previews
2 parents 7938764 + 707bfbd commit 00607a9

File tree

23 files changed

+395
-97
lines changed

23 files changed

+395
-97
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Features added
2727
* #11892: Improved performance when resolving cross references in cpp domain.
2828
Patch by Rouslan Korneychuk.
2929

30+
* #11981: Improve rendering of signatures using ``slice`` syntax,
31+
e.g., ``def foo(arg: np.float64[:,:]) -> None: ...``.
32+
3033
Bugs fixed
3134
----------
3235

@@ -77,6 +80,8 @@ Bugs fixed
7780
* #11925: Blacklist the ``sphinxprettysearchresults`` extension; the functionality
7881
it provides was merged into Sphinx v2.0.0.
7982
Patch by James Addison.
83+
* #11962: Fix target resolution when using ``:paramtype:`` fields.
84+
Patch by Bénédikt Tran.
8085

8186
Testing
8287
-------

EXAMPLES.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Documentation using the classic theme
6666
* `EZ-Draw <https://pageperso.lis-lab.fr/~edouard.thiel/ez-draw/doc/en/html/ez-manual.html>`__ (customized)
6767
* `Generic Mapping Tools (GMT) <https://gmt.soest.hawaii.edu/doc/latest/>`__ (customized)
6868
* `Genomedata <https://noble.gs.washington.edu/proj/genomedata/doc/1.3.3/>`__
69-
* `GetFEM++ <https://getfem.org/>`__ (customized)
69+
* `GetFEM <https://getfem.org/>`__ (customized)
7070
* `Glasgow Haskell Compiler <https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/>`__ (customized)
7171
* `Grok <https://web.archive.org/web/20230708190705/http://grok.zope.org/doc/current/>`__ (customized)
7272
* `GROMACS <https://manual.gromacs.org/documentation/>`__
@@ -132,7 +132,6 @@ Documentation using the nature theme
132132
* `libLAS <https://liblas.org/>`__ (customized)
133133
* `Lmod <https://lmod.readthedocs.io/>`__
134134
* `MapServer <https://mapserver.org/>`__ (customized)
135-
* `pyglet <https://pyglet.readthedocs.io/>`__ (customized)
136135
* `PyWavelets <https://pywavelets.readthedocs.io/>`__
137136
* `Setuptools <https://setuptools.readthedocs.io/>`__
138137
* `Spring Python <https://docs.spring.io/spring-python/1.2.x/sphinx/html/>`__
@@ -253,6 +252,7 @@ Documentation using sphinx_rtd_theme
253252
* `PROS <https://pros.cs.purdue.edu/v5/>`__ (customized)
254253
* `Pweave <https://mpastell.com/pweave/>`__
255254
* `pyca/cryptograhpy <https://cryptography.io/>`__
255+
* `pyglet <https://pyglet.readthedocs.io/>`__
256256
* `PyNaCl <https://pynacl.readthedocs.io/>`__
257257
* `pyOpenSSL <https://www.pyopenssl.org/>`__
258258
* `PyPy <https://doc.pypy.org/>`__

doc/usage/restructuredtext/roles.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ different style:
240240
:rst:role:`code` role instead.
241241

242242
.. versionchanged:: 1.8
243-
Allowed to escape curly braces with backslash
243+
Allowed to escape curly braces with double backslash. For example, in
244+
``:samp:`print(f"answer=\\{1+{variable}*2\\}")```, the part ``variable``
245+
would be emphasized and the escaped curly braces would be displayed:
246+
:samp:`print(f"answer=\\{1+{variable}*2\\}")`
244247

245248
There is also an :rst:role:`index` role to generate index entries.
246249

@@ -273,7 +276,7 @@ the standard reST markup for that purpose.
273276
Substitutions
274277
-------------
275278

276-
The documentation system provides three substitutions that are defined by
279+
The documentation system provides some substitutions that are defined by
277280
default. They are set in the build configuration file.
278281

279282
.. describe:: |release|

sphinx/environment/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@
8181

8282
if TYPE_CHECKING:
8383
from collections.abc import MutableMapping
84-
from typing import Literal
85-
86-
from typing_extensions import overload
84+
from typing import Literal, overload
8785

8886
from sphinx.domains.c import CDomain
8987
from sphinx.domains.changeset import ChangeSetDomain

sphinx/ext/napoleon/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def _patch_python_domain() -> None:
339339
PyObject.doc_field_types.append(
340340
PyTypedField('keyword', label=_('Keyword Arguments'),
341341
names=('keyword', 'kwarg', 'kwparam'),
342-
typerolename='obj', typenames=('paramtype', 'kwtype'),
342+
typerolename='class', typenames=('paramtype', 'kwtype'),
343343
can_collapse=True))
344344

345345

sphinx/pycode/ast.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ def visit_Name(self, node: ast.Name) -> str:
156156
def visit_Set(self, node: ast.Set) -> str:
157157
return "{" + ", ".join(self.visit(e) for e in node.elts) + "}"
158158

159+
def visit_Slice(self, node: ast.Slice) -> str:
160+
if not node.lower and not node.upper and not node.step:
161+
# Empty slice with default values -> [:]
162+
return ":"
163+
164+
start = self.visit(node.lower) if node.lower else ""
165+
stop = self.visit(node.upper) if node.upper else ""
166+
if not node.step:
167+
# Default step size -> [start:stop]
168+
return f"{start}:{stop}"
169+
170+
step = self.visit(node.step) if node.step else ""
171+
return f"{start}:{stop}:{step}"
172+
159173
def visit_Subscript(self, node: ast.Subscript) -> str:
160174
def is_simple_tuple(value: ast.expr) -> bool:
161175
return (

sphinx/search/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def get_terms(self, fn2index: dict[str, int]) -> tuple[dict[str, list[int] | int
377377
if fn in fn2index:
378378
rv[k] = fn2index[fn]
379379
else:
380-
rv[k] = sorted([fn2index[fn] for fn in v if fn in fn2index])
380+
rv[k] = sorted(fn2index[fn] for fn in v if fn in fn2index)
381381
return rvs
382382

383383
def freeze(self) -> dict[str, Any]:

sphinx/util/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def object_description(obj: Any, *, _seen: frozenset = frozenset()) -> str:
400400
if id(obj) in seen:
401401
return 'tuple(...)'
402402
seen |= frozenset([id(obj)])
403-
return '(%s%s)' % (
403+
return '({}{})'.format(
404404
', '.join(object_description(x, _seen=seen) for x in obj),
405405
',' * (len(obj) == 1),
406406
)

sphinx/writers/html5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ def depart_desc_type_parameter(self, node: Element) -> None:
247247
self.depart_desc_parameter(node)
248248

249249
def visit_desc_optional(self, node: Element) -> None:
250-
self.params_left_at_level = sum([isinstance(c, addnodes.desc_parameter)
251-
for c in node.children])
250+
self.params_left_at_level = sum(isinstance(c, addnodes.desc_parameter)
251+
for c in node.children)
252252
self.optional_param_level += 1
253253
self.max_optional_param_level = self.optional_param_level
254254
if self.multi_line_parameter_list:

sphinx/writers/latex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,8 @@ def depart_desc_type_parameter(self, node: Element) -> None:
911911
self._depart_sig_parameter(node)
912912

913913
def visit_desc_optional(self, node: Element) -> None:
914-
self.params_left_at_level = sum([isinstance(c, addnodes.desc_parameter)
915-
for c in node.children])
914+
self.params_left_at_level = sum(isinstance(c, addnodes.desc_parameter)
915+
for c in node.children)
916916
self.optional_param_level += 1
917917
self.max_optional_param_level = self.optional_param_level
918918
if self.multi_line_parameter_list:

0 commit comments

Comments
 (0)