Skip to content

Commit 0822ff9

Browse files
committed
feat: Wrap objects names in spans to allow custom styling
Spans are only used when signatures are separated. Issue mkdocstrings/mkdocstrings#240: mkdocstrings/mkdocstrings#240
1 parent 8fed314 commit 0822ff9

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
toc_label=attribute.name) %}
2323

2424
{% if config.separate_signature %}
25-
{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}
25+
<span class="doc doc-object-name doc-attribute-name">{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}</span>
2626
{% else %}
2727
{% filter highlight(language="python", inline=True) %}
2828
{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
toc_label=class.name) %}
2323

2424
{% if config.separate_signature %}
25-
{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
25+
<span class="doc doc-object-name doc-class-name">{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}</span>
2626
{% elif config.merge_init_into_class and "__init__" in class.members -%}
2727
{%- with function = class.members["__init__"] -%}
2828
{%- filter highlight(language="python", inline=True) -%}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
toc_label=function.name ~ "()") %}
2323

2424
{% if config.separate_signature %}
25-
{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}
25+
<span class="doc doc-object-name doc-function-name">{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}</span>
2626
{% else %}
2727
{% filter highlight(language="python", inline=True) %}
2828
{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}

src/mkdocstrings_handlers/python/templates/material/_base/module.html

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@
2121
class="doc doc-heading",
2222
toc_label=module.name) %}
2323

24-
{% if not config.separate_signature %}<code>{% endif %}
25-
{% if show_full_path %}{{ module.path }}{% else %}{{ module.name }}{% endif %}
26-
{% if not config.separate_signature %}</code>{% endif %}
24+
{% with module_name = module.path if show_full_path else module.name %}
25+
{% if config.separate_signature %}
26+
<span class="doc doc-object-name doc-module-name">{{ module_name }}</span>
27+
{% else %}
28+
<code>{{ module_name }}</code>
29+
{% endif %}
30+
{% endwith %}
2731

2832
{% with labels = module.labels %}
2933
{% include "labels.html" with context %}

0 commit comments

Comments
 (0)