pdoc 14.2.0__py3-none-any.whl → 14.4.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
@@ -176,18 +176,21 @@ class GoldenRetriever(Dog):
176
176
 
177
177
  The public interface of a module is determined through one of two
178
178
  ways.
179
-
180
179
  - If `__all__` is defined in the module, then all identifiers in that list will be considered public.
181
180
  No other identifiers will be considered public.
182
- - If `__all__` is not defined, then pdoc will consider all members public that
183
- 1. do not start with an underscore,
184
- 2. don't have `@private` in their docstring,
185
- 2. and are defined in the current module (i.e. they are not imported).
181
+ - If `__all__` is not defined, then pdoc will consider all items public that do not start with an
182
+ underscore and that are defined in the current module (i.e. they are not imported).
183
+
184
+ If you want to override the default behavior for a particular item,
185
+ you can do so by including an annotation in its docstring:
186
+
187
+ - `@private` hides an item unconditionally.
188
+ - <code>&#64;public</code> shows an item unconditionally.
186
189
 
187
- In general, we recommend keeping these conventions:
190
+ In general, we recommend keeping the following conventions:
188
191
 
189
192
  - If you want to document a private member, consider making it public.
190
- - If you want to hide a public member, consider making it private or add `@private` to their docstring,
193
+ - If you want to hide a public member, consider making it private.
191
194
  - If you want to document a special `__dunder__` method, the recommended way to do so is
192
195
  to not document the dunder method specifically, but to add some usage examples in the class documentation.
193
196
 
@@ -462,7 +465,7 @@ You can find an example in [`examples/library-usage`](https://github.com/mitmpro
462
465
  from __future__ import annotations
463
466
 
464
467
  __docformat__ = "markdown" # explicitly disable rST processing in the examples above.
465
- __version__ = "14.2.0" # this is read from setup.py
468
+ __version__ = "14.4.0" # this is read from setup.py
466
469
 
467
470
  from pathlib import Path
468
471
  from typing import overload
pdoc/doc.py CHANGED
@@ -283,6 +283,9 @@ class Namespace(Doc[T], metaclass=ABCMeta):
283
283
  default_value=empty,
284
284
  taken_from=taken_from,
285
285
  )
286
+ doc.source = doc_f.source
287
+ doc.source_file = doc_f.source_file
288
+ doc.source_lines = doc_f.source_lines
286
289
  elif inspect.isroutine(obj):
287
290
  doc = Function(self.modulename, qualname, obj, taken_from) # type: ignore
