pdoc 14.6.0__tar.gz → 14.6.1__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.
- {pdoc-14.6.0 → pdoc-14.6.1}/CHANGELOG.md +11 -0
- {pdoc-14.6.0/pdoc.egg-info → pdoc-14.6.1}/PKG-INFO +1 -1
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/__init__.py +1 -1
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/_compat.py +11 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/doc.py +17 -8
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/doc_ast.py +2 -2
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/doc_pyi.py +22 -6
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/default/module.html.jinja2 +1 -1
- {pdoc-14.6.0 → pdoc-14.6.1/pdoc.egg-info}/PKG-INFO +1 -1
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_doc_types.py +3 -1
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_snapshot.py +1 -1
- {pdoc-14.6.0 → pdoc-14.6.1}/LICENSE +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/MANIFEST.in +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/README.md +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/__main__.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/doc_types.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/docstrings.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/extract.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/markdown2/LICENSE +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/markdown2/README.md +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/markdown2/__init__.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/py.typed +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/render.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/render_helpers.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/search.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/README.md +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/build-search-index.js +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/content.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/custom.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/default/error.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/default/frame.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/default/index.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/README.md +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/bootstrap-reboot.min.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/box-arrow-in-left.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/elasticlunr.min.js +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/favicon.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/navtoggle.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/pdoc-logo.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/deprecated/resources/favicon.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/layout.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/livereload.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/math.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/mermaid.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/bootstrap-reboot.min.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/box-arrow-in-left.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/elasticlunr.min.js +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/exclamation-triangle-fill.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/info-circle-fill.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/lightning-fill.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/navtoggle.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/resources/pdoc-logo.svg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/search.html.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/search.js.jinja2 +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/syntax-highlighting.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/templates/theme.css +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc/web.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc.egg-info/SOURCES.txt +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc.egg-info/dependency_links.txt +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc.egg-info/entry_points.txt +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc.egg-info/requires.txt +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pdoc.egg-info/top_level.txt +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/pyproject.toml +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/setup.cfg +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_doc.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_doc_ast.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_doc_pyi.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_docstrings.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_extract.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_main.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_render_helpers.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_search.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_smoke.py +0 -0
- {pdoc-14.6.0 → pdoc-14.6.1}/test/test_web.py +0 -0
@@ -4,6 +4,17 @@
|
|
4
4
|
|
5
5
|
## Unreleased: pdoc next
|
6
6
|
|
7
|
+
|
8
|
+
## 2024-08-27: pdoc 14.6.1
|
9
|
+
|
10
|
+
- Fix a bug where entire modules would be excluded by `--no-include-undocumented`.
|
11
|
+
To exclude modules, see https://pdoc.dev/docs/pdoc.html#exclude-submodules-from-being-documented.
|
12
|
+
([#728](https://github.com/mitmproxy/pdoc/pull/728), @mhils)
|
13
|
+
- Fix a bug where pdoc would crash when importing pyi files.
|
14
|
+
([#732](https://github.com/mitmproxy/pdoc/pull/732), @mhils)
|
15
|
+
- Fix a bug where subclasses of TypedDict subclasses would not render correctly.
|
16
|
+
([#729](https://github.com/mitmproxy/pdoc/pull/729), @mhils)
|
17
|
+
|
7
18
|
## 2024-07-24: pdoc 14.6.0
|
8
19
|
|
9
20
|
- If `example.data.Data` is also exposed as `example.Data`, pdoc now links to `example.Data` in documentation.
|
@@ -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.6.
|
484
|
+
__version__ = "14.6.1" # this is read from setup.py
|
485
485
|
|
486
486
|
from pathlib import Path
|
487
487
|
from typing import overload
|
@@ -123,6 +123,16 @@ else: # pragma: no cover
|
|
123
123
|
return ' | '.join(self.option_strings)
|
124
124
|
|
125
125
|
|
126
|
+
if sys.version_info >= (3, 10):
|
127
|
+
from typing import is_typeddict
|
128
|
+
else: # pragma: no cover
|
129
|
+
def is_typeddict(tp):
|
130
|
+
try:
|
131
|
+
return tp.__orig_bases__[-1].__name__ == "TypedDict"
|
132
|
+
except Exception:
|
133
|
+
return False
|
134
|
+
|
135
|
+
|
126
136
|
__all__ = [
|
127
137
|
"cache",
|
128
138
|
"ast_unparse",
|
@@ -134,4 +144,5 @@ __all__ = [
|
|
134
144
|
"removesuffix",
|
135
145
|
"formatannotation",
|
136
146
|
"BooleanOptionalAction",
|
147
|
+
"is_typeddict",
|
137
148
|
]
|
@@ -37,6 +37,7 @@ import types
|
|
37
37
|
from typing import Any
|
38
38
|
from typing import ClassVar
|
39
39
|
from typing import Generic
|
40
|
+
from typing import TypedDict
|
40
41
|
from typing import TypeVar
|
41
42
|
from typing import Union
|
42
43
|
from typing import get_origin
|
@@ -49,6 +50,7 @@ from pdoc._compat import TypeAlias
|
|
49
50
|
from pdoc._compat import TypeAliasType
|
50
51
|
from pdoc._compat import cache
|
51
52
|
from pdoc._compat import formatannotation
|
53
|
+
from pdoc._compat import is_typeddict
|
52
54
|
from pdoc.doc_types import GenericAlias
|
53
55
|
from pdoc.doc_types import NonUserDefinedCallables
|
54
56
|
from pdoc.doc_types import empty
|
@@ -655,14 +657,21 @@ class Class(Namespace[type]):
|
|
655
657
|
@cached_property
|
656
658
|
def _bases(self) -> tuple[type, ...]:
|
657
659
|
orig_bases = _safe_getattr(self.obj, "__orig_bases__", ())
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
660
|
+
|
661
|
+
if is_typeddict(self.obj):
|
662
|
+
if sys.version_info < (3, 12): # pragma: no cover
|
663
|
+
# TypedDicts on Python <3.12 have a botched __mro__. We need to fix it.
|
664
|
+
return (self.obj, *orig_bases[:-1])
|
665
|
+
else:
|
666
|
+
# TypedDict on Python >=3.12 removes intermediate classes from __mro__,
|
667
|
+
# so we use orig_bases to recover the full mro.
|
668
|
+
while orig_bases and orig_bases[-1] is not TypedDict:
|
669
|
+
parent_bases = _safe_getattr(orig_bases[-1], "__orig_bases__", ())
|
670
|
+
if (
|
671
|
+
len(parent_bases) != 1 or parent_bases in orig_bases
|
672
|
+
): # sanity check that things look right
|
673
|
+
break # pragma: no cover
|
674
|
+
orig_bases = (*orig_bases, parent_bases[0])
|
666
675
|
|
667
676
|
# __mro__ and __orig_bases__ differ between Python versions and special cases like TypedDict/NamedTuple.
|
668
677
|
# This here is a pragmatic approximation of what we want.
|
@@ -245,7 +245,7 @@ def _parse_class(source: str) -> ast.ClassDef:
|
|
245
245
|
t = tree.body[0]
|
246
246
|
assert isinstance(t, ast.ClassDef)
|
247
247
|
return t
|
248
|
-
return ast.ClassDef(body=[], decorator_list=[])
|
248
|
+
return ast.ClassDef(body=[], decorator_list=[]) # type: ignore
|
249
249
|
|
250
250
|
|
251
251
|
@cache
|
@@ -265,7 +265,7 @@ def _parse_function(source: str) -> ast.FunctionDef | ast.AsyncFunctionDef:
|
|
265
265
|
# we have a lambda function,
|
266
266
|
# to simplify the API return the ast.FunctionDef stub.
|
267
267
|
pass
|
268
|
-
return ast.FunctionDef(body=[], decorator_list=[])
|
268
|
+
return ast.FunctionDef(body=[], decorator_list=[]) # type: ignore
|
269
269
|
|
270
270
|
|
271
271
|
def _parse(
|
@@ -6,6 +6,7 @@ This makes it possible to add type hints for native modules such as modules writ
|
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
|
+
import importlib.util
|
9
10
|
from pathlib import Path
|
10
11
|
import sys
|
11
12
|
import traceback
|
@@ -45,13 +46,28 @@ def find_stub_file(module_name: str) -> Path | None:
|
|
45
46
|
|
46
47
|
|
47
48
|
def _import_stub_file(module_name: str, stub_file: Path) -> types.ModuleType:
|
48
|
-
"""
|
49
|
-
|
50
|
-
m = types.ModuleType(module_name)
|
51
|
-
m.__file__ = str(stub_file)
|
52
|
-
eval(code, m.__dict__, m.__dict__)
|
49
|
+
"""
|
50
|
+
Import the type stub outside of the normal import machinery.
|
53
51
|
|
54
|
-
|
52
|
+
Note that currently, for objects imported by the stub file, the _original_ module
|
53
|
+
is used and not the corresponding stub file.
|
54
|
+
"""
|
55
|
+
sys.path_hooks.append(
|
56
|
+
importlib.machinery.FileFinder.path_hook(
|
57
|
+
(importlib.machinery.SourceFileLoader, [".pyi"])
|
58
|
+
)
|
59
|
+
)
|
60
|
+
try:
|
61
|
+
loader = importlib.machinery.SourceFileLoader(module_name, str(stub_file))
|
62
|
+
spec = importlib.util.spec_from_file_location(
|
63
|
+
module_name, stub_file, loader=loader
|
64
|
+
)
|
65
|
+
assert spec is not None
|
66
|
+
m = importlib.util.module_from_spec(spec)
|
67
|
+
loader.exec_module(m)
|
68
|
+
return m
|
69
|
+
finally:
|
70
|
+
sys.path_hooks.pop()
|
55
71
|
|
56
72
|
|
57
73
|
def _prepare_module(ns: doc.Namespace) -> None:
|
@@ -244,7 +244,7 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
|
|
244
244
|
{% elif "@public" in doc.docstring %}
|
245
245
|
{# show members explicitly marked as @public #}
|
246
246
|
true
|
247
|
-
{% elif not include_undocumented and not doc.docstring %}
|
247
|
+
{% elif not include_undocumented and not doc.docstring and doc.kind != "module" %}
|
248
248
|
{# hide members that are undocumented if include_undocumented has been toggled off. #}
|
249
249
|
{% elif doc.name == "__init__" and (doc.docstring or (doc.kind == "function" and doc.signature_without_self.parameters)) %}
|
250
250
|
{# show constructors that have a docstring or at least one extra argument #}
|
@@ -79,5 +79,7 @@ def test_recurse(monkeypatch):
|
|
79
79
|
monkeypatch.setitem(sys.modules, "a", a)
|
80
80
|
monkeypatch.setitem(sys.modules, "b", b)
|
81
81
|
|
82
|
-
with pytest.warns(
|
82
|
+
with pytest.warns(
|
83
|
+
UserWarning, match="Recursion error when importing a|Import of xyz failed"
|
84
|
+
):
|
83
85
|
assert safe_eval_type("xyz", a.__dict__, None, a, "a") == "xyz"
|
@@ -164,7 +164,7 @@ snapshots = [
|
|
164
164
|
Snapshot("pyo3_sample_library", specs=["pdoc_pyo3_sample_library"]),
|
165
165
|
Snapshot("top_level_reimports", ["top_level_reimports"]),
|
166
166
|
Snapshot("type_checking_imports", ["type_checking_imports.main"]),
|
167
|
-
Snapshot("
|
167
|
+
Snapshot("type_stubs", ["type_stubs"], min_version=(3, 10)),
|
168
168
|
Snapshot(
|
169
169
|
"visibility",
|
170
170
|
render_options={
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|