pdoc 14.6.1__py3-none-any.whl → 14.7.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.
- pdoc/__init__.py +1 -1
- pdoc/doc.py +14 -4
- pdoc/doc_ast.py +8 -8
- pdoc/render_helpers.py +15 -6
- pdoc/templates/default/module.html.jinja2 +1 -1
- {pdoc-14.6.1.dist-info → pdoc-14.7.0.dist-info}/METADATA +15 -14
- {pdoc-14.6.1.dist-info → pdoc-14.7.0.dist-info}/RECORD +11 -11
- {pdoc-14.6.1.dist-info → pdoc-14.7.0.dist-info}/WHEEL +1 -1
- {pdoc-14.6.1.dist-info → pdoc-14.7.0.dist-info}/LICENSE +0 -0
- {pdoc-14.6.1.dist-info → pdoc-14.7.0.dist-info}/entry_points.txt +0 -0
- {pdoc-14.6.1.dist-info → pdoc-14.7.0.dist-info}/top_level.txt +0 -0
pdoc/__init__.py
CHANGED
@@ -481,7 +481,7 @@ You can find an example in [`examples/library-usage`](https://github.com/mitmpro
|
|
481
481
|
from __future__ import annotations
|
482
482
|
|
483
483
|
__docformat__ = "markdown" # explicitly disable rST processing in the examples above.
|
484
|
-
__version__ = "14.
|
484
|
+
__version__ = "14.7.0" # this is read from setup.py
|
485
485
|
|
486
486
|
from pathlib import Path
|
487
487
|
from typing import overload
|
pdoc/doc.py
CHANGED
@@ -1132,9 +1132,11 @@ class Variable(Doc[None]):
|
|
1132
1132
|
if self.default_value is empty:
|
1133
1133
|
return ""
|
1134
1134
|
if isinstance(self.default_value, TypeAliasType):
|
1135
|
-
|
1135
|
+
formatted = formatannotation(self.default_value.__value__)
|
1136
|
+
return _remove_collections_abc(formatted)
|
1136
1137
|
elif self.annotation == TypeAlias:
|
1137
|
-
|
1138
|
+
formatted = formatannotation(self.default_value)
|
1139
|
+
return _remove_collections_abc(formatted)
|
1138
1140
|
|
1139
1141
|
# This is not perfect, but a solid attempt at preventing accidental leakage of secrets.
|
1140
1142
|
# If you have input on how to improve the heuristic, please send a pull request!
|
@@ -1166,7 +1168,8 @@ class Variable(Doc[None]):
|
|
1166
1168
|
def annotation_str(self) -> str:
|
1167
1169
|
"""The variable's type annotation as a pretty-printed str."""
|
1168
1170
|
if self.annotation is not empty:
|
1169
|
-
|
1171
|
+
formatted = formatannotation(self.annotation)
|
1172
|
+
return f": {_remove_collections_abc(formatted)}"
|
1170
1173
|
else:
|
1171
1174
|
return ""
|
1172
1175
|
|
@@ -1202,6 +1205,7 @@ class _PrettySignature(inspect.Signature):
|
|
1202
1205
|
for param in self.parameters.values():
|
1203
1206
|
formatted = str(param)
|
1204
1207
|
formatted = _remove_memory_addresses(formatted)
|
1208
|
+
formatted = _remove_collections_abc(formatted)
|
1205
1209
|
|
1206
1210
|
kind = param.kind
|
1207
1211
|
|
@@ -1238,7 +1242,8 @@ class _PrettySignature(inspect.Signature):
|
|
1238
1242
|
|
1239
1243
|
def _return_annotation_str(self) -> str:
|
1240
1244
|
if self.return_annotation is not empty:
|
1241
|
-
|
1245
|
+
formatted = formatannotation(self.return_annotation)
|
1246
|
+
return _remove_collections_abc(formatted)
|
1242
1247
|
else:
|
1243
1248
|
return ""
|
1244
1249
|
|
@@ -1333,3 +1338,8 @@ _Enum_default_docstrings = tuple(
|
|
1333
1338
|
def _remove_memory_addresses(x: str) -> str:
|
1334
1339
|
"""Remove memory addresses from repr() output"""
|
1335
1340
|
return re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", x)
|
1341
|
+
|
1342
|
+
|
1343
|
+
def _remove_collections_abc(x: str) -> str:
|
1344
|
+
"""Remove 'collections.abc' from type signatures."""
|
1345
|
+
return re.sub(r"(?!\.)\bcollections\.abc\.", "", x)
|
pdoc/doc_ast.py
CHANGED
@@ -240,12 +240,11 @@ def _parse_class(source: str) -> ast.ClassDef:
|
|
240
240
|
Returns an empty ast.ClassDef if source is empty.
|
241
241
|
"""
|
242
242
|
tree = _parse(source)
|
243
|
-
|
244
|
-
if tree.body:
|
243
|
+
if tree.body and len(tree.body) == 1:
|
245
244
|
t = tree.body[0]
|
246
|
-
|
247
|
-
|
248
|
-
return ast.ClassDef(body=[], decorator_list=[]) # type: ignore
|
245
|
+
if isinstance(t, ast.ClassDef):
|
246
|
+
return t
|
247
|
+
return ast.ClassDef(name="PdocStub", body=[], decorator_list=[]) # type: ignore
|
249
248
|
|
250
249
|
|
251
250
|
@cache
|
@@ -256,8 +255,7 @@ def _parse_function(source: str) -> ast.FunctionDef | ast.AsyncFunctionDef:
|
|
256
255
|
Returns an empty ast.FunctionDef if source is empty.
|
257
256
|
"""
|
258
257
|
tree = _parse(source)
|
259
|
-
|
260
|
-
if tree.body:
|
258
|
+
if tree.body and len(tree.body) == 1:
|
261
259
|
t = tree.body[0]
|
262
260
|
if isinstance(t, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
263
261
|
return t
|
@@ -265,7 +263,9 @@ def _parse_function(source: str) -> ast.FunctionDef | ast.AsyncFunctionDef:
|
|
265
263
|
# we have a lambda function,
|
266
264
|
# to simplify the API return the ast.FunctionDef stub.
|
267
265
|
pass
|
268
|
-
return ast.FunctionDef(
|
266
|
+
return ast.FunctionDef(
|
267
|
+
name="pdoc_stub", args=ast.arguments(), body=[], decorator_list=[]
|
268
|
+
) # type: ignore
|
269
269
|
|
270
270
|
|
271
271
|
def _parse(
|
pdoc/render_helpers.py
CHANGED
@@ -307,11 +307,17 @@ def module_candidates(identifier: str, current_module: str) -> Iterable[str]:
|
|
307
307
|
|
308
308
|
|
309
309
|
@pass_context
|
310
|
-
def linkify(
|
310
|
+
def linkify(
|
311
|
+
context: Context, code: str, namespace: str = "", shorten: bool = True
|
312
|
+
) -> str:
|
311
313
|
"""
|
312
314
|
Link all identifiers in a block of text. Identifiers referencing unknown modules or modules that
|
313
315
|
are not rendered at the moment will be ignored.
|
314
316
|
A piece of text is considered to be an identifier if it either contains a `.` or is surrounded by `<code>` tags.
|
317
|
+
|
318
|
+
If `shorten` is True, replace identifiers with short forms where possible.
|
319
|
+
For example, replace "current_module.Foo" with "Foo". This is useful for annotations
|
320
|
+
(which are verbose), but undesired for docstrings (where we want to preserve intent).
|
315
321
|
"""
|
316
322
|
|
317
323
|
def linkify_repl(m: re.Match):
|
@@ -381,12 +387,15 @@ def linkify(context: Context, code: str, namespace: str = "") -> str:
|
|
381
387
|
and (target_object is doc.obj or target_object is None)
|
382
388
|
and context["is_public"](doc).strip()
|
383
389
|
):
|
384
|
-
if
|
385
|
-
|
390
|
+
if shorten:
|
391
|
+
if module == mod:
|
392
|
+
url_text = qualname
|
393
|
+
else:
|
394
|
+
url_text = doc.fullname
|
395
|
+
if plain_text.endswith("()"):
|
396
|
+
url_text += "()"
|
386
397
|
else:
|
387
|
-
url_text =
|
388
|
-
if plain_text.endswith("()"):
|
389
|
-
url_text += "()"
|
398
|
+
url_text = plain_text
|
390
399
|
return f'<a href="{relative_link(context["module"].modulename, doc.modulename)}#{qualname}">{url_text}</a>'
|
391
400
|
|
392
401
|
# No matches found.
|
@@ -209,7 +209,7 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
|
|
209
209
|
{% enddefaultmacro %}
|
210
210
|
{% defaultmacro docstring(var) %}
|
211
211
|
{% if var.docstring %}
|
212
|
-
<div class="docstring">{{ var.docstring | replace("@public", "") | to_markdown | to_html | linkify(namespace=var.qualname) }}</div>
|
212
|
+
<div class="docstring">{{ var.docstring | replace("@public", "") | to_markdown | to_html | linkify(namespace=var.qualname, shorten=False) }}</div>
|
213
213
|
{% endif %}
|
214
214
|
{% enddefaultmacro %}
|
215
215
|
{% defaultmacro nav_members(members) %}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pdoc
|
3
|
-
Version: 14.
|
3
|
+
Version: 14.7.0
|
4
4
|
Summary: API Documentation for Python Projects
|
5
5
|
Author-email: Maximilian Hils <pdoc@maximilianhils.com>
|
6
6
|
License: MIT-0
|
@@ -21,25 +21,26 @@ Classifier: Programming Language :: Python :: 3.9
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.10
|
22
22
|
Classifier: Programming Language :: Python :: 3.11
|
23
23
|
Classifier: Programming Language :: Python :: 3.12
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
24
25
|
Classifier: Typing :: Typed
|
25
26
|
Requires-Python: >=3.8
|
26
27
|
Description-Content-Type: text/markdown
|
27
28
|
License-File: LICENSE
|
28
|
-
Requires-Dist: Jinja2
|
29
|
-
Requires-Dist: pygments
|
29
|
+
Requires-Dist: Jinja2>=2.11.0
|
30
|
+
Requires-Dist: pygments>=2.12.0
|
30
31
|
Requires-Dist: MarkupSafe
|
31
|
-
Requires-Dist: astunparse
|
32
|
+
Requires-Dist: astunparse; python_version < "3.9"
|
32
33
|
Provides-Extra: dev
|
33
|
-
Requires-Dist: tox
|
34
|
-
Requires-Dist: ruff
|
35
|
-
Requires-Dist: mypy
|
36
|
-
Requires-Dist: types-pygments
|
37
|
-
Requires-Dist: pytest
|
38
|
-
Requires-Dist: pytest-cov
|
39
|
-
Requires-Dist: pytest-timeout
|
40
|
-
Requires-Dist: hypothesis
|
41
|
-
Requires-Dist: pygments
|
42
|
-
Requires-Dist: pdoc-pyo3-sample-library
|
34
|
+
Requires-Dist: tox; extra == "dev"
|
35
|
+
Requires-Dist: ruff; extra == "dev"
|
36
|
+
Requires-Dist: mypy; extra == "dev"
|
37
|
+
Requires-Dist: types-pygments; extra == "dev"
|
38
|
+
Requires-Dist: pytest; extra == "dev"
|
39
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
40
|
+
Requires-Dist: pytest-timeout; extra == "dev"
|
41
|
+
Requires-Dist: hypothesis; extra == "dev"
|
42
|
+
Requires-Dist: pygments>=2.14.0; extra == "dev"
|
43
|
+
Requires-Dist: pdoc-pyo3-sample-library==1.0.11; extra == "dev"
|
43
44
|
|
44
45
|
<p align="center">
|
45
46
|
<a href="https://pdoc.dev/"><img alt="pdoc" src="https://pdoc.dev/logo.svg" width="200" height="100" /></a>
|
@@ -1,15 +1,15 @@
|
|
1
|
-
pdoc/__init__.py,sha256=
|
1
|
+
pdoc/__init__.py,sha256=TyBp31CH_-JtsJqTz6oKZ7nA6g89o44CIxxzmVSVyGk,21456
|
2
2
|
pdoc/__main__.py,sha256=7Xrkxw6-qaSfZfCGFlunl3TfR93uWiCSnvoFABuOmmE,8418
|
3
3
|
pdoc/_compat.py,sha256=OKpXrlLyPCNCHx-csUMLMEuhZTyW6vNe8bznhNH4hL0,4114
|
4
|
-
pdoc/doc.py,sha256=
|
5
|
-
pdoc/doc_ast.py,sha256=
|
4
|
+
pdoc/doc.py,sha256=BATA6UqK9SU1ZWXIYSMRCZi9os3a19QJm5-gUU-bqMU,49851
|
5
|
+
pdoc/doc_ast.py,sha256=A77c3Gq52_Im-lP475_S4fCD4GIJy0_FbEAZye885fo,11389
|
6
6
|
pdoc/doc_pyi.py,sha256=-ZGMz_HctkOPm19eV42vR6pB4KM8odGCjgrVoRPvJXM,5078
|
7
7
|
pdoc/doc_types.py,sha256=mIgMntaw-jCPn_yW2fVTdvkqnWwQys0UKmMTucrdI2w,8468
|
8
8
|
pdoc/docstrings.py,sha256=IdjpZYROqRNRfj1tmAKVuB2WfS1HIMqQwOeYpvbvXio,16384
|
9
9
|
pdoc/extract.py,sha256=7QqxtsKfvcpFi2yBvpFPQe-YR6KAW_L5PCh9v9g1m_c,14307
|
10
10
|
pdoc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
pdoc/render.py,sha256=-gbybpZQUJICYABZr4HJLBsX43vsMOl1Vo1FIshz9pU,7054
|
12
|
-
pdoc/render_helpers.py,sha256=
|
12
|
+
pdoc/render_helpers.py,sha256=oPQbYkixh0qaAIUHW93QCephB9gacMdtRTHA5wFOeUc,20400
|
13
13
|
pdoc/search.py,sha256=RGFaRftEQOg1Mw4FEOmJVRY9DhBncBYSFi5r4MSknTM,7248
|
14
14
|
pdoc/web.py,sha256=F2AvCZr2ucVf9ZlN_SWBO0XpcSKbZTfiN47ypX85zzo,6896
|
15
15
|
pdoc/markdown2/LICENSE,sha256=BfcOT5Iu-7wDaKcbIta8wkP-pFncOu4yXeBlMfbeYGI,1116
|
@@ -30,7 +30,7 @@ pdoc/templates/theme.css,sha256=yjnbtPVmqaifTINsA5sK2a3e1aoFO0UlOMgOSKUgLvI,397
|
|
30
30
|
pdoc/templates/default/error.html.jinja2,sha256=RqH14o6ZV79uBO14gKSjwObXFKKczkcLTMe1orurEJk,970
|
31
31
|
pdoc/templates/default/frame.html.jinja2,sha256=Qp5zlts8Bl-O2f0cxJHH_QdmAkMtJJjNVA0ZU2Mbwl8,2164
|
32
32
|
pdoc/templates/default/index.html.jinja2,sha256=MkzVYMWUuJgscty3jVbDtcEfB1vz-bp3v_sMa5MzevU,2381
|
33
|
-
pdoc/templates/default/module.html.jinja2,sha256=
|
33
|
+
pdoc/templates/default/module.html.jinja2,sha256=wUqEgest0bhIML_4SFByQKVfvhSZj9WUbhy-ncddUNQ,13281
|
34
34
|
pdoc/templates/deprecated/README.md,sha256=8HPj4Bu6EPAdHbH5CQVYgcD580zpkhqbwiSFoLAVB1Q,339
|
35
35
|
pdoc/templates/deprecated/bootstrap-reboot.min.css,sha256=-u1DTWljwtvjAc8X-ihFhIixKaPcs4w_uZ_CYvvP9-o,207
|
36
36
|
pdoc/templates/deprecated/box-arrow-in-left.svg,sha256=-u1DTWljwtvjAc8X-ihFhIixKaPcs4w_uZ_CYvvP9-o,207
|
@@ -47,9 +47,9 @@ pdoc/templates/resources/info-circle-fill.svg,sha256=kO3AMXfWtacpJPzC8Pvihf46OZd
|
|
47
47
|
pdoc/templates/resources/lightning-fill.svg,sha256=XEyCtbgxeAlwCezdsf7N0NFd5aMjwqyJJDpaFbYYTFA,265
|
48
48
|
pdoc/templates/resources/navtoggle.svg,sha256=WVR0BJIucX0MgwwEawmfX0qYD1i_dSbUhoGnqPef3jw,187
|
49
49
|
pdoc/templates/resources/pdoc-logo.svg,sha256=w5OsMmytDaA2Fr9CobeQQFxBNx4-wFFHtLvkORj0gjk,6989
|
50
|
-
pdoc-14.
|
51
|
-
pdoc-14.
|
52
|
-
pdoc-14.
|
53
|
-
pdoc-14.
|
54
|
-
pdoc-14.
|
55
|
-
pdoc-14.
|
50
|
+
pdoc-14.7.0.dist-info/LICENSE,sha256=LrhIeJ7gKTDPyOX9YVuZGr9mpmyjpkvqH6LjxvE0szM,898
|
51
|
+
pdoc-14.7.0.dist-info/METADATA,sha256=CnJAbNSbI-5EBnWL4TRf2jkFiQu57dQ0Gl1ifoylXns,7321
|
52
|
+
pdoc-14.7.0.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
53
|
+
pdoc-14.7.0.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
|
54
|
+
pdoc-14.7.0.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
|
55
|
+
pdoc-14.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|