pdoc 14.4.0__py3-none-any.whl → 14.5.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 CHANGED
@@ -283,7 +283,16 @@ You can include external Markdown files in your documentation by using reStructu
283
283
  """
284
284
  ```
285
285
 
286
- Since version 11, pdoc processes such reStructuredText elements by default.
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.4.0" # this is read from setup.py
478
+ __version__ = "14.5.0" # 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: Any | empty # technically Any includes empty, but this conveys intent.
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
- for dir in sys.path:
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(dir) / (module_path + ".pyi"),
31
- Path(dir) / (module_path + "/__init__.pyi"),
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
@@ -5,6 +5,7 @@ In particular, it provides functionality to resolve
5
5
  [typing.ForwardRef](https://docs.python.org/3/library/typing.html#typing.ForwardRef) objects without raising an
6
6
  exception.
7
7
  """
8
+
8
9
  from __future__ import annotations
9
10
 
10
11
  import functools
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
@@ -41,6 +41,7 @@ to 27kB.
41
41
 
42
42
  If you wish to disable the search functionality, you can pass `--no-search` when invoking pdoc.
43
43
  """
44
+
44
45
  from __future__ import annotations
45
46
 
46
47
  from collections.abc import Callable
@@ -24,5 +24,6 @@
24
24
  <style>
25
25
  mjx-container {
26
26
  overflow-x: auto;
27
+ overflow-y: hidden;
27
28
  }
28
29
  </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.4.0
3
+ Version: 14.5.0
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 (>=2.11.0)
29
- Requires-Dist: pygments (>=2.12.0)
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 (>=2.14.0) ; extra == 'dev'
42
- Requires-Dist: pdoc-pyo3-sample-library (==1.0.11) ; extra == 'dev'
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
  [![Dev Guide](https://shields.mitmproxy.org/badge/dev_docs-CONTRIBUTING.md-blue)](https://github.com/mitmproxy/pdoc/blob/main/CONTRIBUTING.md)
111
111
 
112
- Also, please feel free to join our developer Slack!
113
-
114
- [![Slack Developer Chat](https://shields.mitmproxy.org/badge/slack-mitmproxy-E01563.svg)](http://slack.mitmproxy.org/)
115
-
116
112
 
117
113
  ## pdoc vs. pdoc3
118
114
 
@@ -1,17 +1,17 @@
1
- pdoc/__init__.py,sha256=Bu6WuxUPvQzuWM79MxWtx_h82cUpSO5uOvjsW0bdyKg,20937
1
+ pdoc/__init__.py,sha256=mEtbCmPlDh93hFxFhwoT-35ETJ_IOp1mRYneZ2rcTIk,21176
2
2
  pdoc/__main__.py,sha256=79uLvuQ8eHvU_tzXy4akpKMdDF2DN0xg5VPgv4pmyGo,8418
3
3
  pdoc/_compat.py,sha256=wKGKTxTTxfNjEcKPwvtuvNeOyiozPfL52h8PArKky-0,3843
4
- pdoc/doc.py,sha256=hPv_SpWmIzjlCpePXNGEj-gyEHrHq48mk_oSKyRAPmM,48383
5
- pdoc/doc_ast.py,sha256=-xwmklfpIku2PDT_KUylN0y9mk83hmp7VmRRSrtHVvc,11310
6
- pdoc/doc_pyi.py,sha256=SJ5Mx7OU4WNnxSNkom79xct0P9eqH3KgObW_6ZxG6Y4,4203
7
- pdoc/doc_types.py,sha256=P6HwAIKotcE7iKJtKpZPvbok7LpeqYEtrgUcknuMcek,8467
8
- pdoc/docstrings.py,sha256=F_knLP93uD5RiHUN1Ha7mGTxzadiG1880-Go0dXmdh0,14990
9
- pdoc/extract.py,sha256=G8mGJRHzhbckXGNuYO-hQUL51HItNkJ7ehK5g7By3o8,14277
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=tlde_X-Z9CTwQCYr_GSiHy8PKSOtjo0GoDORTcPJn-8,7247
14
- pdoc/web.py,sha256=ez0lEqwlmpQnkaVfOWglht7e7bvLQXWnJPBp9usgf3k,6895
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=tw7wpwGhQYUxU5SjjZxFsyk5gqaeMv_5IYFUb4hxqpY,1046
24
+ pdoc/templates/math.html.jinja2,sha256=X_IQ-uPMK4_dxF5szwPZeboetanVWIFgqCNtPAyhLdU,1074
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.4.0.dist-info/LICENSE,sha256=fhLl30uuEsshWBuhV87SDhmGoFCN0Q0Oikq5pM-U6Fw,1211
51
- pdoc-14.4.0.dist-info/METADATA,sha256=RLpOyhI-cajuuNMwe5xxfdpGzaOtcdr0Z8aWc6C2c8g,7470
52
- pdoc-14.4.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
53
- pdoc-14.4.0.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
54
- pdoc-14.4.0.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
55
- pdoc-14.4.0.dist-info/RECORD,,
50
+ pdoc-14.5.0.dist-info/LICENSE,sha256=fhLl30uuEsshWBuhV87SDhmGoFCN0Q0Oikq5pM-U6Fw,1211
51
+ pdoc-14.5.0.dist-info/METADATA,sha256=KPzx15_WO3Z09NVzuOLl8DkC_l70bi-K0RmnZz-zM24,7289
52
+ pdoc-14.5.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
53
+ pdoc-14.5.0.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
54
+ pdoc-14.5.0.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
55
+ pdoc-14.5.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes