Skip to content

Commit ca6b8be

Browse files
committed
fix: Improve inventory object types (incorrectly called roles in mkdocstrings)
Issue-339: #339
1 parent 8125b0d commit ca6b8be

6 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ Context:
3333

3434
{% set attribute_name = attribute.path if show_full_path else attribute.name %}
3535

36+
{% set object_type = "data" if attribute.parent.is_module else "property" if "property" in attribute.labels else "attribute" %}
37+
{#- Object type in objects inventory. -#}
38+
3639
{% if not root or config.show_root_heading %}
3740
{% filter heading(
3841
heading_level,
39-
role=("data" if attribute.parent.kind.value == "module" else "attr"),
42+
role=object_type,
4043
id=html_id,
4144
class="doc doc-heading",
4245
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else attribute.name),
@@ -89,7 +92,7 @@ Context:
8992

9093
{% if config.show_root_toc_entry %}
9194
{% filter heading(heading_level,
92-
role=("data" if attribute.parent.kind.value == "module" else "attr"),
95+
role=object_type,
9396
id=html_id,
9497
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else attribute_name),
9598
hidden=True,

src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Context:
158158

159159
{% block inheritance_diagram scoped %}
160160
{#- Inheritance diagram block.
161-
161+
162162
This block renders the inheritance diagram for the class,
163163
using Mermaid syntax and a bit of JavaScript to make the nodes clickable,
164164
linking to the corresponding class documentation.

src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Context:
3838
{% if config.parameter_headings %}
3939
{% filter heading(
4040
heading_level + 1,
41-
role="param",
41+
role="parameter",
4242
id=html_id ~ "(" ~ parameter.name ~ ")",
4343
class="doc doc-heading doc-heading-parameter",
4444
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-parameter"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + parameter.name,
@@ -86,7 +86,7 @@ Context:
8686
{% if config.parameter_headings %}
8787
{% filter heading(
8888
heading_level + 1,
89-
role="param",
89+
role="parameter",
9090
id=html_id ~ "(" ~ parameter.name ~ ")",
9191
class="doc doc-heading doc-heading-parameter",
9292
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-parameter"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + parameter.name,
@@ -132,7 +132,7 @@ Context:
132132
{% if config.parameter_headings %}
133133
{% filter heading(
134134
heading_level + 1,
135-
role="param",
135+
role="parameter",
136136
id=html_id ~ "(" ~ parameter.name ~ ")",
137137
class="doc doc-heading doc-heading-parameter",
138138
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-parameter"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + parameter.name,

src/mkdocstrings_handlers/python/templates/material/_base/docstring/type_parameters.html.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Context:
4242
{% if config.type_parameter_headings %}
4343
{% filter heading(
4444
heading_level + 1,
45-
role="typeparam",
45+
role="typeparameter",
4646
id=obj.path ~ "[" ~ type_parameter.name ~ "]",
4747
class="doc doc-heading doc-heading-type_parameter",
4848
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-type_parameter"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + type_parameter.name,
@@ -93,7 +93,7 @@ Context:
9393
{% if config.type_parameter_headings %}
9494
{% filter heading(
9595
heading_level + 1,
96-
role="typeparam",
96+
role="typeparameter",
9797
id=obj.path ~ "[" ~ type_parameter.name ~ "]",
9898
class="doc doc-heading doc-heading-type_parameter",
9999
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-type_parameter"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + type_parameter.name,
@@ -156,7 +156,7 @@ Context:
156156
{% if config.type_parameter_headings %}
157157
{% filter heading(
158158
heading_level + 1,
159-
role="typeparam",
159+
role="typeparameter",
160160
id=obj.path ~ "[" ~ type_parameter.name ~ "]",
161161
class="doc doc-heading doc-heading-type_parameter",
162162
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-type_parameter"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + type_parameter.name,

src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ Context:
3737
{#- Brief or full function name depending on configuration. -#}
3838
{% set symbol_type = "method" if function.parent.is_class else "function" %}
3939
{#- Symbol type: method when parent is a class, function otherwise. -#}
40+
{% set object_type = symbol_type %}
41+
{#- Object type in objects inventory. -#}
4042

4143
{% if not root or config.show_root_heading %}
4244
{% filter heading(
4345
heading_level,
44-
role="function",
46+
role=object_type,
4547
id=html_id,
4648
class="doc doc-heading",
4749
toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else function.name),
@@ -106,7 +108,7 @@ Context:
106108
{% if config.show_root_toc_entry %}
107109
{% filter heading(
108110
heading_level,
109-
role="function",
111+
role=object_type,
110112
id=html_id,
111113
toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else function.name),
112114
hidden=True,

src/mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Context:
3535
{% if not root or config.show_root_heading %}
3636
{% filter heading(
3737
heading_level,
38-
role="typealias",
38+
role="type",
3939
id=html_id,
4040
class="doc doc-heading",
4141
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-type_alias"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + type_alias.name,
@@ -83,7 +83,7 @@ Context:
8383
{% else %}
8484
{% if config.show_root_toc_entry %}
8585
{% filter heading(heading_level,
86-
role="typealias",
86+
role="type",
8787
id=html_id,
8888
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-type_alias"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + type_alias.name,
8989
hidden=True,

0 commit comments

Comments
 (0)