pdoc 14.5.0__py3-none-any.whl → 14.6.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 +7 -1
- pdoc/__main__.py +2 -2
- pdoc/doc.py +23 -8
- pdoc/docstrings.py +1 -1
- pdoc/extract.py +1 -1
- pdoc/markdown2/__init__.py +1667 -765
- pdoc/render_helpers.py +76 -38
- pdoc/templates/content.css +10 -6
- pdoc/templates/math.html.jinja2 +0 -1
- pdoc-14.6.0.dist-info/LICENSE +5 -0
- {pdoc-14.5.0.dist-info → pdoc-14.6.0.dist-info}/METADATA +2 -2
- {pdoc-14.5.0.dist-info → pdoc-14.6.0.dist-info}/RECORD +15 -15
- pdoc-14.5.0.dist-info/LICENSE +0 -24
- {pdoc-14.5.0.dist-info → pdoc-14.6.0.dist-info}/WHEEL +0 -0
- {pdoc-14.5.0.dist-info → pdoc-14.6.0.dist-info}/entry_points.txt +0 -0
- {pdoc-14.5.0.dist-info → pdoc-14.6.0.dist-info}/top_level.txt +0 -0
pdoc/__init__.py
CHANGED
@@ -194,11 +194,17 @@ In general, we recommend keeping the following conventions:
|
|
194
194
|
- If you want to document a special `__dunder__` method, the recommended way to do so is
|
195
195
|
to not document the dunder method specifically, but to add some usage examples in the class documentation.
|
196
196
|
|
197
|
+
> [!NOTE]
|
198
|
+
> Hiding an item only removes it from documentation.
|
199
|
+
> It is still displayed in the source code when clicking the "View Source" button.
|
200
|
+
|
197
201
|
As a last resort, you can override pdoc's behavior with a custom module template (see
|
198
202
|
[*How can I edit pdoc's HTML template?*](#edit-pdocs-html-template)).
|
199
203
|
You can find an example at
|
200
204
|
[`examples/custom-template/module.html.jinja2`](https://github.com/mitmproxy/pdoc/blob/main/examples/custom-template/module.html.jinja2).
|
201
205
|
|
206
|
+
Hiding an item only removes it from documentation. It is still displayed in the source code when clicking the "View Source" button.
|
207
|
+
|
202
208
|
## ...exclude submodules from being documented?
|
203
209
|
|
204
210
|
If you would like to exclude specific submodules from the documentation, the recommended way is to specify `__all__` as
|
@@ -475,7 +481,7 @@ You can find an example in [`examples/library-usage`](https://github.com/mitmpro
|
|
475
481
|
from __future__ import annotations
|
476
482
|
|
477
483
|
__docformat__ = "markdown" # explicitly disable rST processing in the examples above.
|
478
|
-
__version__ = "14.
|
484
|
+
__version__ = "14.6.0" # this is read from setup.py
|
479
485
|
|
480
486
|
from pathlib import Path
|
481
487
|
from typing import overload
|
pdoc/__main__.py
CHANGED
@@ -265,12 +265,12 @@ def get_dev_version() -> str:
|
|
265
265
|
|
266
266
|
def _nicer_showwarning(message, category, filename, lineno, file=None, line=None):
|
267
267
|
"""A replacement for `warnings.showwarning` that renders warnings in a more visually pleasing way."""
|
268
|
-
if category
|
268
|
+
if category is UserWarning:
|
269
269
|
print(
|
270
270
|
f"{yellow}Warn:{default} {message} {gray}({filename}:{lineno}){default}",
|
271
271
|
file=sys.stderr,
|
272
272
|
)
|
273
|
-
elif category
|
273
|
+
elif category is RuntimeWarning:
|
274
274
|
print(
|
275
275
|
f"{yellow}Warn:{default} {message}",
|
276
276
|
file=sys.stderr,
|
pdoc/doc.py
CHANGED
@@ -587,15 +587,21 @@ class Class(Namespace[type]):
|
|
587
587
|
if doc == dict.__doc__:
|
588
588
|
# Don't display default docstring for dict subclasses (primarily TypedDict).
|
589
589
|
return ""
|
590
|
-
|
591
|
-
|
592
|
-
# from https://github.com/python/cpython/blob/3.10/Lib/dataclasses.py
|
593
|
-
and doc
|
594
|
-
== self.obj.__name__
|
595
|
-
+ str(inspect.signature(self.obj)).replace(" -> None", "")
|
596
|
-
)
|
597
|
-
if is_dataclass_with_default_docstring:
|
590
|
+
if doc in _Enum_default_docstrings:
|
591
|
+
# Don't display default docstring for enum subclasses.
|
598
592
|
return ""
|
593
|
+
if dataclasses.is_dataclass(self.obj) and doc.startswith(self.obj.__name__):
|
594
|
+
try:
|
595
|
+
sig = inspect.signature(self.obj)
|
596
|
+
except Exception:
|
597
|
+
pass
|
598
|
+
else:
|
599
|
+
# from https://github.com/python/cpython/blob/3.10/Lib/dataclasses.py
|
600
|
+
is_dataclass_with_default_docstring = doc == self.obj.__name__ + str(
|
601
|
+
sig
|
602
|
+
).replace(" -> None", "")
|
603
|
+
if is_dataclass_with_default_docstring:
|
604
|
+
return ""
|
599
605
|
return doc
|
600
606
|
|
601
607
|
@cached_property
|
@@ -1306,6 +1312,15 @@ def _safe_getdoc(obj: Any) -> str:
|
|
1306
1312
|
return doc.strip()
|
1307
1313
|
|
1308
1314
|
|
1315
|
+
_Enum_default_docstrings = tuple(
|
1316
|
+
{
|
1317
|
+
_safe_getdoc(enum.Enum),
|
1318
|
+
_safe_getdoc(enum.IntEnum),
|
1319
|
+
_safe_getdoc(_safe_getattr(enum, "StrEnum", enum.Enum)),
|
1320
|
+
}
|
1321
|
+
)
|
1322
|
+
|
1323
|
+
|
1309
1324
|
def _remove_memory_addresses(x: str) -> str:
|
1310
1325
|
"""Remove memory addresses from repr() output"""
|
1311
1326
|
return re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", x)
|
pdoc/docstrings.py
CHANGED
@@ -427,7 +427,7 @@ def _rst_admonitions(contents: str, source_file: Path | None) -> str:
|
|
427
427
|
else:
|
428
428
|
heading = ""
|
429
429
|
return (
|
430
|
-
f'{ind}<div class="
|
430
|
+
f'{ind}<div class="alert {type}" markdown="1">\n'
|
431
431
|
f"{heading}"
|
432
432
|
f"{indent(contents, ind)}\n"
|
433
433
|
f"{ind}</div>\n"
|
pdoc/extract.py
CHANGED
@@ -253,7 +253,7 @@ def iter_modules2(module: types.ModuleType) -> dict[str, pkgutil.ModuleInfo]:
|
|
253
253
|
# This is a hacky workaround to register them.
|
254
254
|
members = dir(module) if mod_all is None else mod_all
|
255
255
|
for name in members:
|
256
|
-
if name in submodules or name == "__main__":
|
256
|
+
if name in submodules or name == "__main__" or not isinstance(name, str):
|
257
257
|
continue
|
258
258
|
member = getattr(module, name, None)
|
259
259
|
is_wild_child_module = (
|