288
291
  elif (
@@ -884,6 +887,8 @@ class Function(Doc[types.FunctionType]):
884
887
  unwrapped = func.__func__ # type: ignore
885
888
  elif isinstance(func, singledispatchmethod):
886
889
  unwrapped = func.func # type: ignore
890
+ elif hasattr(func, "__wrapped__"):
891
+ unwrapped = func.__wrapped__
887
892
  else:
888
893
  unwrapped = func
889
894
  super().__init__(modulename, qualname, unwrapped, taken_from)
@@ -1136,7 +1141,7 @@ class Variable(Doc[None]):
1136
1141
  warnings.warn(f"repr({self.fullname}) raised an exception ({e!r})")
1137
1142
  return ""
1138
1143
 
1139
- pretty = re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", pretty)
1144
+ pretty = _remove_memory_addresses(pretty)
1140
1145
  return pretty
1141
1146
 
1142
1147
  @cached_property
@@ -1177,7 +1182,8 @@ class _PrettySignature(inspect.Signature):
1177
1182
  render_pos_only_separator = False
1178
1183
  render_kw_only_separator = True
1179
1184
  for param in self.parameters.values():
1180
- formatted = re.sub(r" at 0x[0-9a-fA-F]+(?=>$)", "", str(param))
1185
+ formatted = str(param)
1186
+ formatted = _remove_memory_addresses(formatted)
1181
1187
 
1182
1188
  kind = param.kind
1183
1189
 
@@ -1295,3 +1301,8 @@ def _safe_getdoc(obj: Any) -> str:
1295
1301
  return ""
1296
1302
  else:
1297
1303
  return doc.strip()
1304
+
1305
+
1306
+ def _remove_memory_addresses(x: str) -> str:
1307
+ """Remove memory addresses from repr() output"""
1308
+ return re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", x)
pdoc/doc_ast.py CHANGED
@@ -32,7 +32,6 @@ if TYPE_CHECKING:
32
32
  def get_source(obj: Any) -> str:
33
33
  """
34
34
  Returns the source code of the Python object `obj` as a str.
35
- This tries to first unwrap the method if it is wrapped and then calls `inspect.getsource`.
36
35
 
37
36
  If this fails, an empty string is returned.
38
37
  """
pdoc/doc_pyi.py CHANGED
@@ -9,6 +9,7 @@ from pathlib import Path
9
9
  import sys
10
10
  import traceback
11
11
  import types
12
+ import typing
12
13
  from unittest import mock
13
14
  import warnings
14
15
 
@@ -16,6 +17,8 @@ from pdoc import doc
16
17
 
17
18
  from ._compat import cache
18
19
 
20
+ overload_docstr = typing.overload(lambda: None).__doc__
21
+
19
22
 
20
23
  @cache
21
24
  def find_stub_file(module_name: str) -> Path | None:
@@ -68,6 +71,11 @@ def _patch_doc(target_doc: doc.Doc, stub_mod: doc.Module) -> None:
68
71
  stub_doc = stub_mod
69
72
 
70
73
  if isinstance(target_doc, doc.Function) and isinstance(stub_doc, doc.Function):
74
+ # pyi files have functions where all defs have @overload.
75
+ # We don't want to pick up the docstring from the typing helper.
76
+ if stub_doc.docstring == overload_docstr:
77
+ stub_doc.docstring = ""
78
+
71
79
  target_doc.signature = stub_doc.signature
72
80
  target_doc.funcdef = stub_doc.funcdef
73
81
  target_doc.docstring = stub_doc.docstring or target_doc.docstring
@@ -209,7 +209,7 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
209
209
  {% enddefaultmacro %}
210
210
  {% defaultmacro docstring(var) %}
211
211
  {% if var.docstring %}
212
- <div class="docstring">{{ var.docstring | to_markdown | to_html | linkify(namespace=var.qualname) }}</div>
212
+ <div class="docstring">{{ var.docstring | replace("@public", "") | to_markdown | to_html | linkify(namespace=var.qualname) }}</div>
213
213
  {% endif %}
214
214
  {% enddefaultmacro %}
215
215
  {% defaultmacro nav_members(members) %}
@@ -239,10 +239,13 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
239
239
  Implementing this as a macro makes it very easy to override with a custom template, see
240
240
  https://github.com/mitmproxy/pdoc/tree/main/examples/custom-template.
241
241
  #}
242
- {% if not include_undocumented and not doc.docstring %}
243
- {# hide members that are undocumented if include_undocumented has been toggled off. #}
244
- {% elif doc.docstring and "@private" in doc.docstring %}
242
+ {% if "@private" in doc.docstring %}
245
243
  {# hide members explicitly marked as @private #}
244
+ {% elif "@public" in doc.docstring %}
245
+ {# show members explicitly marked as @public #}
246
+ true
247
+ {% elif not include_undocumented and not doc.docstring %}
248
+ {# hide members that are undocumented if include_undocumented has been toggled off. #}
246
249
  {% elif doc.name == "__init__" and (doc.docstring or (doc.kind == "function" and doc.signature_without_self.parameters)) %}
247
250
  {# show constructors that have a docstring or at least one extra argument #}
248
251
  true
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pdoc
3
- Version: 14.2.0
3
+ Version: 14.4.0
4
4
  Summary: API Documentation for Python Projects
5
5
  Author-email: Maximilian Hils <pdoc@maximilianhils.com>
6
6
  License: Unlicense
@@ -1,9 +1,9 @@
1
- pdoc/__init__.py,sha256=YOPJ3nMnuABKGuQUQ1YNWhLXV8ANjZ917wU3jzn3ddI,20792
1
+ pdoc/__init__.py,sha256=Bu6WuxUPvQzuWM79MxWtx_h82cUpSO5uOvjsW0bdyKg,20937
2
2
  pdoc/__main__.py,sha256=79uLvuQ8eHvU_tzXy4akpKMdDF2DN0xg5VPgv4pmyGo,8418
3
3
  pdoc/_compat.py,sha256=wKGKTxTTxfNjEcKPwvtuvNeOyiozPfL52h8PArKky-0,3843
4
- pdoc/doc.py,sha256=4FtcX8Pa3YJpY5-dobUcf7oAFypmjD232XSc6UEJeIg,47993
5
- pdoc/doc_ast.py,sha256=LBYx8NuXsoxqD_MsmDsI9ShMvOK0tnCDvu0Hv1hBies,11405
6
- pdoc/doc_pyi.py,sha256=u2PhgUEx46SUr3wZrlhkUVcs5mbzxuAizKYQevWRJys,3906
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
7
  pdoc/doc_types.py,sha256=P6HwAIKotcE7iKJtKpZPvbok7LpeqYEtrgUcknuMcek,8467
8
8
  pdoc/docstrings.py,sha256=F_knLP93uD5RiHUN1Ha7mGTxzadiG1880-Go0dXmdh0,14990
9
9
  pdoc/extract.py,sha256=G8mGJRHzhbckXGNuYO-hQUL51HItNkJ7ehK5g7By3o8,14277
@@ -30,7 +30,7 @@ pdoc/templates/theme.css,sha256=yjnbtPVmqaifTINsA5sK2a3e1aoFO0UlOMgOSKUgLvI,397
30
30
  pdoc/templates/default/error.html.jinja2,sha256=RqH14o6ZV79uBO14gKSjwObXFKKczkcLTMe1orurEJk,970
31
31
  pdoc/templates/default/frame.html.jinja2,sha256=Qp5zlts8Bl-O2f0cxJHH_QdmAkMtJJjNVA0ZU2Mbwl8,2164
32
32
  pdoc/templates/default/index.html.jinja2,sha256=MkzVYMWUuJgscty3jVbDtcEfB1vz-bp3v_sMa5MzevU,2381
33
- pdoc/templates/default/module.html.jinja2,sha256=KuBvhTefUteJ1unUA5DVedbjTTqkfA86nU4s_CF23aA,13123
33
+ pdoc/templates/default/module.html.jinja2,sha256=8IfopEB0v7b24EmNGYbuUSO4zpXmRj0-_YL1YtWB7lE,13241
34
34
  pdoc/templates/deprecated/README.md,sha256=8HPj4Bu6EPAdHbH5CQVYgcD580zpkhqbwiSFoLAVB1Q,339
35
35
  pdoc/templates/deprecated/bootstrap-reboot.min.css,sha256=-u1DTWljwtvjAc8X-ihFhIixKaPcs4w_uZ_CYvvP9-o,207
36
36
  pdoc/templates/deprecated/box-arrow-in-left.svg,sha256=-u1DTWljwtvjAc8X-ihFhIixKaPcs4w_uZ_CYvvP9-o,207
@@ -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.2.0.dist-info/LICENSE,sha256=fhLl30uuEsshWBuhV87SDhmGoFCN0Q0Oikq5pM-U6Fw,1211
51
- pdoc-14.2.0.dist-info/METADATA,sha256=J-DPKCEO0J898f_48qs9pspc_uoJvZTVoZDcYCrs5DU,7470
52
- pdoc-14.2.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
53
- pdoc-14.2.0.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
54
- pdoc-14.2.0.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
55
- pdoc-14.2.0.dist-info/RECORD,,
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,,
File without changes
File without changes