mkdocstrings-python 1.0.0__py3-none-any.whl → 1.1.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.
@@ -297,7 +297,8 @@ class PythonHandler(BaseHandler):
297
297
  mutabled_config = dict(copy.deepcopy(config))
298
298
  final_config = ChainMap(mutabled_config, self.default_config)
299
299
 
300
- template = self.env.get_template(f"{data.kind.value}.html")
300
+ template_name = rendering.do_get_template(data)
301
+ template = self.env.get_template(template_name)
301
302
 
302
303
  # Heading level is a "state" variable, that will change at each step
303
304
  # of the rendering recursion. Therefore, it's easier to use it as a plain value
@@ -335,6 +336,7 @@ class PythonHandler(BaseHandler):
335
336
  self.env.filters["format_signature"] = rendering.do_format_signature
336
337
  self.env.filters["filter_objects"] = rendering.do_filter_objects
337
338
  self.env.filters["stash_crossref"] = lambda ref, length: ref
339
+ self.env.filters["get_template"] = rendering.do_get_template
338
340
 
339
341
  def get_anchors(self, data: CollectorItem) -> set[str]: # noqa: D102 (ignore missing docstring)
340
342
  try:
@@ -248,3 +248,16 @@ def _get_black_formatter() -> Callable[[str, int], str]:
248
248
  return format_str(code, mode=mode)
249
249
 
250
250
  return formatter
251
+
252
+
253
+ def do_get_template(obj: Object) -> str:
254
+ """Get the template name used to render an object.
255
+
256
+ Parameters:
257
+ obj: A Griffe object.
258
+
259
+ Returns:
260
+ A template name.
261
+ """
262
+ extra_data = getattr(obj, "extra", {}).get("mkdocstrings", {})
263
+ return extra_data.get("template", "") or f"{obj.kind.value}.html"
@@ -27,7 +27,7 @@
27
27
  {% with heading_level = heading_level + extra_level %}
28
28
  {% for attribute in attributes|order_members(config.members_order, members_list) %}
29
29
  {% if not attribute.is_alias or attribute.is_explicitely_exported %}
30
- {% include "attribute.html" with context %}
30
+ {% include attribute|get_template with context %}
31
31
  {% endif %}
32
32
  {% endfor %}
33
33
  {% endwith %}
@@ -42,7 +42,7 @@
42
42
  {% with heading_level = heading_level + extra_level %}
43
43
  {% for class in classes|order_members(config.members_order, members_list) %}
44
44
  {% if not class.is_alias or class.is_explicitely_exported %}
45
- {% include "class.html" with context %}
45
+ {% include class|get_template with context %}
46
46
  {% endif %}
47
47
  {% endfor %}
48
48
  {% endwith %}
@@ -58,7 +58,7 @@
58
58
  {% for function in functions|order_members(config.members_order, members_list) %}
59
59
  {% if not (obj.kind.value == "class" and function.name == "__init__" and config.merge_init_into_class) %}
60
60
  {% if not function.is_alias or function.is_explicitely_exported %}
61
- {% include "function.html" with context %}
61
+ {% include function|get_template with context %}
62
62
  {% endif %}
63
63
  {% endif %}
64
64
  {% endfor %}
@@ -75,7 +75,7 @@
75
75
  {% with heading_level = heading_level + extra_level %}
76
76
  {% for module in modules|order_members(config.members_order, members_list) %}
77
77
  {% if not module.is_alias or module.is_explicitely_exported %}
78
- {% include "module.html" with context %}
78
+ {% include module|get_template with context %}
79
79
  {% endif %}
80
80
  {% endfor %}
81
81
  {% endwith %}
@@ -91,26 +91,26 @@
91
91
  filter_objects(filters=config.filters, members_list=members_list, keep_no_docstrings=config.show_if_no_docstring)|
92
92
  order_members(config.members_order, members_list) %}
93
93
 
94
- {% if not (obj.kind.value == "class" and child.name == "__init__" and config.merge_init_into_class) %}
94
+ {% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %}
95
95
 
96
- {% if child.kind.value == "attribute" %}
96
+ {% if child.is_attribute %}
97
97
  {% with attribute = child %}
98
- {% include "attribute.html" with context %}
98
+ {% include attribute|get_template with context %}
99
99
  {% endwith %}
100
100
 
101
- {% elif child.kind.value == "class" %}
101
+ {% elif child.is_class %}
102
102
  {% with class = child %}
103
- {% include "class.html" with context %}
103
+ {% include class|get_template with context %}
104
104
  {% endwith %}
105
105
 
106
- {% elif child.kind.value == "function" %}
106
+ {% elif child.is_function %}
107
107
  {% with function = child %}
108
- {% include "function.html" with context %}
108
+ {% include function|get_template with context %}
109
109
  {% endwith %}
110
110
 
111
- {% elif child.kind.value == "module" and config.show_submodules %}
111
+ {% elif child.is_module and config.show_submodules %}
112
112
  {% with module = child %}
113
- {% include "module.html" with context %}
113
+ {% include module|get_template with context %}
114
114
  {% endwith %}
115
115
 
116
116
  {% endif %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mkdocstrings-python
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A Python handler for mkdocstrings.
5
5
  Author-Email: Timothée Mazzucotelli <pawamoy@pm.me>
6
6
  License: ISC
@@ -25,8 +25,8 @@ Project-URL: Changelog, https://mkdocstrings.github.io/python/changelog
25
25
  Project-URL: Repository, https://github.com/mkdocstrings/python
26
26
  Project-URL: Issues, https://github.com/mkdocstrings/python/issues
27
27
  Project-URL: Discussions, https://github.com/mkdocstrings/python/discussions
28
- Project-URL: Gitter, https://gitter.im/python/community
29
- Project-URL: Funding, https://github.com/sponsors/mkdocstrings
28
+ Project-URL: Gitter, https://gitter.im/mkdocstrings/python
29
+ Project-URL: Funding, https://github.com/sponsors/pawamoy
30
30
  Requires-Python: >=3.7
31
31
  Requires-Dist: mkdocstrings>=0.20
32
32
  Requires-Dist: griffe>=0.24
@@ -1,9 +1,9 @@
1
1
  mkdocstrings_handlers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  mkdocstrings_handlers/python/__init__.py,sha256=CJT3hmg9HpEMy5dbq2jL3Y8unO6UOHND7yCLojwQrS8,326
3
- mkdocstrings_handlers/python/handler.py,sha256=vX6vRqZRV-nwCFCrjxBUuH0zC1gXwWBHBhgeGHM72Cw,17985
4
- mkdocstrings_handlers/python/rendering.py,sha256=NMlXtGyE5pQZrdhkwqDnxRLTvc0Kes_T7xGy0-tZiTM,7542
3
+ mkdocstrings_handlers/python/handler.py,sha256=VKDSxsSCFMNsTJSox4VBHLFkqaHk4A7fzUQVli2OxK0,18098
4
+ mkdocstrings_handlers/python/rendering.py,sha256=hjj64VBYJrQlVFF3jxwkla7nG5al6rXl0YH4AsHwPiY,7871
5
5
  mkdocstrings_handlers/python/templates/material/_base/attribute.html,sha256=JXn5axcd2ssBb02kzs9OVnKvo-UINOIC1ivsGpflIdc,2532
6
- mkdocstrings_handlers/python/templates/material/_base/children.html,sha256=-FKVAh62bJyqZ3T1R1lgtaRmIsZPnnuAfv-Lov1Hz50,5053
6
+ mkdocstrings_handlers/python/templates/material/_base/children.html,sha256=NOf0LuqOXOg3SVEwwP8ARndWjZrk8q2o-1Ajrrp4dG0,5036
7
7
  mkdocstrings_handlers/python/templates/material/_base/class.html,sha256=wtTLXZl8gvOicdfxOCQaFt_59bn754C1k2ILbE4XvlE,4078
8
8
  mkdocstrings_handlers/python/templates/material/_base/docstring.html,sha256=LZu_zGw1YyGHN1fq-loPN9eKyYwC3rDWMyQbh31hD20,1740
9
9
  mkdocstrings_handlers/python/templates/material/_base/docstring/admonition.html,sha256=wiD2FtMnGrFMZJDilURnNqzIu8bOR0zcMErUVUqbDPo,274
@@ -53,7 +53,7 @@ mkdocstrings_handlers/python/templates/readthedocs/parameters.html,sha256=c0pfsj
53
53
  mkdocstrings_handlers/python/templates/readthedocs/returns.html,sha256=1rvLz7n3xHkhc82mOCJdjgRpGGIFdJqhmiVpv9pdxBE,494
54
54
  mkdocstrings_handlers/python/templates/readthedocs/style.css,sha256=FNcAj6sgr1H8cg9MCkqlOMoYeM2EWExIRVRCmilL9YY,600
55
55
  mkdocstrings_handlers/python/templates/readthedocs/yields.html,sha256=QLl6geeYfOHJ3xwmuRl-rAScei0DtIxFmlSgVO53Hhc,490
56
- mkdocstrings_python-1.0.0.dist-info/METADATA,sha256=9nEqCr_Ghp0KTGQx6X_HQjnq5nTTpWwf0FgL8Wufv70,5749
57
- mkdocstrings_python-1.0.0.dist-info/WHEEL,sha256=7dGFtUmOf30dPBLpGD2z643cxg89joO7p3JHBAwDv6E,90
58
- mkdocstrings_python-1.0.0.dist-info/licenses/LICENSE,sha256=JGb4pdPEM8TTjjhr-uNCO7oXkiVrwG5Pz0JamcjNF_s,754
59
- mkdocstrings_python-1.0.0.dist-info/RECORD,,
56
+ mkdocstrings_python-1.1.0.dist-info/METADATA,sha256=aLxaWwtWx69109-NNM1s2QMyr7TnhWnC0fuZjWUub4c,5747
57
+ mkdocstrings_python-1.1.0.dist-info/WHEEL,sha256=m6kf1fJuo48rT4uxh0SeA_FsGq51BpCh_8VNBKVwYQA,90
58
+ mkdocstrings_python-1.1.0.dist-info/licenses/LICENSE,sha256=JGb4pdPEM8TTjjhr-uNCO7oXkiVrwG5Pz0JamcjNF_s,754
59
+ mkdocstrings_python-1.1.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.0.6)
2
+ Generator: pdm-backend (2.0.7)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any