pdoc 13.0.1__tar.gz → 13.1.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.
Files changed (74) hide show
  1. {pdoc-13.0.1 → pdoc-13.1.1}/CHANGELOG.md +20 -0
  2. {pdoc-13.0.1/pdoc.egg-info → pdoc-13.1.1}/PKG-INFO +1 -1
  3. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/__init__.py +9 -1
  4. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/__main__.py +7 -0
  5. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/_compat.py +5 -2
  6. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/doc.py +33 -4
  7. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/doc_ast.py +10 -6
  8. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/markdown2/__init__.py +371 -253
  9. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/render.py +3 -0
  10. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/render_helpers.py +1 -0
  11. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/default/frame.html.jinja2 +1 -0
  12. pdoc-13.1.1/pdoc/templates/mermaid.html.jinja2 +18 -0
  13. {pdoc-13.0.1 → pdoc-13.1.1/pdoc.egg-info}/PKG-INFO +1 -1
  14. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc.egg-info/SOURCES.txt +1 -0
  15. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_snapshot.py +1 -0
  16. {pdoc-13.0.1 → pdoc-13.1.1}/LICENSE +0 -0
  17. {pdoc-13.0.1 → pdoc-13.1.1}/MANIFEST.in +0 -0
  18. {pdoc-13.0.1 → pdoc-13.1.1}/README.md +0 -0
  19. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/doc_pyi.py +0 -0
  20. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/doc_types.py +0 -0
  21. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/docstrings.py +0 -0
  22. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/extract.py +0 -0
  23. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/markdown2/LICENSE +0 -0
  24. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/markdown2/README.md +0 -0
  25. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/py.typed +0 -0
  26. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/search.py +0 -0
  27. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/README.md +0 -0
  28. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/build-search-index.js +0 -0
  29. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/content.css +0 -0
  30. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/custom.css +0 -0
  31. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/default/error.html.jinja2 +0 -0
  32. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/default/index.html.jinja2 +0 -0
  33. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/default/module.html.jinja2 +0 -0
  34. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/README.md +0 -0
  35. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/bootstrap-reboot.min.css +0 -0
  36. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/box-arrow-in-left.svg +0 -0
  37. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/elasticlunr.min.js +0 -0
  38. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/favicon.svg +0 -0
  39. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/navtoggle.svg +0 -0
  40. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/pdoc-logo.svg +0 -0
  41. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/deprecated/resources/favicon.svg +0 -0
  42. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/layout.css +0 -0
  43. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/livereload.html.jinja2 +0 -0
  44. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/math.html.jinja2 +0 -0
  45. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/bootstrap-reboot.min.css +0 -0
  46. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/box-arrow-in-left.svg +0 -0
  47. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/elasticlunr.min.js +0 -0
  48. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/exclamation-triangle-fill.svg +0 -0
  49. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/info-circle-fill.svg +0 -0
  50. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/lightning-fill.svg +0 -0
  51. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/navtoggle.svg +0 -0
  52. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/resources/pdoc-logo.svg +0 -0
  53. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/search.html.jinja2 +0 -0
  54. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/search.js.jinja2 +0 -0
  55. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/syntax-highlighting.css +0 -0
  56. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/templates/theme.css +0 -0
  57. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc/web.py +0 -0
  58. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc.egg-info/dependency_links.txt +0 -0
  59. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc.egg-info/entry_points.txt +0 -0
  60. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc.egg-info/requires.txt +0 -0
  61. {pdoc-13.0.1 → pdoc-13.1.1}/pdoc.egg-info/top_level.txt +0 -0
  62. {pdoc-13.0.1 → pdoc-13.1.1}/pyproject.toml +0 -0
  63. {pdoc-13.0.1 → pdoc-13.1.1}/setup.cfg +0 -0
  64. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_doc.py +0 -0
  65. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_doc_ast.py +0 -0
  66. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_doc_pyi.py +0 -0
  67. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_doc_types.py +0 -0
  68. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_docstrings.py +0 -0
  69. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_extract.py +0 -0
  70. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_main.py +0 -0
  71. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_render_helpers.py +0 -0
  72. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_search.py +0 -0
  73. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_smoke.py +0 -0
  74. {pdoc-13.0.1 → pdoc-13.1.1}/test/test_web.py +0 -0
@@ -4,6 +4,26 @@
4
4
 
5
5
  <!-- ✨ You do not need to add a pull request reference or an author, this will be added automatically by CI. ✨ -->
6
6
 
7
+
8
+ ## 2023-04-24: pdoc 13.1.1
9
+
10
+ - Fix rendering of dynamically modified docstrings.
11
+ ([#537](https://github.com/mitmproxy/pdoc/pull/537), @mhils)
12
+ - Updated bundled markdown2 version to fix a bug with empty code blocks.
13
+ ([#537](https://github.com/mitmproxy/pdoc/pull/537), @mhils)
14
+ - `pdoc.doc_ast.AstInfo` now has separate `func_docstrings` and `var_docstrings` attributes
15
+ instead of one combined one.
16
+ ([#537](https://github.com/mitmproxy/pdoc/pull/537), @mhils)
17
+
18
+ ## 2023-03-31: pdoc 13.1.0
19
+
20
+ - Add support for rendering [Mermaid diagrams](https://mermaid.js.org/) by passing `--mermaid`.
21
+ ([#525](https://github.com/mitmproxy/pdoc/pull/525), @thearchitector, @mhils)
22
+ - Add rudimentary support for `typing_extensions.Literal` on Python 3.7.
23
+ ([#527](https://github.com/mitmproxy/pdoc/pull/527), @mhils)
24
+
25
+ ## 2023-03-21: pdoc 13.0.1
26
+
7
27
  - Add additional Jinja2 blocks to allow a more fine-grained customization of the menu.
8
28
  ([#521](https://github.com/mitmproxy/pdoc/pull/521), @mikkelakromann)
9
29
  - Fix a crash in pdoc 13.0.0 when `__init__.py` is passed as a file to pdoc.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pdoc
3
- Version: 13.0.1
3
+ Version: 13.1.1
4
4
  Summary: API Documentation for Python Projects
5
5
  Author-email: Maximilian Hils <pdoc@maximilianhils.com>
6
6
  License: Unlicense
@@ -257,6 +257,12 @@ Run `pdoc --math`, and pdoc will render formulas in your docstrings. See
257
257
  [`math_demo`](https://pdoc.dev/docs/math/math_demo.html) for details.
258
258
 
259
259
 
260
+ ## ...render Mermaid diagrams?
261
+
262
+ Run `pdoc --mermaid`, and pdoc will render mermaid diagrams in your docstrings. See
263
+ [`mermaid_demo`](https://pdoc.dev/docs/mermaid/mermaid_demo.html) for details.
264
+
265
+
260
266
  ## ...add my project's logo?
261
267
 
262
268
  See [*Customizing pdoc*](#customizing-pdoc).
@@ -418,6 +424,7 @@ In addition, the following extra syntax elements are enabled:
418
424
  - **[markdown-in-html][]:** Allow the use of `markdown="1"` in a
419
425
  block HTML tag to have markdown processing be done on its contents.
420
426
  Similar to [PHP-Markdown Extra][] but with some limitations.
427
+ - **[mermaid][]:** Allows rendering Mermaid diagrams from included Markdown files using <code>```mermaid</code> fence blocks.
421
428
  - **[pyshell][]:** Treats unindented Python interactive shell
422
429
  sessions as `<code>` blocks.
423
430
  - **strike:** Parse `~~strikethrough~~` formatting.
@@ -434,6 +441,7 @@ In addition, the following extra syntax elements are enabled:
434
441
  [footnotes]: https://github.com/trentm/python-markdown2/wiki/footnotes
435
442
  [header-ids]: https://github.com/trentm/python-markdown2/wiki/header-ids
436
443
  [markdown-in-html]: https://github.com/trentm/python-markdown2/wiki/markdown-in-html
444
+ [mermaid]: https://github.com/trentm/python-markdown2/wiki/mermaid
437
445
  [pyshell]: https://github.com/trentm/python-markdown2/wiki/pyshell
438
446
  [tables]: https://github.com/trentm/python-markdown2/wiki/tables
439
447
  [GitHub-Flavored Markdown]: https://github.github.com/gfm/
@@ -453,7 +461,7 @@ You can find an example in [`examples/library-usage`](https://github.com/mitmpro
453
461
  from __future__ import annotations
454
462
 
455
463
  __docformat__ = "markdown" # explicitly disable rST processing in the examples above.
456
- __version__ = "13.0.1" # this is read from setup.py
464
+ __version__ = "13.1.1" # this is read from setup.py
457
465
 
458
466
  from pathlib import Path
459
467
  from typing import overload
@@ -96,6 +96,12 @@ renderopts.add_argument(
96
96
  default=False,
97
97
  help="Include MathJax from a CDN to enable math formula rendering.",
98
98
  )
99
+ renderopts.add_argument(
100
+ "--mermaid",
101
+ action=BooleanOptionalAction,
102
+ default=False,
103
+ help="Include Mermaid.js from a CDN to enable Mermaid diagram rendering.",
104
+ )
99
105
  renderopts.add_argument(
100
106
  "--search",
101
107
  action=BooleanOptionalAction,
@@ -176,6 +182,7 @@ def cli(args: list[str] | None = None) -> None:
176
182
  logo=opts.logo,
177
183
  logo_link=opts.logo_link,
178
184
  math=opts.math,
185
+ mermaid=opts.mermaid,
179
186
  search=opts.search,
180
187
  show_source=opts.show_source,
181
188
  template_directory=opts.template_directory,
@@ -109,8 +109,11 @@ else: # pragma: no cover
109
109
 
110
110
  # There is no Literal on 3.7, so we just make one up. It should not be used anyways!
111
111
 
112
- class Literal:
113
- pass
112
+ try:
113
+ from typing_extensions import Literal
114
+ except ImportError:
115
+ class Literal:
116
+ pass
114
117
 
115
118
  # get_origin is adapted from
116
119
  # https://github.com/python/cpython/blob/863eb7170b3017399fb2b786a1e3feb6457e54c2/Lib/typing.py#L1474-L1515
@@ -223,6 +223,11 @@ class Namespace(Doc[T], metaclass=ABCMeta):
223
223
  def _var_docstrings(self) -> dict[str, str]:
224
224
  """A mapping from some member variable names to their docstrings."""
225
225
 
226
+ @cached_property
227
+ @abstractmethod
228
+ def _func_docstrings(self) -> dict[str, str]:
229
+ """A mapping from some member function names to their raw (not processed by any @decorators) docstrings."""
230
+
226
231
  @cached_property
227
232
  @abstractmethod
228
233
  def _var_annotations(self) -> dict[str, Any]:
@@ -312,6 +317,8 @@ class Namespace(Doc[T], metaclass=ABCMeta):
312
317
  )
313
318
  if self._var_docstrings.get(name):
314
319
  doc.docstring = self._var_docstrings[name]
320
+ if self._func_docstrings.get(name) and not doc.docstring:
321
+ doc.docstring = self._func_docstrings[name]
315
322
  members[doc.name] = doc
316
323
 
317
324
  if isinstance(self, Module):
@@ -409,7 +416,11 @@ class Module(Namespace[types.ModuleType]):
409
416
 
410
417
  @cached_property
411
418
  def _var_docstrings(self) -> dict[str, str]:
412
- return doc_ast.walk_tree(self.obj).docstrings
419
+ return doc_ast.walk_tree(self.obj).var_docstrings
420
+
421
+ @cached_property
422
+ def _func_docstrings(self) -> dict[str, str]:
423
+ return doc_ast.walk_tree(self.obj).func_docstrings
413
424
 
414
425
  @cached_property
415
426
  def _var_annotations(self) -> dict[str, Any]:
@@ -478,7 +489,11 @@ class Module(Namespace[types.ModuleType]):
478
489
 
479
490
  @cached_property
480
491
  def _documented_members(self) -> set[str]:
481
- return self._var_docstrings.keys() | self._var_annotations.keys()
492
+ return (
493
+ self._var_docstrings.keys()
494
+ | self._func_docstrings.keys()
495
+ | self._var_annotations.keys()
496
+ )
482
497
 
483
498
  @cached_property
484
499
  def _member_objects(self) -> dict[str, Any]:
@@ -526,6 +541,8 @@ class Module(Namespace[types.ModuleType]):
526
541
  members[name] = obj
527
542
  for name in self._var_docstrings:
528
543
  members.setdefault(name, empty)
544
+ for name in self._func_docstrings:
545
+ members.setdefault(name, empty)
529
546
 
530
547
  members, notfound = doc_ast.sort_by_source(self.obj, {}, members)
531
548
  members.update(notfound)
@@ -587,7 +604,15 @@ class Class(Namespace[type]):
587
604
  def _var_docstrings(self) -> dict[str, str]:
588
605
  docstrings: dict[str, str] = {}
589
606
  for cls in self._mro:
590
- for name, docstr in doc_ast.walk_tree(cls).docstrings.items():
607
+ for name, docstr in doc_ast.walk_tree(cls).var_docstrings.items():
608
+ docstrings.setdefault(name, docstr)
609
+ return docstrings
610
+
611
+ @cached_property
612
+ def _func_docstrings(self) -> dict[str, str]:
613
+ docstrings: dict[str, str] = {}
614
+ for cls in self._mro:
615
+ for name, docstr in doc_ast.walk_tree(cls).func_docstrings.items():
591
616
  docstrings.setdefault(name, docstr)
592
617
  return docstrings
593
618
 
@@ -642,7 +667,11 @@ class Class(Namespace[type]):
642
667
  decls: dict[str, tuple[str, str]] = {}
643
668
  for cls in self._mro:
644
669
  treeinfo = doc_ast.walk_tree(cls)
645
- for name in treeinfo.docstrings.keys() | treeinfo.annotations.keys():
670
+ for name in (
671
+ treeinfo.var_docstrings.keys()
672
+ | treeinfo.func_docstrings.keys()
673
+ | treeinfo.annotations.keys()
674
+ ):
646
675
  decls.setdefault(name, (cls.__module__, f"{cls.__qualname__}.{name}"))
647
676
  for name in cls.__dict__:
648
677
  decls.setdefault(name, (cls.__module__, f"{cls.__qualname__}.{name}"))
@@ -85,8 +85,10 @@ def unparse(tree: ast.AST):
85
85
  class AstInfo:
86
86
  """The information extracted from walking the syntax tree."""
87
87
 
88
- docstrings: dict[str, str]
88
+ var_docstrings: dict[str, str]
89
89
  """A qualname -> docstring mapping."""
90
+ func_docstrings: dict[str, str]
91
+ """A qualname -> docstring mapping for functions."""
90
92
  annotations: dict[str, str]
91
93
  """A qualname -> annotation mapping.
92
94
 
@@ -104,7 +106,8 @@ def walk_tree(obj: types.ModuleType | type) -> AstInfo:
104
106
  def _walk_tree(
105
107
  tree: ast.Module | ast.ClassDef | ast.FunctionDef | ast.AsyncFunctionDef,
106
108
  ) -> AstInfo:
107
- docstrings = {}
109
+ var_docstrings = {}
110
+ func_docstrings = {}
108
111
  annotations = {}
109
112
  for a, b in _pairwise_longest(_nodes(tree)):
110
113
  if isinstance(a, ast.AnnAssign) and isinstance(a.target, ast.Name) and a.simple:
@@ -122,7 +125,7 @@ def _walk_tree(
122
125
  elif isinstance(a, ast.FunctionDef) and a.body:
123
126
  first = a.body[0]
124
127
  if isinstance(first, ast.Expr) and isinstance(first.value, ast.Str):
125
- docstrings[a.name] = inspect.cleandoc(first.value.s).strip()
128
+ func_docstrings[a.name] = inspect.cleandoc(first.value.s).strip()
126
129
  continue
127
130
  else:
128
131
  continue
@@ -131,14 +134,15 @@ def _walk_tree(
131
134
  and isinstance(b.value, ast.Constant)
132
135
  and isinstance(b.value.value, str)
133
136
  ):
134
- docstrings[name] = inspect.cleandoc(b.value.value).strip()
137
+ var_docstrings[name] = inspect.cleandoc(b.value.value).strip()
135
138
  elif isinstance(b, ast.Expr) and isinstance(
136
139
  b.value, ast.Str
137
140
  ): # pragma: no cover
138
141
  # Python <= 3.7
139
- docstrings[name] = inspect.cleandoc(b.value.s).strip()
142
+ var_docstrings[name] = inspect.cleandoc(b.value.s).strip()
140
143
  return AstInfo(
141
- docstrings,
144
+ var_docstrings,
145
+ func_docstrings,
142
146
  annotations,
143
147
  )
144
148