mkdocstrings-python 1.14.6__py3-none-any.whl → 1.15.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -305,6 +305,11 @@ class PythonHandler(BaseHandler):
305
305
  self.env.tests["existing_template"] = lambda template_name: template_name in self.env.list_templates()
306
306
 
307
307
  def get_aliases(self, identifier: str) -> tuple[str, ...]: # noqa: D102 (ignore missing docstring)
308
+ if "(" in identifier:
309
+ identifier, parameter = identifier.split("(", 1)
310
+ parameter.removesuffix(")")
311
+ else:
312
+ parameter = ""
308
313
  try:
309
314
  data = self._modules_collection[identifier]
310
315
  except (KeyError, AliasResolutionError):
@@ -315,7 +320,9 @@ class PythonHandler(BaseHandler):
315
320
  if alias not in aliases:
316
321
  aliases.append(alias)
317
322
  except AliasResolutionError:
318
- return tuple(aliases)
323
+ pass
324
+ if parameter:
325
+ return tuple(f"{alias}({parameter})" for alias in aliases)
319
326
  return tuple(aliases)
320
327
 
321
328
  def normalize_extension_paths(self, extensions: Sequence) -> Sequence:
@@ -32,7 +32,7 @@ from mkdocs_autorefs.references import AutorefsHookInterface
32
32
  from mkdocstrings.loggers import get_logger
33
33
 
34
34
  if TYPE_CHECKING:
35
- from collections.abc import Sequence
35
+ from collections.abc import Iterator, Sequence
36
36
 
37
37
  from griffe import Attribute, Class, Function, Module
38
38
  from jinja2 import Environment, Template
@@ -326,26 +326,47 @@ def do_multi_crossref(text: str, *, code: bool = True) -> Markup:
326
326
  return Markup(text).format(**variables)
327
327
 
328
328
 
329
- def do_split_path(path: str, full_path: str) -> list[tuple[str, str]]:
329
+ _split_path_re = re.compile(r"([.(]?)([\w]+)(\))?")
330
+ _splitable_re = re.compile(r"[().]")
331
+
332
+
333
+ def do_split_path(path: str, full_path: str) -> Iterator[tuple[str, str, str, str]]:
330
334
  """Split object paths for building cross-references.
331
335
 
332
336
  Parameters:
333
337
  path: The path to split.
338
+ full_path: The full path, used to compute correct paths for each part of the path.
334
339
 
335
- Returns:
336
- A list of pairs (title, full path).
340
+ Yields:
341
+ 4-tuples: prefix, word, full path, suffix.
337
342
  """
338
- if "." not in path:
339
- return [(path, full_path)]
340
- pairs = []
341
- full_path = ""
342
- for part in path.split("."):
343
- if full_path:
344
- full_path += f".{part}"
345
- else:
346
- full_path = part
347
- pairs.append((part, full_path))
348
- return pairs
343
+ # Path is a single word, yield full path directly.
344
+ if not _splitable_re.search(path):
345
+ yield ("", path, full_path, "")
346
+ return
347
+
348
+ current_path = ""
349
+ if path == full_path:
350
+ # Split full path and yield directly without storing data in a dict.
351
+ for match in _split_path_re.finditer(full_path):
352
+ prefix, word, suffix = match.groups()
353
+ current_path = f"{current_path}{prefix}{word}{suffix or ''}" if current_path else word
354
+ yield prefix or "", word, current_path, suffix or ""
355
+ return
356
+
357
+ # Split full path first to store tuples in a dict.
358
+ elements = {}
359
+ for match in _split_path_re.finditer(full_path):
360
+ prefix, word, suffix = match.groups()
361
+ current_path = f"{current_path}{prefix}{word}{suffix or ''}" if current_path else word
362
+ elements[word] = (prefix or "", word, current_path, suffix or "")
363
+
364
+ # Then split path and pick tuples from the dict.
365
+ first = True
366
+ for match in _split_path_re.finditer(path):
367
+ prefix, word, current_path, suffix = elements[match.group(2)]
368
+ yield "" if first else prefix, word, current_path, suffix
369
+ first = False
349
370
 
350
371
 
351
372
  def _keep_object(name: str, filters: Sequence[tuple[Pattern, bool]]) -> bool:
@@ -31,7 +31,8 @@ which is a tree-like structure representing a Python expression.
31
31
  {%- elif annotation_path == "full" -%}
32
32
  {%- set annotation = full -%}
33
33
  {%- endif -%}
34
- {%- for title, path in annotation|split_path(full) -%}
34
+ {%- for prefix, title, path, suffix in annotation|split_path(full) -%}
35
+ {{ prefix }}
35
36
  {%- if not signature -%}
