mkdocstrings-python-xref 1.16.3__tar.gz → 1.16.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocstrings-python-xref
3
- Version: 1.16.3
3
+ Version: 1.16.4
4
4
  Summary: Enhanced mkdocstrings python handler
5
5
  Project-URL: Repository, https://github.com/analog-garage/mkdocstrings-python-xref
6
6
  Project-URL: Documentation, https://analog-garage.github.io/mkdocstrings-python-xref/
@@ -26,7 +26,7 @@ dynamic = ["version"]
26
26
  requires-python = ">=3.9"
27
27
  dependencies = [
28
28
  "mkdocstrings-python >=1.16.6,<2.0",
29
- "griffe >=1.0"
29
+ "griffe >=1.0",
30
30
  ]
31
31
 
32
32
  [project.urls]
@@ -47,7 +47,7 @@ dev = [
47
47
  "mike >=1.1",
48
48
  "mkdocs >=1.5.3,<2.0",
49
49
  "mkdocs-material >=9.5.4",
50
- "linkchecker >=10.4"
50
+ "linkchecker >=10.4",
51
51
  ]
52
52
 
53
53
  [tool.pixi.workspace]
@@ -71,6 +71,7 @@ mike = "*"
71
71
  mkdocs = "*"
72
72
  mkdocs-material = "*"
73
73
  linkchecker = "*"
74
+ twine = "*"
74
75
 
75
76
  [tool.pixi.pypi-dependencies]
76
77
  mkdocstrings-python-xref = { path = ".", editable = true }
