pdoc 14.5.1__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/render_helpers.py CHANGED
@@ -57,6 +57,7 @@ Overwrite this to configure pygments highlighting of signatures.
57
57
 
58
58
  # Keep in sync with the documentation in pdoc/__init__.py!
59
59
  markdown_extensions = {
60
+ "alerts": None,
60
61
  "code-friendly": None,
61
62
  "cuddled-lists": None,
62
63
  "fenced-code-blocks": {"cssclass": formatter.cssclass},
@@ -207,6 +208,10 @@ def possible_sources(
207
208
  We return both candidates as we don't know if _internal.py exists.
208
209
  It may not be in all_modules because it's been excluded by `__all__`.
209
210
  However, if `examplepkg._internal` is in all_modules we know that it can only be that option.
211
+
212
+ >>> possible_sources(["examplepkg"], "examplepkg.Foo.bar")
213
+ examplepkg.Foo, bar
214
+ examplepkg, Foo.bar
210
215
  """
211
216
  if identifier in all_modules:
212
217
  yield identifier, ""
@@ -273,6 +278,34 @@ def qualname_candidates(identifier: str, context_qualname: str) -> list[str]:
273
278
  return ret
274
279
 
275
280
 
281
+ def module_candidates(identifier: str, current_module: str) -> Iterable[str]:
282
+ """
283
+ Given an identifier and the current module name, return the module names we should look at
284
+ to find where the target object is exposed. Module names are ordered by preferences, i.e.
285
+ we always prefer the current module and then top-level modules over their children.
286
+
287
+ >>> module_candidates("foo.bar.baz", "qux")
288
+ qux
289
+ foo
290
+ foo.bar
291
+ foo.bar.baz
292
+ >>> module_candidates("foo.bar.baz", "foo.bar")
293
+ foo.bar
294
+ foo
295
+ foo.bar.baz
296
+ """
297
+ yield current_module
298
+
299
+ end = identifier.find(".")
300
+ while end > 0:
301
+ if (name := identifier[:end]) != current_module:
302
+ yield name
303
+ end = identifier.find(".", end + 1)
304
+
305
+ if identifier != current_module:
306
+ yield identifier
307
+
308
+
276
309
  @pass_context
277
310
  def linkify(context: Context, code: str, namespace: str = "") -> str:
278
311
  """
@@ -282,6 +315,9 @@ def linkify(context: Context, code: str, namespace: str = "") -> str:
282
315
  """
283
316
 
284
317
  def linkify_repl(m: re.Match):
318
+ """
319
+ Resolve `text` to the most suitable documentation object.
320
+ """
285
321
  text = m.group(0)
286
322
  plain_text = text.replace(
287
323
  '</span><span class="o">.</span><span class="n">', "."
@@ -289,7 +325,7 @@ def linkify(context: Context, code: str, namespace: str = "") -> str:
289
325
  identifier = removesuffix(plain_text, "()")
290
326
  mod: pdoc.doc.Module = context["module"]
291
327
 
292
- # Check if this is a relative reference?
328
+ # Check if this is a relative reference. These cannot be local and need to be resolved.
293
329
  if identifier.startswith("."):
294
330
  taken_from_mod = mod
295
331
  if namespace and (ns := mod.get(namespace)):
@@ -306,59 +342,61 @@ def linkify(context: Context, code: str, namespace: str = "") -> str:
306
342
  parent_module = parent_module.rpartition(".")[0]
307
343
  identifier = parent_module + identifier
308
344
  else:
309
- # Check if this is a local reference within this module?
345
+ # Is this a local reference within this module?
310
346
  for qualname in qualname_candidates(identifier, namespace):
311
347
  doc = mod.get(qualname)
312
348
  if doc and context["is_public"](doc).strip():
313
349
  return f'<a href="#{qualname}">{plain_text}</a>'
314
350
 
315
- module = ""
316
- qualname = ""
351
+ # Is this a reference pointing straight at a module?
352
+ if identifier in context["all_modules"]:
353
+ return f'<a href="{relative_link(context["module"].modulename, identifier)}">{identifier}</a>'
354
+
317
355
  try:
318
- # Check if the object we are interested in is imported and re-exposed in the current namespace.
319
- for module, qualname in possible_sources(
320
- context["all_modules"], identifier
321
- ):
322
- doc = mod.get(qualname)
356
+ sources = list(possible_sources(context["all_modules"], identifier))
357
+ except ValueError:
358
+ # possible_sources did not find a parent module.
359
+ return text
360
+
361
+ # Try to find the actual target object so that we can then later verify
362
+ # that objects exposed at a parent module with the same name point to it.
363
+ target_object = None
364
+ for module_name, qualname in sources:
365
+ if doc := context["all_modules"].get(module_name, {}).get(qualname):
366
+ target_object = doc.obj
367
+ break
368
+
369
+ # Look at the different modules where our target object may be exposed.
370
+ for module_name in module_candidates(identifier, mod.modulename):
371
+ module: pdoc.doc.Module | None = context["all_modules"].get(module_name)
372
+ if not module:
373
+ continue
374
+
375
+ for _, qualname in sources:
376
+ doc = module.get(qualname)
377
+ # Check if they have an object with the same name,
378
+ # and verify that it's pointing to the right thing and is public.
323
379
  if (
324
380
  doc
325
- and doc.taken_from == (module, qualname)
381
+ and (target_object is doc.obj or target_object is None)
326
382
  and context["is_public"](doc).strip()
327
383
  ):
328
- if plain_text.endswith("()"):
329
- plain_text = f"{doc.qualname}()"
384
+ if module == mod:
385
+ url_text = qualname
330
386
  else:
331
- plain_text = doc.qualname
332
- return f'<a href="#{qualname}">{plain_text}</a>'
333
- except ValueError:
334
- # possible_sources did not find a parent module.
335
- return text
336
- else:
337
- # It's not, but we now know the parent module. Does the target exist?
338
- doc = context["all_modules"][module]
339
- if qualname:
340
- assert isinstance(doc, pdoc.doc.Module)
341
- doc = doc.get(qualname)
342
- target_exists_and_public = (
343
- doc is not None and context["is_public"](doc).strip()
344
- )
345
- if target_exists_and_public:
346
- assert doc is not None # mypy
347
- if qualname:
348
- qualname = f"#{qualname}"
349
- if plain_text.endswith("()"):
350
- plain_text = f"{doc.fullname}()"
351
- else:
352
- plain_text = doc.fullname
353
- return f'<a href="{relative_link(context["module"].modulename, module)}{qualname}">{plain_text}</a>'
354
- else:
355
- return text
387
+ url_text = doc.fullname
388
+ if plain_text.endswith("()"):
389
+ url_text += "()"
390
+ return f'<a href="{relative_link(context["module"].modulename, doc.modulename)}#{qualname}">{url_text}</a>'
391
+
392
+ # No matches found.
393
+ return text
356
394
 
357
395
  return Markup(
358
396
  re.sub(
359
397
  r"""
360
398
  # Part 1: foo.bar or foo.bar() (without backticks)
361
- (?<![/=?#&]) # heuristic: not part of a URL
399
+ (?<![/=?#&\.]) # heuristic: not part of a URL
362
400
  # First part of the identifier (e.g. "foo") - this is optional for relative references.
363
401
  (?:
364
402
  \b
@@ -27,35 +27,39 @@ This makes sure that the pdoc styling doesn't leak to the rest of the page when
27
27
 
28
28
 
29
29
  /* Admonitions */
30
- .pdoc .pdoc-alert {
30
+ .pdoc .alert {
31
31
  padding: 1rem 1rem 1rem calc(1.5rem + 24px);
32
32
  border: 1px solid transparent;
33
33
  border-radius: .25rem;
34
34
  background-repeat: no-repeat;
35
- background-position: 1rem center;
35
+ background-position: .75rem center;
36
36
  margin-bottom: 1rem;
37
37
  }
38
38
 
39
- .pdoc .pdoc-alert > *:last-child {
39
+ .pdoc .alert > em {
40
+ display: none;
41
+ }
42
+
43
+ .pdoc .alert > *:last-child {
40
44
  margin-bottom: 0;
41
45
  }
42
46
 
43
47
  /* Admonitions are currently not stylable via theme.css */
44
- .pdoc .pdoc-alert-note {
48
+ .pdoc .alert.note {
45
49
  color: #084298;
46
50
  background-color: #cfe2ff;
47
51
  border-color: #b6d4fe;
48
52
  background-image: url("data:image/svg+xml,{% filter urlencode %}{% include 'resources/info-circle-fill.svg' %}{% endfilter %}");
49
53
  }
50
54
 
51
- .pdoc .pdoc-alert-warning {
55
+ .pdoc .alert.warning {
52
56
  color: #664d03;
53
57
  background-color: #fff3cd;
54
58
  border-color: #ffecb5;
55
59
  background-image: url("data:image/svg+xml,{% filter urlencode %}{% include 'resources/exclamation-triangle-fill.svg' %}{% endfilter %}");
56
60
  }
57
61
 
58
- .pdoc .pdoc-alert-danger {
62
+ .pdoc .alert.danger {
59
63
  color: #842029;
60
64
  background-color: #f8d7da;
61
65
  border-color: #f5c2c7;
@@ -0,0 +1,5 @@
1
+ Copyright 2024 Maximilian Hils
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
4
+
5
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pdoc
3
- Version: 14.5.1
3
+ Version: 14.6.0
4
4
  Summary: API Documentation for Python Projects
5
5
  Author-email: Maximilian Hils <pdoc@maximilianhils.com>
6
- License: Unlicense
6
+ License: MIT-0
7
7
  Project-URL: Homepage, https://pdoc.dev
8
8
  Project-URL: Source, https://github.com/mitmproxy/pdoc/
9
9
  Project-URL: Documentation, https://pdoc.dev/docs/pdoc.html
@@ -1,23 +1,23 @@
1
- pdoc/__init__.py,sha256=bhq50jgLNwpui952AYj4NyCl5ahLjjn0czk_sChTmrk,21176
2
- pdoc/__main__.py,sha256=79uLvuQ8eHvU_tzXy4akpKMdDF2DN0xg5VPgv4pmyGo,8418
1
+ pdoc/__init__.py,sha256=SR29piNT7ZRfryJ7b-MAHzsmUEN1__5kuwBatXofZ88,21456
2
+ pdoc/__main__.py,sha256=7Xrkxw6-qaSfZfCGFlunl3TfR93uWiCSnvoFABuOmmE,8418
3
3
  pdoc/_compat.py,sha256=wKGKTxTTxfNjEcKPwvtuvNeOyiozPfL52h8PArKky-0,3843
4
- pdoc/doc.py,sha256=zmXHLmMBB-evOSXyV6cR-bYfQSI6bBIIwODJQZtT7Pk,48400
4
+ pdoc/doc.py,sha256=WsxiFNwiqqY3Gn12Ee-hafVrN_AbCXCs_SC8jaTTWfQ,48881
5
5
  pdoc/doc_ast.py,sha256=ChAOF7qcuRQbdWnRamH6OUtvvIo-JOVCetPjRnb2a3w,11299
6
6
  pdoc/doc_pyi.py,sha256=TT6vbugw53vDgunegloJONSLRAaeXswqKah1_TVuUwA,4567
7
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
8
+ pdoc/docstrings.py,sha256=IdjpZYROqRNRfj1tmAKVuB2WfS1HIMqQwOeYpvbvXio,16384
9
+ pdoc/extract.py,sha256=7QqxtsKfvcpFi2yBvpFPQe-YR6KAW_L5PCh9v9g1m_c,14307
10
10
  pdoc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  pdoc/render.py,sha256=-gbybpZQUJICYABZr4HJLBsX43vsMOl1Vo1FIshz9pU,7054
12
- pdoc/render_helpers.py,sha256=clTbaHYpyK2rMvjhUQpdO0bqrjjcAgFkimuJMZ-uCXc,18708
12
+ pdoc/render_helpers.py,sha256=mqMLdsr4NQiUPQFa6FsRh5z2Id78f4CmOz84cUA_tTM,19985
13
13
  pdoc/search.py,sha256=RGFaRftEQOg1Mw4FEOmJVRY9DhBncBYSFi5r4MSknTM,7248
14
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
- pdoc/markdown2/__init__.py,sha256=d12k9Kr2TnRRz0ga_VH73R5QkW2UjGO_wDzSR6kFJpI,127882
17
+ pdoc/markdown2/__init__.py,sha256=guvOlezAha8NQBH8TFkEwiP4zFy5tsV2NVYiEOWD2jg,159248
18
18
  pdoc/templates/README.md,sha256=ukxrGoYYCIYkScS5j2Dge8c3VEd01AzOiIKq6yl5OqE,1780
19
19
  pdoc/templates/build-search-index.js,sha256=igiRW84j_aRFmGv5j48e8gnWeTgfdL8Rs930vHOUYyU,982
20
- pdoc/templates/content.css,sha256=eBji75EG9DRr8L2NftE3LesQqW4o56_yIt0NXq_cCZY,9194
20
+ pdoc/templates/content.css,sha256=TuLZj-fv_50WB2s5uCrb_DN6toOFjaylFVd7j2k9ABE,9213
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
@@ -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.5.1.dist-info/LICENSE,sha256=fhLl30uuEsshWBuhV87SDhmGoFCN0Q0Oikq5pM-U6Fw,1211
51
- pdoc-14.5.1.dist-info/METADATA,sha256=P7b0Scr4vqcuncgp_3LwSwz1zvqpd4uOwiIxWojZgS0,7289
52
- pdoc-14.5.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
53
- pdoc-14.5.1.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
54
- pdoc-14.5.1.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
55
- pdoc-14.5.1.dist-info/RECORD,,
50
+ pdoc-14.6.0.dist-info/LICENSE,sha256=LrhIeJ7gKTDPyOX9YVuZGr9mpmyjpkvqH6LjxvE0szM,898
51
+ pdoc-14.6.0.dist-info/METADATA,sha256=CLKP-hbqqFiinS5d2YyqnJRiJWsfyy_Blv68-j3QRak,7285
52
+ pdoc-14.6.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
53
+ pdoc-14.6.0.dist-info/entry_points.txt,sha256=-bK-S1ZvmqCWqi1hGnsl5nayWkzXB1BEs-Cynh5QZaI,43
54
+ pdoc-14.6.0.dist-info/top_level.txt,sha256=rg5eIToBHzwTfZZi1E7NVHgie5joQuSuU1rWV0qKS9k,5
55
+ pdoc-14.6.0.dist-info/RECORD,,
@@ -1,24 +0,0 @@
1
- This is free and unencumbered software released into the public domain.
2
-
3
- Anyone is free to copy, modify, publish, use, compile, sell, or
4
- distribute this software, either in source code form or as a compiled
5
- binary, for any purpose, commercial or non-commercial, and by any
6
- means.
7
-
8
- In jurisdictions that recognize copyright laws, the author or authors
9
- of this software dedicate any and all copyright interest in the
10
- software to the public domain. We make this dedication for the benefit
11
- of the public at large and to the detriment of our heirs and
12
- successors. We intend this dedication to be an overt act of
13
- relinquishment in perpetuity of all present and future rights to this
14
- software under copyright law.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
23
-
24
- For more information, please refer to <http://unlicense.org/>
File without changes