36
37
  {#- Always render cross-references outside of signatures. We don't need to stash them. -#}
37
38
  <autoref identifier="{{ path }}" optional{% if title != path %} hover{% endif %}>{{ title }}</autoref>
@@ -44,7 +45,7 @@ which is a tree-like structure representing a Python expression.
44
45
  {#- We're in a signature but cross-references are disabled, we just render the title. -#}
45
46
  {{ title }}
46
47
  {%- endif -%}
47
- {%- if not loop.last -%}.{%- endif -%}
48
+ {{ suffix }}
48
49
  {%- endfor -%}
49
50
  {%- endwith -%}
50
51
  {%- endmacro -%}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mkdocstrings-python
3
- Version: 1.14.6
3
+ Version: 1.15.0
4
4
  Summary: A Python handler for mkdocstrings.
5
5
  Author-Email: =?utf-8?q?Timoth=C3=A9e_Mazzucotelli?= <dev@pawamoy.fr>
6
6
  License: ISC
@@ -150,9 +150,9 @@ mkdocstrings_handlers/python/.mypy_cache/CACHEDIR.TAG,sha256=8cE6_FVTWMkDOw8fMKq
150
150
  mkdocstrings_handlers/python/__init__.py,sha256=k-0NWvXysr5RqWjtGyCozookveBB-ADZHIhgxvI1px8,128
151
151
  mkdocstrings_handlers/python/config.py,sha256=dZTBl2BbEyVc_o8PW0rReWHDzdqYstOP7fnlWioRVk0,31459
152
152
  mkdocstrings_handlers/python/debug.py,sha256=4vqIbCbbz_vcjcFk6jPoF8E1kLig8AQEsQ93ybcjIVc,2894
153
- mkdocstrings_handlers/python/handler.py,sha256=05cu68blsknnR_KCgiHVnyUeDQMcuP57zgiZSHZeReI,14601
153
+ mkdocstrings_handlers/python/handler.py,sha256=0ap57utWbw6o4LWLhZOQWsr_H4Fr7t1zcCmV6xfqY-w,14849
154
154
  mkdocstrings_handlers/python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
155
- mkdocstrings_handlers/python/rendering.py,sha256=rxK3GMaw_kyx8xA2b_LM9H54j746eAz6gbGf7RnGW-A,21946
155
+ mkdocstrings_handlers/python/rendering.py,sha256=DuNV-cI2Tie574yItj6CiE95THbKOxpZE0uvl50iGmI,23054
156
156
  mkdocstrings_handlers/python/templates/material/_base/attribute.html,sha256=nn0671f4bE7VqnTs-VQL3SGPACWAxb2uJBRcP2nwYng,427
157
157
  mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja,sha256=sbbkQtl5bPm5mmmZ-VCyLtfsOuhSr-FrD2FUSlbK-Zs,4451
158
158
  mkdocstrings_handlers/python/templates/material/_base/children.html,sha256=mOafkSlphFQJLWfrYrIMFVRGi2yjdtN6iJh8bPt7uRI,424
@@ -188,7 +188,7 @@ mkdocstrings_handlers/python/templates/material/_base/docstring/warns.html.jinja
188
188
  mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html,sha256=-aNSOHi5lvqheUzklSRThN7UeCdsqTHm35CyKi5yaWU,448
189
189
  mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html.jinja,sha256=2J1tK2lSTUHYOnOnqeX_I_LWMAOh2dZGbIvifKKt46c,4589
190
190
  mkdocstrings_handlers/python/templates/material/_base/expression.html,sha256=JU-ScDWoFk0m6x0Dx50LKN9yW7RzTWj4VYcJYEIQ144,430
191
- mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja,sha256=sdK6-0ars0CuX8Jsf7pPKP1YoPQV8NBSl9qDncQTFaA,4384
191
+ mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja,sha256=kfvwxwW6BrHLAEd-h7YOUWMu4lFaOrUEPvt9sD_y0G0,4393
192
192
  mkdocstrings_handlers/python/templates/material/_base/function.html,sha256=tFpXIt5sIhjXjTCXhtYZ4cGpbgdbaIdbm8HdP9Pccik,424
193
193
  mkdocstrings_handlers/python/templates/material/_base/function.html.jinja,sha256=KyiqTv51KNJmItZmdzV0BuUsr341yKn4um7exYkJ2Is,5718
194
194
  mkdocstrings_handlers/python/templates/material/_base/labels.html,sha256=SJGvRoTYj9AImTRRn-SP4nGAdpfz-ai4gGgHGxMOJK8,418
@@ -327,8 +327,8 @@ mkdocstrings_handlers/python/templates/readthedocs/languages/ja.html.jinja,sha25
327
327
  mkdocstrings_handlers/python/templates/readthedocs/languages/zh.html,sha256=OuvrkorxuL0gKZNYneann1bwd1Z2i5bBY7SbC496HDw,46
328
328
  mkdocstrings_handlers/python/templates/readthedocs/languages/zh.html.jinja,sha256=OuvrkorxuL0gKZNYneann1bwd1Z2i5bBY7SbC496HDw,46
329
329
  mkdocstrings_handlers/python/templates/readthedocs/style.css,sha256=Ds8vF1rSxc2B0c4P10osx4cqXHWMntcSCxmRfX-nfzw,971
330
- mkdocstrings_python-1.14.6.dist-info/METADATA,sha256=g2HXnCzLjLHuwqo76VSQIGJXNSBmTYVzJ-2XUhU7Vew,5570
331
- mkdocstrings_python-1.14.6.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
332
- mkdocstrings_python-1.14.6.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
333
- mkdocstrings_python-1.14.6.dist-info/licenses/LICENSE,sha256=JGb4pdPEM8TTjjhr-uNCO7oXkiVrwG5Pz0JamcjNF_s,754
334
- mkdocstrings_python-1.14.6.dist-info/RECORD,,
330
+ mkdocstrings_python-1.15.0.dist-info/METADATA,sha256=RHYBPgd4y65iKIORXsqIBrJoP1wuOkvFG_Dq1kE5YS4,5570
331
+ mkdocstrings_python-1.15.0.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
332
+ mkdocstrings_python-1.15.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
333
+ mkdocstrings_python-1.15.0.dist-info/licenses/LICENSE,sha256=JGb4pdPEM8TTjjhr-uNCO7oXkiVrwG5Pz0JamcjNF_s,754
334
+ mkdocstrings_python-1.15.0.dist-info/RECORD,,