@@ -222,30 +223,73 @@ disable = [
222
223
 
223
224
  [tool.pixi.tasks]
224
225
  # linting tasks
225
- mypy = "mypy"
226
- ruff = "ruff check src/mkdocstrings_handlers tests"
227
- lint = {depends-on = ["ruff", "mypy"]}
226
+ [tool.pixi.tasks.mypy]
227
+ description = "Run mypy type checking"
228
+ cmd = "mypy"
229
+
230
+ [tool.pixi.tasks.ruff]
231
+ description = "Run ruff linting on source code and tests"
232
+ cmd = "ruff check src/mkdocstrings_handlers tests"
233
+
234
+ [tool.pixi.tasks.lint]
235
+ description = "Run all linting tasks (ruff and mypy)"
236
+ depends-on = ["ruff", "mypy"]
228
237
 
229
238
  # testing tasks
230
- pytest = "pytest -sv -ra tests"
231
- test = {depends-on = ["pytest", "lint"]}
232
- coverage = "pytest -ra --cov --cov-report=html --cov-report=term -- tests"
233
- coverage-show = "python -m webbrowser file://$PIXI_PROJECT_ROOT/htmlcov/index.html"
239
+ [tool.pixi.tasks.pytest]
240
+ description = "Run pytest with verbose output"
241
+ cmd = "pytest -sv -ra tests"
242
+
243
+ [tool.pixi.tasks.test]
244
+ description = "Run tests and linting"
245
+ depends-on = ["pytest", "lint"]
246
+
247
+ [tool.pixi.tasks.coverage]
248
+ description = "Run tests with coverage reporting"
249
+ cmd = "pytest -ra --cov --cov-report=html --cov-report=term -- tests"
250
+
251
+ [tool.pixi.tasks.coverage-show]
252
+ description = "Open coverage report in web browser"
253
+ cmd = "python -m webbrowser file://$PIXI_PROJECT_ROOT/htmlcov/index.html"
234
254
 
235
255
  # doc tasks
236
- docs = {depends-on = ["doc"]}
237
- show-doc = "mkdocs serve -f mkdocs.yml"
238
- show-docs = {depends-on = ["show-doc"]}
256
+ [tool.pixi.tasks.docs]
257
+ description = "Build documentation"
258
+ depends-on = ["doc"]
259
+
260
+ [tool.pixi.tasks.show-doc]
261
+ description = "Serve documentation locally with live reload"
262
+ cmd = "mkdocs serve -f mkdocs.yml"
263
+
264
+ [tool.pixi.tasks.show-docs]
265
+ description = "Serve documentation locally (alias for show-doc)"
266
+ depends-on = ["show-doc"]
239
267
 
240
268
  # cleanup tasks
241
- clean-build = "rm -rf build dist"
242
- clean-coverage = "rm -rf .coverage .coverage.* htmlcov"
243
- clean-docs = "rm -rf site"
244
- clean-test = "rm -rf .pytest_cache .mypy_cache .ruff_cache"
245
- clean = {depends-on = ["clean-build", "clean-coverage", "clean-test"]}
269
+ [tool.pixi.tasks.clean-build]
270
+ description = "Remove build and distribution artifacts"
271
+ cmd = "rm -rf build dist"
272
+
273
+ [tool.pixi.tasks.clean-coverage]
274
+ description = "Remove coverage reports and cache files"
275
+ cmd = "rm -rf .coverage .coverage.* htmlcov"
276
+
277
+ [tool.pixi.tasks.clean-docs]
278
+ description = "Remove generated documentation site"
279
+ cmd = "rm -rf site"
280
+
281
+ [tool.pixi.tasks.clean-test]
282
+ description = "Remove test and linting cache directories"
283
+ cmd = "rm -rf .pytest_cache .mypy_cache .ruff_cache"
284
+
285
+ [tool.pixi.tasks.clean]
286
+ description = "Remove all build, coverage, and test artifacts"
287
+ depends-on = ["clean-build", "clean-coverage", "clean-test"]
246
288
 
247
289
  # build tasks
248
- build = {depends-on = ["build-wheel", "build-sdist", "build-conda"]}
290
+ [tool.pixi.tasks.build]
291
+ description = "Build all package formats (wheel, sdist, conda)"
292
+ depends-on = ["build-wheel", "build-sdist", "build-conda"]
249
293
 
250
294
  [tool.pixi.tasks.build-wheel]
251
295
  env = {VERSION = "$(cat src/mkdocstrings_handlers/python_xref/VERSION)"}
@@ -254,18 +298,71 @@ inputs = ["pyproject.toml", "LICENSE.md", "src/**/*"]
254
298
  outputs = ["dist/mkdocstrings_python_xref-$VERSION-py3-none-any.whl"]
255
299
 
256
300
  [tool.pixi.tasks.build-sdist]
257
- env = {VERSION = "$(cat src/mkdocstrings_handlers/python_xref/VERSION)"}
258
301
  cmd = "python -m build --sdist --no-isolation --outdir dist"
259
302
  inputs = ["pyproject.toml", "LICENSE.md", "src/**/*"]
260
- outputs = ["dist/mkdocstrings_pixipython_xref-$VERSION.tar.gz"]
303
+ outputs = ["dist/mkdocstrings_python_xref-*.tar.gz"]
261
304
 
262
305
  [tool.pixi.tasks.build-conda]
263
- #env = {VERSION = "$(cat src/mkdocstrings_handlers/python_xref/VERSION)"}
264
- cmd = "whl2conda convert dist/*.whl -w dist --overwrite"
306
+ description = "Build conda package from wheel"
307
+ env = {VERSION = "$(cat src/mkdocstrings_handlers/python_xref/VERSION)"}
308
+ cmd = "whl2conda convert dist/mkdocstrings_python_xref-$VERSION-py3-none-any.whl -w dist --overwrite"
265
309
  depends-on = ["build-wheel"]
266
- inputs = ["dist/mkdocstrings_python_xref-$VERSION-py3-none-any.whl"]
310
+ inputs = ["dist/mkdocstrings_python_xref-*-none-any.whl"]
311
+
312
+ # upload tasks
313
+ [tool.pixi.tasks.check-upload-wheel]
314
+ description = "Check wheel package for upload readiness using twine"
315
+ cmd = "twine check dist/*.whl"
316
+ depends-on = ["build-wheel"]
317
+
318
+ [tool.pixi.tasks.check-upload-sdist]
319
+ description = "Check source distribution for upload readiness using twine"
320
+ cmd = "twine check dist/*.tar.gz"
321
+ depends-on = ["build-sdist"]
322
+
323
+ [tool.pixi.tasks.check-upload]
324
+ description = "Check all packages for upload readiness"
325
+ depends-on = ["check-upload-sdist", "check-upload-wheel"]
326
+
327
+ [tool.pixi.tasks.upload-wheel]
328
+ description = "Upload wheel package to PyPI (skips existing versions)"
329
+ cmd = "twine upload --skip-existing dist/*.whl"
330
+ depends-on = ["check-upload-wheel"]
331
+
332
+ [tool.pixi.tasks.upload-sdist]
333
+ description = "Upload source distribution to PyPI (skips existing versions)"
334
+ cmd = "twine upload --skip-existing dist/*.tar.gz"
335
+ depends-on = ["check-upload-sdist"]
336
+
337
+ [tool.pixi.tasks.upload]
338
+ description = "Upload all packages to PyPI"
339
+ depends-on = ["upload-sdist", "upload-wheel"]
267
340
 
268
341
  [tool.pixi.tasks.doc]
342
+ description = "Build documentation site"
269
343
  cmd = "mkdocs build -f mkdocs.yml"
270
344
  inputs = ["docs/*.md", "docs/*.svg", "mkdocs.yml"]
271
345
  outputs = ["site/*.html"]
346
+
347
+ [tool.pixi.tasks.doc-strict]
348
+ description = "Build documentation and check for broken links"
349
+ cmd = "linkchecker site"
350
+ depends-on = ["doc"]
351
+ inputs = ["site/**"]
352
+
353
+ [tool.pixi.tasks.showdoc]
354
+ description = "Serve documentation locally (alias for show-doc)"
355
+ cmd = "mkdocs serve -f mkdocs.yml"
356
+
357
+ [tool.pixi.tasks.doc-serve-all]
358
+ description = "Serve all documentation versions using mike"
359
+ cmd = "mike serve -F mkdocs.yml"
360
+
361
+ [tool.pixi.tasks.doc-deploy]
362
+ env = {VERSION = "$(cat src/mkdocstrings_handlers/python_xref/VERSION)"}
363
+ description = "Deploy the current version to the gh-pages branch"
364
+ cmd = "mike deploy -F mkdocs.yml -u $VERSION latest & mike set-default -u $VERSION latest"
365
+
366
+ [tool.pixi.tasks.show-version]
367
+ env = {VERSION = "$(cat src/mkdocstrings_handlers/python_xref/VERSION)"}
368
+ cmd = "echo $VERSION"
@@ -20,7 +20,7 @@ import re
20
20
  import sys
21
21
  from typing import Any, Callable, List, Optional, cast
22
22
 
23
- from griffe import Docstring, Object
23
+ from griffe import Alias, Docstring, GriffeError, Object
24
24
  from mkdocstrings import get_logger
25
25
 
26
26
  __all__ = [
@@ -318,7 +318,10 @@ class _RelativeCrossrefProcessor:
318
318
  self._ok = just_warn
319
319
 
320
320
 
321
- def substitute_relative_crossrefs(obj: Object, checkref: Optional[Callable[[str], bool]] = None) -> None:
321
+ def substitute_relative_crossrefs(
322
+ obj: Alias|Object,
323
+ checkref: Optional[Callable[[str], bool]] = None,
324
+ ) -> None:
322
325
  """Recursively expand relative cross-references in all docstrings in tree.
323
326
 
324
327
  Arguments:
@@ -326,13 +329,21 @@ def substitute_relative_crossrefs(obj: Object, checkref: Optional[Callable[[str]
326
329
  checkref: optional function to check whether computed cross-reference is valid.
327
330
  Should return True if valid, False if not valid.
328
331
  """
332
+ if isinstance(obj, Alias):
333
+ try:
334
+ obj = obj.target
335
+ except GriffeError:
336
+ # If alias could not be resolved, it probably refers
337
+ # to an external package, not be documented.
338
+ return
339
+
329
340
  doc = obj.docstring
330
341
 
331
342
  if doc is not None:
332
343
  doc.value = _RE_CROSSREF.sub(_RelativeCrossrefProcessor(doc, checkref=checkref), doc.value)
333
344
 
334
345
  for member in obj.members.values():
335
- if isinstance(member, Object): # pragma: no branch
346
+ if isinstance(member, (Alias,Object)): # pragma: no branch
336
347
  substitute_relative_crossrefs(member, checkref=checkref)
337
348
 
338
349
  def doc_value_offset_to_location(doc: Docstring, offset: int) -> tuple[int,int]: