pdoc 14.4.0__py3-none-any.whl → 14.5.1__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 +12 -2
- pdoc/doc.py +4 -1
- pdoc/doc_ast.py +4 -6
- pdoc/doc_pyi.py +11 -3
- pdoc/doc_types.py +1 -0
- pdoc/docstrings.py +39 -0
- pdoc/extract.py +1 -0
- pdoc/search.py +1 -0
- pdoc/templates/math.html.jinja2 +1 -1
- pdoc/web.py +1 -0
- {pdoc-14.4.0.dist-info → pdoc-14.5.1.dist-info}/METADATA +5 -9
- {pdoc-14.4.0.dist-info → pdoc-14.5.1.dist-info}/RECORD +16 -16
- {pdoc-14.4.0.dist-info → pdoc-14.5.1.dist-info}/WHEEL +1 -1
- {pdoc-14.4.0.dist-info → pdoc-14.5.1.dist-info}/LICENSE +0 -0
- {pdoc-14.4.0.dist-info → pdoc-14.5.1.dist-info}/entry_points.txt +0 -0
- {pdoc-14.4.0.dist-info → pdoc-14.5.1.dist-info}/top_level.txt +0 -0
pdoc/__init__.py
CHANGED
@@ -283,7 +283,16 @@ You can include external Markdown files in your documentation by using reStructu
|
|
283
283
|
"""
|
284
284
|
```
|
285
285
|
|
286
|
-
|
286
|
+
You can also include only parts of a file with the
|
287
|
+
[`start-line`, `end-line`, `start-after`, and `end-after` options](https://docutils.sourceforge.io/docs/ref/rst/directives.html#including-an-external-document-fragment):
|
288
|
+
|
289
|
+
```python
|
290
|
+
"""
|
291
|
+
.. include:: ../README.md
|
292
|
+
:start-line: 1
|
293
|
+
:end-before: Changelog
|
294
|
+
"""
|
295
|
+
```
|
287
296
|
|
288
297
|
|
289
298
|
## ...add a title page?
|
@@ -462,10 +471,11 @@ to your Python code before pdoc is used.
|
|
462
471
|
It is also possible to create `pdoc.doc.Module` objects directly and modify them before rendering.
|
463
472
|
You can find an example in [`examples/library-usage`](https://github.com/mitmproxy/pdoc/tree/main/examples/library-usage).
|
464
473
|
'''
|
474
|
+
|
465
475
|
from __future__ import annotations
|
466
476
|
|
467
477
|
__docformat__ = "markdown" # explicitly disable rST processing in the examples above.
|
468
|
-
__version__ = "14.
|
478
|
+
__version__ = "14.5.1" # this is read from setup.py
|
469
479
|
|
470
480
|
from pathlib import Path
|
471
481
|
from typing import overload
|
pdoc/doc.py
CHANGED
@@ -15,6 +15,7 @@ All documentation types make heavy use of `@functools.cached_property` decorator
|
|
15
15
|
This means they have a large set of attributes that are lazily computed on first access.
|
16
16
|
By convention, all attributes are read-only, although this is not enforced at runtime.
|
17
17
|
"""
|
18
|
+
|
18
19
|
from __future__ import annotations
|
19
20
|
|
20
21
|
from abc import ABCMeta
|
@@ -1030,7 +1031,9 @@ class Variable(Doc[None]):
|
|
1030
1031
|
|
1031
1032
|
kind = "variable"
|
1032
1033
|
|
1033
|
-
default_value:
|
1034
|
+
default_value: (
|
1035
|
+
Any | empty
|
1036
|
+
) # technically Any includes empty, but this conveys intent.
|
1034
1037
|
"""
|
1035
1038
|
The variable's default value.
|
1036
1039
|
|
pdoc/doc_ast.py
CHANGED
@@ -3,6 +3,7 @@ This module handles all interpretation of the *Abstract Syntax Tree (AST)* in pd
|
|
3
3
|
|
4
4
|
Parsing the AST is done to extract docstrings, type annotations, and variable declarations from `__init__`.
|
5
5
|
"""
|
6
|
+
|
6
7
|
from __future__ import annotations
|
7
8
|
|
8
9
|
import ast
|
@@ -51,18 +52,15 @@ def _get_source(obj: Any) -> str:
|
|
51
52
|
|
52
53
|
|
53
54
|
@overload
|
54
|
-
def parse(obj: types.ModuleType) -> ast.Module:
|
55
|
-
...
|
55
|
+
def parse(obj: types.ModuleType) -> ast.Module: ...
|
56
56
|
|
57
57
|
|
58
58
|
@overload
|
59
|
-
def parse(obj: types.FunctionType) -> ast.FunctionDef | ast.AsyncFunctionDef:
|
60
|
-
...
|
59
|
+
def parse(obj: types.FunctionType) -> ast.FunctionDef | ast.AsyncFunctionDef: ...
|
61
60
|
|
62
61
|
|
63
62
|
@overload
|
64
|
-
def parse(obj: type) -> ast.ClassDef:
|
65
|
-
...
|
63
|
+
def parse(obj: type) -> ast.ClassDef: ...
|
66
64
|
|
67
65
|
|
68
66
|
def parse(obj):
|
pdoc/doc_pyi.py
CHANGED
@@ -3,6 +3,7 @@ This module is responsible for patching `pdoc.doc.Doc` objects with type annotat
|
|
3
3
|
in `.pyi` type stub files ([PEP 561](https://peps.python.org/pep-0561/)).
|
4
4
|
This makes it possible to add type hints for native modules such as modules written using [PyO3](https://pyo3.rs/).
|
5
5
|
"""
|
6
|
+
|
6
7
|
from __future__ import annotations
|
7
8
|
|
8
9
|
from pathlib import Path
|
@@ -25,10 +26,17 @@ def find_stub_file(module_name: str) -> Path | None:
|
|
25
26
|
"""Try to find a .pyi file with type stubs for the given module name."""
|
26
27
|
module_path = module_name.replace(".", "/")
|
27
28
|
|
28
|
-
|
29
|
+
# Find .pyi-file in a PEP 0561 compatible stub-package
|
30
|
+
module_part_name = module_name.split(".")
|
31
|
+
module_part_name[0] = f"{module_part_name[0]}-stubs"
|
32
|
+
module_stub_path = "/".join(module_part_name)
|
33
|
+
|
34
|
+
for search_dir in sys.path:
|
29
35
|
file_candidates = [
|
30
|
-
Path(
|
31
|
-
Path(
|
36
|
+
Path(search_dir) / (module_path + ".pyi"),
|
37
|
+
Path(search_dir) / (module_path + "/__init__.pyi"),
|
38
|
+
Path(search_dir) / (module_stub_path + ".pyi"),
|
39
|
+
Path(search_dir) / (module_stub_path + "/__init__.pyi"),
|
32
40
|
]
|
33
41
|
for f in file_candidates:
|
34
42
|
if f.exists():
|
pdoc/doc_types.py
CHANGED
pdoc/docstrings.py
CHANGED
@@ -10,6 +10,7 @@ If you miss a particular feature for your favorite flavor, contributions are wel
|
|
10
10
|
That being said, please keep the complexity low and make sure that changes are
|
11
11
|
accompanied by matching snapshot tests in `test/testdata/`.
|
12
12
|
"""
|
13
|
+
|
13
14
|
from __future__ import annotations
|
14
15
|
|
15
16
|
import base64
|
@@ -359,6 +360,38 @@ def _rst_links(contents: str) -> str:
|
|
359
360
|
return contents
|
360
361
|
|
361
362
|
|
363
|
+
def _rst_extract_options(contents: str) -> tuple[str, dict[str, str]]:
|
364
|
+
"""
|
365
|
+
Extract options from the beginning of reStructuredText directives.
|
366
|
+
|
367
|
+
Return the trimmed content and a dict of options.
|
368
|
+
"""
|
369
|
+
options = {}
|
370
|
+
while match := re.match(r"^\s*:(.+?):(.*)([\s\S]*)", contents):
|
371
|
+
key, value, contents = match.groups()
|
372
|
+
options[key] = value.strip()
|
373
|
+
|
374
|
+
return contents, options
|
375
|
+
|
376
|
+
|
377
|
+
def _rst_include_trim(contents: str, options: dict[str, str]) -> str:
|
378
|
+
"""
|
379
|
+
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#include-options>
|
380
|
+
"""
|
381
|
+
if "end-line" in options or "start-line" in options:
|
382
|
+
lines = contents.splitlines()
|
383
|
+
if i := options.get("end-line"):
|
384
|
+
lines = lines[: int(i)]
|
385
|
+
if i := options.get("start-line"):
|
386
|
+
lines = lines[int(i) :]
|
387
|
+
contents = "\n".join(lines)
|
388
|
+
if x := options.get("end-before"):
|
389
|
+
contents = contents[: contents.index(x)]
|
390
|
+
if x := options.get("start-after"):
|
391
|
+
contents = contents[contents.index(x) + len(x) :]
|
392
|
+
return contents
|
393
|
+
|
394
|
+
|
362
395
|
def _rst_admonitions(contents: str, source_file: Path | None) -> str:
|
363
396
|
"""
|
364
397
|
Convert reStructuredText admonitions - a bit tricky because they may already be indented themselves.
|
@@ -370,6 +403,7 @@ def _rst_admonitions(contents: str, source_file: Path | None) -> str:
|
|
370
403
|
type = m.group("type")
|
371
404
|
val = m.group("val").strip()
|
372
405
|
contents = dedent(m.group("contents")).strip()
|
406
|
+
contents, options = _rst_extract_options(contents)
|
373
407
|
|
374
408
|
if type == "include":
|
375
409
|
loc = source_file or Path(".")
|
@@ -378,7 +412,12 @@ def _rst_admonitions(contents: str, source_file: Path | None) -> str:
|
|
378
412
|
except OSError as e:
|
379
413
|
warnings.warn(f"Cannot include {val!r}: {e}")
|
380
414
|
included = "\n"
|
415
|
+
try:
|
416
|
+
included = _rst_include_trim(included, options) + "\n"
|
417
|
+
except ValueError as e:
|
418
|
+
warnings.warn(f"Failed to process include options for {val!r}: {e}")
|
381
419
|
included = _rst_admonitions(included, loc.parent / val)
|
420
|
+
included = embed_images(included, loc.parent / val)
|
382
421
|
return indent(included, ind)
|
383
422
|
if type == "math":
|
384
423
|
return f"{ind}$${val}{contents}$$\n"
|
pdoc/extract.py
CHANGED
@@ -3,6 +3,7 @@ This module handles the interaction with Python's module system,
|
|
3
3
|
that is it loads the correct module based on whatever the user specified,
|
4
4
|
and provides the rest of pdoc with some additional module metadata.
|
5
5
|
"""
|
6
|
+
|
6
7
|
from __future__ import annotations
|
7
8
|
|
8
9
|
from collections.abc import Iterable
|
pdoc/search.py
CHANGED
pdoc/templates/math.html.jinja2
CHANGED
@@ -10,7 +10,6 @@
|
|
10
10
|
}
|
11
11
|
};
|
12
12
|
</script>
|
13
|
-
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
14
13
|
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
15
14
|
<script>
|
16
15
|
/* Re-invoke MathJax when DOM content changes, for example during search. */
|
@@ -24,5 +23,6 @@
|
|
24
23
|
<style>
|
25
24
|
mjx-container {
|
26
25
|
overflow-x: auto;
|
26
|
+
overflow-y: hidden;
|
27
27
|
}
|
28
28
|
</style>
|
pdoc/web.py
CHANGED
@@ -5,6 +5,7 @@ We want to keep the number of dependencies as small as possible,
|
|
5
5
|
so we are content with the builtin `http.server` module.
|
6
6
|
It is a bit unergonomic compared to let's say flask, but good enough for our purposes.
|
7
7
|
"""
|
8
|
+
|
8
9
|
from __future__ import annotations
|
9
10
|
|
10
11
|
from collections.abc import Iterable
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pdoc
|
3
|
-
Version: 14.
|
3
|
+
Version: 14.5.1
|
4
4
|
Summary: API Documentation for Python Projects
|
5
5
|
Author-email: Maximilian Hils <pdoc@maximilianhils.com>
|
6
6
|
License: Unlicense
|
@@ -25,8 +25,8 @@ Classifier: Typing :: Typed
|
|
25
25
|
Requires-Python: >=3.8
|
26
26
|
Description-Content-Type: text/markdown
|
27
27
|
License-File: LICENSE
|
28
|
-
Requires-Dist: Jinja2
|
29
|
-
Requires-Dist: pygments
|
28
|
+
Requires-Dist: Jinja2 >=2.11.0
|
29
|
+
Requires-Dist: pygments >=2.12.0
|
30
30
|
Requires-Dist: MarkupSafe
|
31
31
|
Requires-Dist: astunparse ; python_version < "3.9"
|
32
32
|
Provides-Extra: dev
|
@@ -38,8 +38,8 @@ Requires-Dist: pytest ; extra == 'dev'
|
|
38
38
|
Requires-Dist: pytest-cov ; extra == 'dev'
|
39
39
|
Requires-Dist: pytest-timeout ; extra == 'dev'
|
40
40
|
Requires-Dist: hypothesis ; extra == 'dev'
|
41
|
-
Requires-Dist: pygments
|
42
|
-
Requires-Dist: pdoc-pyo3-sample-library
|
41
|
+
Requires-Dist: pygments >=2.14.0 ; extra == 'dev'
|
42
|
+
Requires-Dist: pdoc-pyo3-sample-library ==1.0.11 ; extra == 'dev'
|
43
43
|
|
44
44
|
<p align="center">
|
45
45
|
<a href="https://pdoc.dev/"><img alt="pdoc" src="https://pdoc.dev/logo.svg" width="200" height="100" /></a>
|
@@ -109,10 +109,6 @@ As an open source project, pdoc welcomes contributions of all forms.
|
|
109
109
|
|
110
110
|
[](https://github.com/mitmproxy/pdoc/blob/main/CONTRIBUTING.md)
|
111
111
|
|
112
|
-
Also, please feel free to join our developer Slack!
|
113
|
-
|
114
|
-
[](http://slack.mitmproxy.org/)
|
115
|
-
|
116
112
|
|
117
113
|
## pdoc vs. pdoc3
|
118
114
|
|
@@ -1,17 +1,17 @@
|
|
1
|
-
pdoc/__init__.py,sha256=
|
1
|
+
pdoc/__init__.py,sha256=bhq50jgLNwpui952AYj4NyCl5ahLjjn0czk_sChTmrk,21176
|
2
2
|
pdoc/__main__.py,sha256=79uLvuQ8eHvU_tzXy4akpKMdDF2DN0xg5VPgv4pmyGo,8418
|
3
3
|
pdoc/_compat.py,sha256=wKGKTxTTxfNjEcKPwvtuvNeOyiozPfL52h8PArKky-0,3843
|
4
|
-
pdoc/doc.py,sha256=
|
5
|
-
pdoc/doc_ast.py,sha256
|
6
|
-
pdoc/doc_pyi.py,sha256=
|
7
|
-
pdoc/doc_types.py,sha256=
|
8
|
-
pdoc/docstrings.py,sha256=
|
9
|
-
pdoc/extract.py,sha256=
|
4
|
+
pdoc/doc.py,sha256=zmXHLmMBB-evOSXyV6cR-bYfQSI6bBIIwODJQZtT7Pk,48400
|
5
|
+
pdoc/doc_ast.py,sha256=ChAOF7qcuRQbdWnRamH6OUtvvIo-JOVCetPjRnb2a3w,11299
|
6
|
+
pdoc/doc_pyi.py,sha256=TT6vbugw53vDgunegloJONSLRAaeXswqKah1_TVuUwA,4567
|
7
|
+
pdoc/doc_types.py,sha256=mIgMntaw-jCPn_yW2fVTdvkqnWwQys0UKmMTucrdI2w,8468
|
8
|
+
pdoc/docstrings.py,sha256=SiCsv-tMT4cxdhSZOT8xeZhJUtloXEDBuphsnXPLSgs,16400
|
9
|
+
pdoc/extract.py,sha256=6OFHDK7hxn-9b_5SKqQAPd4lXwgWPSDveXS_tqfL_44,14278
|
10
10
|
pdoc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
pdoc/render.py,sha256=-gbybpZQUJICYABZr4HJLBsX43vsMOl1Vo1FIshz9pU,7054
|
12
12
|
pdoc/render_helpers.py,sha256=clTbaHYpyK2rMvjhUQpdO0bqrjjcAgFkimuJMZ-uCXc,18708
|
13
|
-
pdoc/search.py,sha256=
|
14
|
-
pdoc/web.py,sha256=
|
13
|
+
pdoc/search.py,sha256=RGFaRftEQOg1Mw4FEOmJVRY9DhBncBYSFi5r4MSknTM,7248
|
14
|
+
pdoc/web.py,sha256=F2AvCZr2ucVf9ZlN_SWBO0XpcSKbZTfiN47ypX85zzo,6896
|
15
15
|
pdoc/markdown2/LICENSE,sha256=BfcOT5Iu-7wDaKcbIta8wkP-pFncOu4yXeBlMfbeYGI,1116
|
16
16
|
pdoc/markdown2/README.md,sha256=-b2NGwLPzTBnaCGPSqRCzHxSrqArlXxGG5w0c6pOqFk,200
|
17
17
|
pdoc/markdown2/__init__.py,sha256=d12k9Kr2TnRRz0ga_VH73R5QkW2UjGO_wDzSR6kFJpI,127882
|
@@ -21,7 +21,7 @@ pdoc/templates/content.css,sha256=eBji75EG9DRr8L2NftE3LesQqW4o56_yIt0NXq_cCZY,91
|
|
21
21
|
pdoc/templates/custom.css,sha256=62cn8AmBJiplFJyAKXoZSlVa1s3lNOjkYwDp20pF-ew,106
|
22
22
|
pdoc/templates/layout.css,sha256=xv7AgPtHiazW7S2AtNebRr2BKmOSPmX2wwcejXBRfQ0,4670
|
23
23
|
pdoc/templates/livereload.html.jinja2,sha256=VHbZWN_dBRgBpaRzszvXbbX278-fzbok0JRIOeLep_E,566
|
24
|
-
pdoc/templates/math.html.jinja2,sha256=
|
24
|
+
pdoc/templates/math.html.jinja2,sha256=Jov3pJu5bnouB3jO1Mqoj6aERFlKwiOlnE_0-z4jycE,998
|
25
25
|
pdoc/templates/mermaid.html.jinja2,sha256=cZSmk1Zmec2HaziyEiz2jgmjzQmrG-ZhQISGrhXa1Qc,625
|
26
26
|
pdoc/templates/search.html.jinja2,sha256=6mfYR7S8bI7aprnZFCNvusnji5Zj-QpufaCjSMUQ3Bc,7497
|
27
27
|
pdoc/templates/search.js.jinja2,sha256=pRH-19e80c7Nlu9cKckse4RRruRoYjyiDZscZ3nIdbs,1773
|
@@ -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.5.1.dist-info/LICENSE,sha256=fhLl30uuEsshWBuhV87SDhmGoFCN0Q0Oikq5pM-U6Fw,1211
|
51
|
+
pdoc-14.5.1.dist-info/METADATA,sha256=P7b0Scr4vqcuncgp_3LwSwz1zvqpd4uOwiIxWojZgS0,7289
|
52
|
+
pdoc-14.5.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
53
|
+
pdoc-14.5.1.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
|
54
|
+
pdoc-14.5.1.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
|
55
|
+
pdoc-14.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|