Skip to content

Commit

Permalink
feat: Wrap objects names in spans to allow custom styling
Browse files Browse the repository at this point in the history
Spans are only used when signatures are separated.

Issue mkdocstrings/mkdocstrings#240: mkdocstrings/mkdocstrings#240
  • Loading branch information
pawamoy committed Apr 29, 2022
1 parent 8fed314 commit 0822ff9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
toc_label=attribute.name) %}

{% if config.separate_signature %}
{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}
<span class="doc doc-object-name doc-attribute-name">{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}</span>
{% else %}
{% filter highlight(language="python", inline=True) %}
{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
toc_label=class.name) %}

{% if config.separate_signature %}
{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
<span class="doc doc-object-name doc-class-name">{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}</span>
{% elif config.merge_init_into_class and "__init__" in class.members -%}
{%- with function = class.members["__init__"] -%}
{%- filter highlight(language="python", inline=True) -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
toc_label=function.name ~ "()") %}

{% if config.separate_signature %}
{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}
<span class="doc doc-object-name doc-function-name">{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}</span>
{% else %}
{% filter highlight(language="python", inline=True) %}
{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
class="doc doc-heading",
toc_label=module.name) %}

{% if not config.separate_signature %}<code>{% endif %}
{% if show_full_path %}{{ module.path }}{% else %}{{ module.name }}{% endif %}
{% if not config.separate_signature %}</code>{% endif %}
{% with module_name = module.path if show_full_path else module.name %}
{% if config.separate_signature %}
<span class="doc doc-object-name doc-module-name">{{ module_name }}</span>
{% else %}
<code>{{ module_name }}</code>
{% endif %}
{% endwith %}

{% with labels = module.labels %}
{% include "labels.html" with context %}
Expand Down

0 comments on commit 0822ff9

Please sign in to comment.