mkdocstrings-python 1.19.0__py3-none-any.whl → 2.0.1__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.
Files changed (147) hide show
  1. mkdocstrings_handlers/python/__init__.py +0 -4
  2. mkdocstrings_handlers/python/_internal/handler.py +6 -45
  3. mkdocstrings_handlers/python/_internal/rendering.py +14 -111
  4. mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja +2 -4
  5. mkdocstrings_handlers/python/templates/material/_base/children.html.jinja +9 -6
  6. mkdocstrings_handlers/python/templates/material/_base/class.html.jinja +13 -18
  7. mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja +5 -9
  8. mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja +1 -2
  9. mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja +1 -2
  10. mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja +1 -2
  11. mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja +1 -2
  12. mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja +4 -8
  13. mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja +7 -14
  14. mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja +4 -8
  15. mkdocstrings_handlers/python/templates/material/_base/docstring/receives.html.jinja +5 -10
  16. mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja +5 -10
  17. mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html.jinja +1 -1
  18. mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html.jinja +9 -9
  19. mkdocstrings_handlers/python/templates/material/_base/docstring/warns.html.jinja +4 -8
  20. mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html.jinja +5 -10
  21. mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja +15 -30
  22. mkdocstrings_handlers/python/templates/material/_base/function.html.jinja +5 -9
  23. mkdocstrings_handlers/python/templates/material/_base/language.html.jinja +3 -6
  24. mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja +5 -0
  25. mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja +13 -8
  26. mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja +13 -8
  27. mkdocstrings_handlers/python/templates/material/_base/module.html.jinja +4 -8
  28. mkdocstrings_handlers/python/templates/material/_base/signature.html.jinja +3 -6
  29. mkdocstrings_handlers/python/templates/material/_base/summary/attributes.html.jinja +1 -2
  30. mkdocstrings_handlers/python/templates/material/_base/summary/classes.html.jinja +1 -2
  31. mkdocstrings_handlers/python/templates/material/_base/summary/functions.html.jinja +1 -2
  32. mkdocstrings_handlers/python/templates/material/_base/summary/modules.html.jinja +1 -2
  33. mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html.jinja +1 -2
  34. mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja +5 -10
  35. mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja +3 -6
  36. mkdocstrings_handlers/python/templates/material/_base/type_parameters.html.jinja +2 -4
  37. mkdocstrings_handlers/python/templates/readthedocs/_base/class.html.jinja +18 -18
  38. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/attributes.html.jinja +2 -4
  39. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/other_parameters.html.jinja +2 -4
  40. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/parameters.html.jinja +3 -6
  41. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/raises.html.jinja +2 -4
  42. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/receives.html.jinja +2 -4
  43. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/returns.html.jinja +2 -4
  44. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/warns.html.jinja +2 -4
  45. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/yields.html.jinja +2 -4
  46. mkdocstrings_handlers/python/templates/readthedocs/_base/language.html.jinja +3 -6
  47. mkdocstrings_python-2.0.1.dist-info/METADATA +179 -0
  48. mkdocstrings_python-2.0.1.dist-info/RECORD +121 -0
  49. {mkdocstrings_python-1.19.0.dist-info → mkdocstrings_python-2.0.1.dist-info}/WHEEL +1 -1
  50. mkdocstrings_handlers/python/config.py +0 -17
  51. mkdocstrings_handlers/python/handler.py +0 -17
  52. mkdocstrings_handlers/python/rendering.py +0 -17
  53. mkdocstrings_handlers/python/templates/material/_base/attribute.html +0 -10
  54. mkdocstrings_handlers/python/templates/material/_base/children.html +0 -10
  55. mkdocstrings_handlers/python/templates/material/_base/class.html +0 -10
  56. mkdocstrings_handlers/python/templates/material/_base/docstring/admonition.html +0 -10
  57. mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html +0 -10
  58. mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html +0 -10
  59. mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html +0 -10
  60. mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html +0 -10
  61. mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html +0 -10
  62. mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html +0 -10
  63. mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html +0 -10
  64. mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html +0 -10
  65. mkdocstrings_handlers/python/templates/material/_base/docstring/receives.html +0 -10
  66. mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html +0 -10
  67. mkdocstrings_handlers/python/templates/material/_base/docstring/type_aliases.html +0 -10
  68. mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html +0 -10
  69. mkdocstrings_handlers/python/templates/material/_base/docstring/warns.html +0 -10
  70. mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html +0 -10
  71. mkdocstrings_handlers/python/templates/material/_base/docstring.html +0 -10
  72. mkdocstrings_handlers/python/templates/material/_base/expression.html +0 -10
  73. mkdocstrings_handlers/python/templates/material/_base/function.html +0 -10
  74. mkdocstrings_handlers/python/templates/material/_base/labels.html +0 -10
  75. mkdocstrings_handlers/python/templates/material/_base/language.html +0 -10
  76. mkdocstrings_handlers/python/templates/material/_base/languages/en.html +0 -10
  77. mkdocstrings_handlers/python/templates/material/_base/languages/ja.html +0 -10
  78. mkdocstrings_handlers/python/templates/material/_base/languages/zh.html +0 -10
  79. mkdocstrings_handlers/python/templates/material/_base/module.html +0 -10
  80. mkdocstrings_handlers/python/templates/material/_base/signature.html +0 -10
  81. mkdocstrings_handlers/python/templates/material/_base/summary/attributes.html +0 -10
  82. mkdocstrings_handlers/python/templates/material/_base/summary/classes.html +0 -10
  83. mkdocstrings_handlers/python/templates/material/_base/summary/functions.html +0 -10
  84. mkdocstrings_handlers/python/templates/material/_base/summary/modules.html +0 -10
  85. mkdocstrings_handlers/python/templates/material/_base/summary/type_aliases.html +0 -10
  86. mkdocstrings_handlers/python/templates/material/_base/summary.html +0 -10
  87. mkdocstrings_handlers/python/templates/material/_base/type_alias.html +0 -10
  88. mkdocstrings_handlers/python/templates/material/_base/type_parameters.html +0 -10
  89. mkdocstrings_handlers/python/templates/material/attribute.html +0 -2
  90. mkdocstrings_handlers/python/templates/material/children.html +0 -2
  91. mkdocstrings_handlers/python/templates/material/class.html +0 -2
  92. mkdocstrings_handlers/python/templates/material/docstring/admonition.html +0 -2
  93. mkdocstrings_handlers/python/templates/material/docstring/attributes.html +0 -2
  94. mkdocstrings_handlers/python/templates/material/docstring/classes.html +0 -2
  95. mkdocstrings_handlers/python/templates/material/docstring/examples.html +0 -2
  96. mkdocstrings_handlers/python/templates/material/docstring/functions.html +0 -2
  97. mkdocstrings_handlers/python/templates/material/docstring/modules.html +0 -2
  98. mkdocstrings_handlers/python/templates/material/docstring/other_parameters.html +0 -2
  99. mkdocstrings_handlers/python/templates/material/docstring/parameters.html +0 -2
  100. mkdocstrings_handlers/python/templates/material/docstring/raises.html +0 -2
  101. mkdocstrings_handlers/python/templates/material/docstring/receives.html +0 -2
  102. mkdocstrings_handlers/python/templates/material/docstring/returns.html +0 -2
  103. mkdocstrings_handlers/python/templates/material/docstring/warns.html +0 -2
  104. mkdocstrings_handlers/python/templates/material/docstring/yields.html +0 -2
  105. mkdocstrings_handlers/python/templates/material/docstring.html +0 -2
  106. mkdocstrings_handlers/python/templates/material/expression.html +0 -2
  107. mkdocstrings_handlers/python/templates/material/function.html +0 -2
  108. mkdocstrings_handlers/python/templates/material/labels.html +0 -2
  109. mkdocstrings_handlers/python/templates/material/language.html +0 -2
  110. mkdocstrings_handlers/python/templates/material/languages/en.html +0 -2
  111. mkdocstrings_handlers/python/templates/material/languages/ja.html +0 -2
  112. mkdocstrings_handlers/python/templates/material/languages/zh.html +0 -2
  113. mkdocstrings_handlers/python/templates/material/module.html +0 -2
  114. mkdocstrings_handlers/python/templates/material/signature.html +0 -2
  115. mkdocstrings_handlers/python/templates/material/summary/attributes.html +0 -2
  116. mkdocstrings_handlers/python/templates/material/summary/classes.html +0 -2
  117. mkdocstrings_handlers/python/templates/material/summary/functions.html +0 -2
  118. mkdocstrings_handlers/python/templates/material/summary/modules.html +0 -2
  119. mkdocstrings_handlers/python/templates/material/summary.html +0 -2
  120. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/attributes.html +0 -10
  121. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/other_parameters.html +0 -10
  122. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/parameters.html +0 -10
  123. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/raises.html +0 -10
  124. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/receives.html +0 -10
  125. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/returns.html +0 -10
  126. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/warns.html +0 -10
  127. mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/yields.html +0 -10
  128. mkdocstrings_handlers/python/templates/readthedocs/_base/language.html +0 -10
  129. mkdocstrings_handlers/python/templates/readthedocs/_base/languages/en.html +0 -10
  130. mkdocstrings_handlers/python/templates/readthedocs/_base/languages/ja.html +0 -10
  131. mkdocstrings_handlers/python/templates/readthedocs/_base/languages/zh.html +0 -10
  132. mkdocstrings_handlers/python/templates/readthedocs/docstring/attributes.html +0 -2
  133. mkdocstrings_handlers/python/templates/readthedocs/docstring/other_parameters.html +0 -2
  134. mkdocstrings_handlers/python/templates/readthedocs/docstring/parameters.html +0 -2
  135. mkdocstrings_handlers/python/templates/readthedocs/docstring/raises.html +0 -2
  136. mkdocstrings_handlers/python/templates/readthedocs/docstring/receives.html +0 -2
  137. mkdocstrings_handlers/python/templates/readthedocs/docstring/returns.html +0 -2
  138. mkdocstrings_handlers/python/templates/readthedocs/docstring/warns.html +0 -2
  139. mkdocstrings_handlers/python/templates/readthedocs/docstring/yields.html +0 -2
  140. mkdocstrings_handlers/python/templates/readthedocs/language.html +0 -2
  141. mkdocstrings_handlers/python/templates/readthedocs/languages/en.html +0 -2
  142. mkdocstrings_handlers/python/templates/readthedocs/languages/ja.html +0 -2
  143. mkdocstrings_handlers/python/templates/readthedocs/languages/zh.html +0 -2
  144. mkdocstrings_python-1.19.0.dist-info/METADATA +0 -121
  145. mkdocstrings_python-1.19.0.dist-info/RECORD +0 -215
  146. {mkdocstrings_python-1.19.0.dist-info → mkdocstrings_python-2.0.1.dist-info}/entry_points.txt +0 -0
  147. {mkdocstrings_python-1.19.0.dist-info → mkdocstrings_python-2.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -24,14 +24,12 @@ from mkdocstrings_handlers.python._internal.rendering import (
24
24
  do_as_modules_section,
25
25
  do_as_type_aliases_section,
26
26
  do_backlink_tree,
27
- do_crossref,
28
27
  do_filter_objects,
29
28
  do_format_attribute,
30
29
  do_format_code,
31
30
  do_format_signature,
32
31
  do_format_type_alias,
33
32
  do_get_template,
34
- do_multi_crossref,
35
33
  do_order_members,
36
34
  do_split_path,
37
35
  do_stash_crossref,
@@ -59,14 +57,12 @@ __all__ = [
59
57
  "do_as_modules_section",
60
58
  "do_as_type_aliases_section",
61
59
  "do_backlink_tree",
62
- "do_crossref",
63
60
  "do_filter_objects",
64
61
  "do_format_attribute",
65
62
  "do_format_code",
66
63
  "do_format_signature",
67
64
  "do_format_type_alias",
68
65
  "do_get_template",
69
- "do_multi_crossref",
70
66
  "do_order_members",
71
67
  "do_split_path",
72
68
  "do_stash_crossref",
@@ -10,7 +10,6 @@ from contextlib import suppress
10
10
  from dataclasses import asdict
11
11
  from pathlib import Path
12
12
  from typing import TYPE_CHECKING, Any, BinaryIO, ClassVar
13
- from warnings import warn
14
13
 
15
14
  from griffe import (
16
15
  AliasResolutionError,
@@ -56,17 +55,6 @@ _logger = get_logger(__name__)
56
55
  patch_loggers(get_logger)
57
56
 
58
57
 
59
- # YORE: Bump 2: Remove block.
60
- def _warn_extra_options(names: Sequence[str]) -> None:
61
- warn(
62
- "Passing extra options directly under `options` is deprecated. "
63
- "Instead, pass them under `options.extra`, and update your templates. "
64
- f"Current extra (unrecognized) options: {', '.join(sorted(names))}",
65
- DeprecationWarning,
66
- stacklevel=3,
67
- )
68
-
69
-
70
58
  class PythonHandler(BaseHandler):
71
59
  """The Python handler class."""
72
60
 
@@ -97,18 +85,9 @@ class PythonHandler(BaseHandler):
97
85
  self.base_dir = base_dir
98
86
  """The base directory of the project."""
99
87
 
100
- # YORE: Bump 2: Remove block.
101
- global_extra, global_options = PythonOptions._extract_extra(config.options)
102
- if global_extra:
103
- _warn_extra_options(global_extra.keys()) # type: ignore[arg-type]
104
- self._global_extra = global_extra
105
- self.global_options = global_options
88
+ self.global_options = config.options
106
89
  """The global configuration options (in `mkdocs.yml`)."""
107
90
 
108
- # YORE: Bump 2: Replace `# ` with `` within block.
109
- # self.global_options = config.options
110
- # """The global configuration options (in `mkdocs.yml`)."""
111
-
112
91
  # Warn if user overrides base templates.
113
92
  if self.custom_templates:
114
93
  for theme_dir in base_dir.joinpath(self.custom_templates, "python").iterdir():
@@ -160,7 +139,7 @@ class PythonHandler(BaseHandler):
160
139
  ) -> Iterator[tuple[str, str]]:
161
140
  """Yield items and their URLs from an inventory file streamed from `in_file`.
162
141
 
163
- This implements mkdocstrings' `load_inventory` "protocol" (see [`mkdocstrings.plugin`][]).
142
+ This implements mkdocstrings' `load_inventory` "protocol" (see [`mkdocstrings.BaseHandler.load_inventory`][]).
164
143
 
165
144
  Arguments:
166
145
  in_file: The binary file-like object to read the inventory from.
@@ -188,25 +167,13 @@ class PythonHandler(BaseHandler):
188
167
  Returns:
189
168
  The combined options.
190
169
  """
191
- # YORE: Bump 2: Remove block.
192
- local_extra, local_options = PythonOptions._extract_extra(local_options) # type: ignore[arg-type]
193
- if local_extra:
194
- _warn_extra_options(local_extra.keys()) # type: ignore[arg-type]
195
- unknown_extra = self._global_extra | local_extra
196
-
197
170
  extra = {**self.global_options.get("extra", {}), **local_options.get("extra", {})}
198
171
  options = {**self.global_options, **local_options, "extra": extra}
199
172
  try:
200
- # YORE: Bump 2: Replace `opts =` with `return` within line.
201
- opts = PythonOptions.from_data(**options)
173
+ return PythonOptions.from_data(**options)
202
174
  except Exception as error:
203
175
  raise PluginError(f"Invalid options: {error}") from error
204
176
 
205
- # YORE: Bump 2: Remove block.
206
- for key, value in unknown_extra.items():
207
- object.__setattr__(opts, key, value)
208
- return opts
209
-
210
177
  def collect(self, identifier: str, options: PythonOptions) -> CollectorItem:
211
178
  """Collect the documentation for the given identifier.
212
179
 
@@ -291,7 +258,7 @@ class PythonHandler(BaseHandler):
291
258
  Returns:
292
259
  The rendered data (HTML).
293
260
  """
294
- template_name = rendering.do_get_template(self.env, data)
261
+ template_name = rendering.do_get_template(data)
295
262
  template = self.env.get_template(template_name)
296
263
 
297
264
  return template.render(
@@ -303,8 +270,7 @@ class PythonHandler(BaseHandler):
303
270
  # than as an item in a dictionary.
304
271
  "heading_level": options.heading_level,
305
272
  "root": True,
306
- # YORE: Bump 2: Regex-replace ` or .+` with ` or "en",` within line.
307
- "locale": locale or self.config.locale,
273
+ "locale": locale or "en",
308
274
  },
309
275
  )
310
276
 
@@ -336,8 +302,6 @@ class PythonHandler(BaseHandler):
336
302
  self.env.lstrip_blocks = True
337
303
  self.env.keep_trailing_newline = False
338
304
  self.env.filters["split_path"] = rendering.do_split_path
339
- self.env.filters["crossref"] = rendering.do_crossref
340
- self.env.filters["multi_crossref"] = rendering.do_multi_crossref
341
305
  self.env.filters["order_members"] = rendering.do_order_members
342
306
  self.env.filters["format_code"] = rendering.do_format_code
343
307
  self.env.filters["format_signature"] = rendering.do_format_signature
@@ -434,10 +398,7 @@ def get_handler(
434
398
  # We therefore increase the limit here, once, before Griffe is used to collect or render stuff.
435
399
  sys.setrecursionlimit(max(sys.getrecursionlimit(), 2000))
436
400
 
437
- base_dir = Path(tool_config.config_file_path or "./mkdocs.yml").parent
438
- if "inventories" not in handler_config and "import" in handler_config:
439
- warn("The 'import' key is renamed 'inventories' for the Python handler", FutureWarning, stacklevel=1)
440
- handler_config["inventories"] = handler_config.pop("import", [])
401
+ base_dir = Path(getattr(tool_config, "config_file_path", None) or "./mkdocs.yml").parent
441
402
  return PythonHandler(
442
403
  config=PythonConfig.from_data(**handler_config),
443
404
  base_dir=base_dir,
@@ -7,13 +7,11 @@ import re
7
7
  import string
8
8
  import subprocess
9
9
  import sys
10
- import warnings
11
10
  from collections import defaultdict
12
11
  from contextlib import suppress
13
12
  from dataclasses import replace
14
13
  from functools import lru_cache
15
- from pathlib import Path
16
- from re import Match, Pattern
14
+ from re import Pattern
17
15
  from typing import TYPE_CHECKING, Any, Callable, ClassVar, Literal, TypeVar
18
16
 
19
17
  from griffe import (
@@ -33,7 +31,7 @@ from griffe import (
33
31
  Object,
34
32
  TypeAlias,
35
33
  )
36
- from jinja2 import TemplateNotFound, pass_context, pass_environment
34
+ from jinja2 import pass_context
37
35
  from markupsafe import Markup
38
36
  from mkdocs_autorefs import AutorefsHookInterface, Backlink, BacklinkCrumb
39
37
  from mkdocstrings import get_logger
@@ -42,7 +40,6 @@ if TYPE_CHECKING:
42
40
  from collections.abc import Iterable, Iterator, Sequence
43
41
 
44
42
  from griffe import Attribute, Class, Function, Module
45
- from jinja2 import Environment
46
43
  from jinja2.runtime import Context
47
44
  from mkdocstrings import CollectorItem
48
45
 
@@ -170,10 +167,8 @@ def do_format_signature(
170
167
  The same code, formatted.
171
168
  """
172
169
  env = context.environment
173
- # YORE: Bump 2: Replace `do_get_template(env, "type_parameters")` with `"type_parameters.html.jinja"` within line.
174
- type_params_template = env.get_template(do_get_template(env, "type_parameters"))
175
- # YORE: Bump 2: Replace `do_get_template(env, "signature")` with `"signature.html.jinja"` within line.
176
- signature_template = env.get_template(do_get_template(env, "signature"))
170
+ type_params_template = env.get_template("type_parameters.html.jinja")
171
+ signature_template = env.get_template("signature.html.jinja")
177
172
 
178
173
  if annotations is None:
179
174
  new_context = context.parent
@@ -237,8 +232,7 @@ def do_format_attribute(
237
232
  The same code, formatted.
238
233
  """
239
234
  env = context.environment
240
- # YORE: Bump 2: Replace `do_get_template(env, "expression")` with `"expression.html.jinja"` within line.
241
- template = env.get_template(do_get_template(env, "expression"))
235
+ template = env.get_template("expression.html.jinja")
242
236
  annotations = context.parent["config"].show_signature_annotations
243
237
 
244
238
  signature = str(attribute_path).strip()
@@ -295,10 +289,8 @@ def do_format_type_alias(
295
289
  The same code, formatted.
296
290
  """
297
291
  env = context.environment
298
- # YORE: Bump 2: Replace `do_get_template(env, "type_parameters")` with `"type_parameters.html.jinja"` within line.
299
- type_params_template = env.get_template(do_get_template(env, "type_parameters"))
300
- # YORE: Bump 2: Replace `do_get_template(env, "expression")` with `"expression.html.jinja"` within line.
301
- expr_template = env.get_template(do_get_template(env, "expression"))
292
+ type_params_template = env.get_template("type_parameters.html.jinja")
293
+ expr_template = env.get_template("expression.html.jinja")
302
294
 
303
295
  signature = str(type_alias_path).strip()
304
296
  signature += type_params_template.render(context.parent, obj=type_alias, signature=True)
@@ -364,76 +356,6 @@ def do_order_members(
364
356
  return members
365
357
 
366
358
 
367
- # YORE: Bump 2: Remove block.
368
- @lru_cache
369
- def _warn_crossref() -> None:
370
- warnings.warn(
371
- "The `crossref` filter is deprecated and will be removed in a future version",
372
- DeprecationWarning,
373
- stacklevel=1,
374
- )
375
-
376
-
377
- # YORE: Bump 2: Remove block.
378
- def do_crossref(path: str, *, brief: bool = True) -> Markup:
379
- """Deprecated. Filter to create cross-references.
380
-
381
- Parameters:
382
- path: The path to link to.
383
- brief: Show only the last part of the path, add full path as hover.
384
-
385
- Returns:
386
- Markup text.
387
- """
388
- _warn_crossref()
389
- full_path = path
390
- if brief:
391
- path = full_path.split(".")[-1]
392
- return Markup("<autoref identifier={full_path} optional hover>{path}</autoref>").format(
393
- full_path=full_path,
394
- path=path,
395
- )
396
-
397
-
398
- # YORE: Bump 2: Remove block.
399
- @lru_cache
400
- def _warn_multi_crossref() -> None:
401
- warnings.warn(
402
- "The `multi_crossref` filter is deprecated and will be removed in a future version",
403
- DeprecationWarning,
404
- stacklevel=1,
405
- )
406
-
407
-
408
- # YORE: Bump 2: Remove block.
409
- def do_multi_crossref(text: str, *, code: bool = True) -> Markup:
410
- """Deprecated. Filter to create cross-references.
411
-
412
- Parameters:
413
- text: The text to scan.
414
- code: Whether to wrap the result in a code tag.
415
-
416
- Returns:
417
- Markup text.
418
- """
419
- _warn_multi_crossref()
420
- group_number = 0
421
- variables = {}
422
-
423
- def repl(match: Match) -> str:
424
- nonlocal group_number
425
- group_number += 1
426
- path = match.group()
427
- path_var = f"path{group_number}"
428
- variables[path_var] = path
429
- return f"<autoref identifier={{{path_var}}} optional hover>{{{path_var}}}</autoref>"
430
-
431
- text = re.sub(r"([\w.]+)", repl, text)
432
- if code:
433
- text = f"<code>{text}</code>"
434
- return Markup(text).format(**variables) # noqa: S704
435
-
436
-
437
359
  _split_path_re = re.compile(r"([.(]?)([\w]+)(\))?")
438
360
  _splitable_re = re.compile(r"[().]")
439
361
 
@@ -648,39 +570,20 @@ def _get_black_formatter() -> Callable[[str, int], str] | None:
648
570
  return formatter
649
571
 
650
572
 
651
- # YORE: Bump 2: Remove line.
652
- @pass_environment
653
- # YORE: Bump 2: Replace `env: Environment, ` with `` within line.
654
- # YORE: Bump 2: Replace `str | ` with `` within line.
655
- def do_get_template(env: Environment, obj: str | Object) -> str:
573
+ def do_get_template(obj: Object | Alias) -> str:
656
574
  """Get the template name used to render an object.
657
575
 
658
576
  Parameters:
659
- env: The Jinja environment, passed automatically.
660
- obj: A Griffe object, or a template name.
577
+ obj: A Griffe object.
661
578
 
662
579
  Returns:
663
580
  A template name.
664
581
  """
665
- name = obj
666
- if isinstance(obj, (Alias, Object)):
667
- extra_data = getattr(obj, "extra", {}).get("mkdocstrings", {})
668
- if name := extra_data.get("template", ""):
669
- return name
670
- name = obj.kind.value.replace(" ", "_")
671
- # YORE: Bump 2: Replace block with `return f"{name}.html.jinja"`.
672
- try:
673
- template = env.get_template(f"{name}.html")
674
- except TemplateNotFound:
675
- return f"{name}.html.jinja"
676
- our_template = Path(template.filename).is_relative_to(Path(__file__).parent.parent) # type: ignore[arg-type]
677
- if our_template:
678
- return f"{name}.html.jinja"
679
- _logger.warning(
680
- f"DeprecationWarning: Overriding '{name}.html' is deprecated, override '{name}.html.jinja' instead. ",
681
- once=True,
682
- )
683
- return f"{name}.html"
582
+ extra_data = getattr(obj, "extra", {}).get("mkdocstrings", {})
583
+ if name := extra_data.get("template", ""):
584
+ return name
585
+ name = obj.kind.value.replace(" ", "_")
586
+ return f"{name}.html.jinja"
684
587
 
685
588
 
686
589
  @pass_context
@@ -67,8 +67,7 @@ Context:
67
67
  This block renders the labels for the attribute.
68
68
  -#}
69
69
  {% with labels = attribute.labels %}
70
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
71
- {% include "labels"|get_template with context %}
70
+ {% include "labels.html.jinja" with context %}
72
71
  {% endwith %}
73
72
  {% endblock labels %}
74
73
 
@@ -115,8 +114,7 @@ Context:
115
114
  This block renders the docstring for the attribute.
116
115
  -#}
117
116
  {% with docstring_sections = attribute.docstring.parsed %}
118
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
119
- {% include "docstring"|get_template with context %}
117
+ {% include "docstring.html.jinja" with context %}
120
118
  {% endwith %}
121
119
  {% endblock docstring %}
122
120
 
@@ -19,6 +19,9 @@ Context:
19
19
  {{ log.debug("Rendering children of " + obj.path) }}
20
20
  {% endblock logs %}
21
21
 
22
+ {% import "language.html.jinja" as lang with context %}
23
+ {#- Language module providing the `t` translation method. -#}
24
+
22
25
  <div class="doc doc-children">
23
26
 
24
27
  {% if root_members %}
@@ -45,7 +48,7 @@ Context:
45
48
  ) %}
46
49
  {% if attributes %}
47
50
  {% if config.show_category_heading %}
48
- {% filter heading(heading_level, id=html_id ~ "-attributes", skip_inventory=config.skip_local_inventory) %}Attributes{% endfilter %}
51
+ {% filter heading(heading_level, id=html_id ~ "-attributes", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Attributes") }}{% endfilter %}
49
52
  {% endif %}
50
53
  {% with heading_level = heading_level + extra_level %}
51
54
  {% for attribute in attributes|order_members(config.members_order, members_list) %}
@@ -65,7 +68,7 @@ Context:
65
68
  ) %}
66
69
  {% if type_aliases %}
67
70
  {% if config.show_category_heading %}
68
- {% filter heading(heading_level, id=html_id ~ "-type_aliases") %}Type Aliases{% endfilter %}
71
+ {% filter heading(heading_level, id=html_id ~ "-type_aliases") %}{{ lang.t("Type Aliases") }}{% endfilter %}
69
72
  {% endif %}
70
73
  {% with heading_level = heading_level + extra_level %}
71
74
  {% for type_alias in type_aliases|order_members(config.members_order, members_list) %}
@@ -85,7 +88,7 @@ Context:
85
88
  ) %}
86
89
  {% if classes %}
87
90
  {% if config.show_category_heading %}
88
- {% filter heading(heading_level, id=html_id ~ "-classes", skip_inventory=config.skip_local_inventory) %}Classes{% endfilter %}
91
+ {% filter heading(heading_level, id=html_id ~ "-classes", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Classes") }}{% endfilter %}
89
92
  {% endif %}
90
93
  {% with heading_level = heading_level + extra_level %}
91
94
  {% for class in classes|order_members(config.members_order, members_list) %}
@@ -105,7 +108,7 @@ Context:
105
108
  ) %}
106
109
  {% if functions %}
107
110
  {% if config.show_category_heading %}
108
- {% filter heading(heading_level, id=html_id ~ "-functions", skip_inventory=config.skip_local_inventory) %}Functions{% endfilter %}
111
+ {% filter heading(heading_level, id=html_id ~ "-functions", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Functions") }}{% endfilter %}
109
112
  {% endif %}
110
113
  {% with heading_level = heading_level + extra_level %}
111
114
  {% for function in functions|order_members(config.members_order, members_list) %}
@@ -128,7 +131,7 @@ Context:
128
131
  ) %}
129
132
  {% if modules %}
130
133
  {% if config.show_category_heading %}
131
- {% filter heading(heading_level, id=html_id ~ "-modules", skip_inventory=config.skip_local_inventory) %}Modules{% endfilter %}
134
+ {% filter heading(heading_level, id=html_id ~ "-modules", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Modules") }}{% endfilter %}
132
135
  {% endif %}
133
136
  {% with heading_level = heading_level + extra_level %}
134
137
  {% for module in modules|order_members("alphabetical", members_list) %}
@@ -157,7 +160,7 @@ Context:
157
160
 
158
161
  {% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %}
159
162
 
160
- {% if config.filters == "public" or members_list is not none or child.is_public %}
163
+ {% if config.filters == "public" or members_list is not none or (not child.is_imported or child.is_public) %}
161
164
  {% if child.is_attribute %}
162
165
  {% with attribute = child %}
163
166
  {% include attribute|get_template with context %}
@@ -17,6 +17,9 @@ Context:
17
17
  {{ log.debug("Rendering " + class.path) }}
18
18
  {% endblock logs %}
19
19
 
20
+ {% import "language.html.jinja" as lang with context %}
21
+ {#- Language module providing the `t` translation method. -#}
22
+
20
23
  <div class="doc doc-object doc-class">
21
24
  {% with obj = class, html_id = class.path, all_members = class.all_members %}
22
25
 
@@ -57,11 +60,9 @@ Context:
57
60
  {%+ filter highlight(language="python", inline=True) %}
58
61
  {{ class_name -}}
59
62
  {%- with obj = function -%}
60
- {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
61
- {%- include "type_parameters"|get_template with context -%}
63
+ {%- include "type_parameters.html.jinja" with context -%}
62
64
  {%- endwith -%}
63
- {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
64
- {%- include "signature"|get_template with context -%}
65
+ {%- include "signature.html.jinja" with context -%}
65
66
  {% endfilter %}
66
67
  {% endwith %}
67
68
  {% else %}
@@ -76,8 +77,7 @@ Context:
76
77
  This block renders the labels for the class.
77
78
  -#}
78
79
  {% with labels = class.labels %}
79
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
80
- {% include "labels"|get_template with context %}
80
+ {% include "labels.html.jinja" with context %}
81
81
  {% endwith %}
82
82
  {% endblock labels %}
83
83
 
@@ -148,8 +148,7 @@ Context:
148
148
  Bases: {% for expression in class.bases -%}
149
149
  <code>
150
150
  {%- with backlink_type = "subclassed-by" -%}
151
- {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
152
- {%- include "expression"|get_template with context -%}
151
+ {%- include "expression.html.jinja" with context -%}
153
152
  {%- endwith -%}
154
153
  </code>{% if not loop.last %}, {% endif %}
155
154
  {% endfor -%}
@@ -211,8 +210,7 @@ Context:
211
210
  This block renders the docstring for the class.
212
211
  -#}
213
212
  {% with docstring_sections = class.docstring.parsed %}
214
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
215
- {% include "docstring"|get_template with context %}
213
+ {% include "docstring.html.jinja" with context %}
216
214
  {% endwith %}
217
215
  {% if config.merge_init_into_class %}
218
216
  {# We don't want to merge the inherited `__init__` method docstring into the class docstring #}
@@ -221,8 +219,7 @@ Context:
221
219
  {% if "__init__" in check_members and check_members["__init__"].has_docstring %}
222
220
  {% with function = check_members["__init__"] %}
223
221
  {% with obj = function, docstring_sections = function.docstring.parsed %}
224
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
225
- {% include "docstring"|get_template with context %}
222
+ {% include "docstring.html.jinja" with context %}
226
223
  {% endwith %}
227
224
  {% endwith %}
228
225
  {% endif %}
@@ -239,8 +236,7 @@ Context:
239
236
 
240
237
  This block renders auto-summaries for classes, methods, and attributes.
241
238
  -#}
242
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
243
- {% include "summary"|get_template with context %}
239
+ {% include "summary.html.jinja" with context %}
244
240
  {% endblock summary %}
245
241
 
246
242
  {% block source scoped %}
@@ -253,7 +249,7 @@ Context:
253
249
  {% if "__init__" in all_members and all_members["__init__"].source %}
254
250
  {% with init = all_members["__init__"] %}
255
251
  <details class="mkdocstrings-source">
256
- <summary>Source code in <code>
252
+ <summary>{{ lang.t("Source code in") }} <code>
257
253
  {%- if init.relative_filepath.is_absolute() -%}
258
254
  {{ init.relative_package_filepath }}
259
255
  {%- else -%}
@@ -266,7 +262,7 @@ Context:
266
262
  {% endif %}
267
263
  {% elif class.source %}
268
264
  <details class="mkdocstrings-source">
269
- <summary>Source code in <code>
265
+ <summary>{{ lang.t("Source code in") }} <code>
270
266
  {%- if class.relative_filepath.is_absolute() -%}
271
267
  {{ class.relative_package_filepath }}
272
268
  {%- else -%}
@@ -286,8 +282,7 @@ Context:
286
282
  -#}
287
283
  {% set root = False %}
288
284
  {% set heading_level = heading_level + 1 %}
289
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
290
- {% include "children"|get_template with context %}
285
+ {% include "children.html.jinja" with context %}
291
286
  {% endblock children %}
292
287
  {% endblock contents %}
293
288
  </div>
@@ -15,8 +15,7 @@ Context:
15
15
  {{ log.debug("Rendering attributes section") }}
16
16
  {% endblock logs %}
17
17
 
18
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
19
- {% import "language"|get_template as lang with context %}
18
+ {% import "language.html.jinja" as lang with context %}
20
19
  {#- Language module providing the `t` translation method. -#}
21
20
 
22
21
  {% if config.docstring_section_style == "table" %}
@@ -38,8 +37,7 @@ Context:
38
37
  <td>
39
38
  {% if attribute.annotation %}
40
39
  {% with expression = attribute.annotation %}
41
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
42
- <code>{% include "expression"|get_template with context %}</code>
40
+ <code>{% include "expression.html.jinja" with context %}</code>
43
41
  {% endwith %}
44
42
  {% endif %}
45
43
  </td>
@@ -63,8 +61,7 @@ Context:
63
61
  <b><code><autoref identifier="{{ obj.path }}.{{ attribute.name }}" optional hover>{{ attribute.name }}</autoref></code></b>
64
62
  {% if attribute.annotation %}
65
63
  {% with expression = attribute.annotation %}
66
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
67
- (<code>{% include "expression"|get_template with context %}</code>)
64
+ (<code>{% include "expression.html.jinja" with context %}</code>)
68
65
  {% endwith %}
69
66
  {% endif %}
70
67
 
@@ -96,10 +93,9 @@ Context:
96
93
  <p>
97
94
  {% if attribute.annotation %}
98
95
  <span class="doc-attribute-annotation">
99
- <b>TYPE:</b>
96
+ <b>{{ lang.t("TYPE:") }}</b>
100
97
  {% with expression = attribute.annotation %}
101
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
102
- <code>{% include "expression"|get_template with context %}</code>
98
+ <code>{% include "expression.html.jinja" with context %}</code>
103
99
  {% endwith %}
104
100
  </span>
105
101
  {% endif %}
@@ -15,8 +15,7 @@ Context:
15
15
  {{ log.debug("Rendering classes section") }}
16
16
  {% endblock logs %}
17
17
 
18
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
19
- {% import "language"|get_template as lang with context %}
18
+ {% import "language.html.jinja" as lang with context %}
20
19
  {#- Language module providing the `t` translation method. -#}
21
20
 
22
21
  {% if config.docstring_section_style == "table" %}
@@ -15,8 +15,7 @@ Context:
15
15
  {{ log.debug("Rendering examples section") }}
16
16
  {% endblock logs %}
17
17
 
18
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
19
- {% import "language"|get_template as lang with context %}
18
+ {% import "language.html.jinja" as lang with context %}
20
19
  {#- Language module providing the `t` translation method. -#}
21
20
 
22
21
  <p><span class="doc-section-title">{{ section.title or lang.t("Examples:") }}</span></p>
@@ -15,8 +15,7 @@ Context:
15
15
  {{ log.debug("Rendering functions section") }}
16
16
  {% endblock logs %}
17
17
 
18
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
19
- {% import "language"|get_template as lang with context %}
18
+ {% import "language.html.jinja" as lang with context %}
20
19
  {#- Language module providing the `t` translation method. -#}
21
20
 
22
21
  {% if config.docstring_section_style == "table" %}
@@ -15,8 +15,7 @@ Context:
15
15
  {{ log.debug("Rendering modules section") }}
16
16
  {% endblock logs %}
17
17
 
18
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
19
- {% import "language"|get_template as lang with context %}
18
+ {% import "language.html.jinja" as lang with context %}
20
19
  {#- Language module providing the `t` translation method. -#}
21
20
 
22
21
  {% if config.docstring_section_style == "table" %}
@@ -15,8 +15,7 @@ Context:
15
15
  {{ log.debug("Rendering other parameters section") }}
16
16
  {% endblock logs %}
17
17
 
18
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
19
- {% import "language"|get_template as lang with context %}
18
+ {% import "language.html.jinja" as lang with context %}
20
19
  {#- Language module providing the `t` translation method. -#}
21
20
 
22
21
  {% if config.docstring_section_style == "table" %}
@@ -38,8 +37,7 @@ Context:
38
37
  <td>
39
38
  {% if parameter.annotation %}
40
39
  {% with expression = parameter.annotation, backlink_type = "used-by" %}
41
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
42
- <code>{% include "expression"|get_template with context %}</code>
40
+ <code>{% include "expression.html.jinja" with context %}</code>
43
41
  {% endwith %}
44
42
  {% endif %}
45
43
  </td>
@@ -63,8 +61,7 @@ Context:
63
61
  <b><code>{{ parameter.name }}</code></b>
64
62
  {% if parameter.annotation %}
65
63
  {% with expression = parameter.annotation, backlink_type = "used-by" %}
66
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
67
- (<code>{% include "expression"|get_template with context %}</code>)
64
+ (<code>{% include "expression.html.jinja" with context %}</code>)
68
65
  {% endwith %}
69
66
  {% endif %}
70
67
 
@@ -98,8 +95,7 @@ Context:
98
95
  <span class="doc-param-annotation">
99
96
  <b>{{ lang.t("TYPE:") }}</b>
100
97
  {% with expression = parameter.annotation, backlink_type = "used-by" %}
101
- {# YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. #}
102
- <code>{% include "expression"|get_template with context %}</code>
98
+ <code>{% include "expression.html.jinja" with context %}</code>
103
99
  {% endwith %}
104
100
  </span>
105
101
  {% endif %}