Skip to content

Commit d6e1d68

Browse files
committed
feat: Add CSS classes doc-section-title and doc-section-item in docstring sections
Issue-17: #17
1 parent 0a2e917 commit d6e1d68

File tree

13 files changed

+83
-78
lines changed

13 files changed

+83
-78
lines changed

src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Attributes:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -15,7 +15,7 @@
1515
</thead>
1616
<tbody>
1717
{% for attribute in section.value %}
18-
<tr>
18+
<tr class="doc-section-item">
1919
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ attribute.name }}">{{ attribute.name }}</span></code></td>
2020
<td>
2121
{% if attribute.annotation %}
@@ -36,10 +36,10 @@
3636
{% endblock table_style %}
3737
{% elif config.docstring_section_style == "list" %}
3838
{% block list_style scoped %}
39-
<p>{{ section.title or lang.t("Attributes:") }}</p>
39+
<p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p>
4040
<ul>
4141
{% for attribute in section.value %}
42-
<li class="field-body">
42+
<li class="doc-section-item field-body">
4343
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ attribute.name }}">{{ attribute.name }}</span></code></b>
4444
{% if attribute.annotation %}
4545
{% with expression = attribute.annotation %}
@@ -59,13 +59,13 @@
5959
<table>
6060
<thead>
6161
<tr>
62-
<th><b>{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}</b></th>
63-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
62+
<th><span class="doc-section-title">{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}</span></th>
63+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
6464
</tr>
6565
</thead>
6666
<tbody>
6767
{% for attribute in section.value %}
68-
<tr>
68+
<tr class="doc-section-item">
6969
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ attribute.name }}">{{ attribute.name }}</span></code></td>
7070
<td class="doc-attribute-details">
7171
<div class="doc-md-description">

src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Classes:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Classes:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -14,7 +14,7 @@
1414
</thead>
1515
<tbody>
1616
{% for class in section.value %}
17-
<tr>
17+
<tr class="doc-section-item">
1818
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ class.name }}">{{ class.name }}</span></code></td>
1919
<td>
2020
<div class="doc-md-description">
@@ -28,10 +28,10 @@
2828
{% endblock table_style %}
2929
{% elif config.docstring_section_style == "list" %}
3030
{% block list_style scoped %}
31-
<p>{{ section.title or lang.t("Classes:") }}</p>
31+
<p><span class="doc-section-title">{{ section.title or lang.t("Classes:") }}</span></p>
3232
<ul>
3333
{% for class in section.value %}
34-
<li class="field-body">
34+
<li class="doc-section-item field-body">
3535
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ class.name }}">{{ class.name }}</span></code></b>
3636
3737
<div class="doc-md-description">
@@ -46,13 +46,13 @@
4646
<table>
4747
<thead>
4848
<tr>
49-
<th><b>{{ (section.title or lang.t("CLASS")).rstrip(":").upper() }}</b></th>
50-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
49+
<th><span class="doc-section-title">{{ (section.title or lang.t("CLASS")).rstrip(":").upper() }}</span></th>
50+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
5151
</tr>
5252
</thead>
5353
<tbody>
5454
{% for class in section.value %}
55-
<tr>
55+
<tr class="doc-section-item">
5656
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ class.name }}">{{ class.name }}</span></code></td>
5757
<td class="doc-class-details">
5858
<div class="doc-md-description">

src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{% import "language.html" as lang with context %}
44

5-
<p><strong>{{ section.title or lang.t("Examples:") }}</strong></p>
5+
<p><span class="doc-section-title">{{ section.title or lang.t("Examples:") }}</span></p>
66
{% for section_type, sub_section in section.value %}
77
{% if section_type.value == "text" %}
88
{{ sub_section|convert_markdown(heading_level, html_id) }}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -15,7 +15,7 @@
1515
<tbody>
1616
{% for function in section.value %}
1717
{% if not function.name == "__init__" or not config.merge_init_into_class %}
18-
<tr>
18+
<tr class="doc-section-item">
1919
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ function.name }}">{{ function.name }}</span></code></td>
2020
<td>
2121
<div class="doc-md-description">
@@ -30,11 +30,11 @@
3030
{% endblock table_style %}
3131
{% elif config.docstring_section_style == "list" %}
3232
{% block list_style scoped %}
33-
<p>{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</p>
33+
<p><span class="doc-section-title">{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</span></p>
3434
<ul>
3535
{% for function in section.value %}
3636
{% if not function.name == "__init__" or not config.merge_init_into_class %}
37-
<li class="field-body">
37+
<li class="doc-section-item field-body">
3838
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ function.name }}">{{ function.name }}</span></code></b>
3939
4040
<div class="doc-md-description">
@@ -50,14 +50,14 @@
5050
<table>
5151
<thead>
5252
<tr>
53-
<th><b>{{ (section.title or lang.t("METHOD") if obj.is_class else lang.t("FUNCTION")).rstrip(":").upper() }}</b></th>
54-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
53+
<th><span class="doc-section-title">{{ (section.title or lang.t("METHOD") if obj.is_class else lang.t("FUNCTION")).rstrip(":").upper() }}</span></th>
54+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
5555
</tr>
5656
</thead>
5757
<tbody>
5858
{% for function in section.value %}
5959
{% if not function.name == "__init__" or not config.merge_init_into_class %}
60-
<tr>
60+
<tr class="doc-section-item">
6161
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ function.name }}">{{ function.name }}</span></code></td>
6262
<td class="doc-function-details">
6363
<div class="doc-md-description">

src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Modules:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Modules:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -14,7 +14,7 @@
1414
</thead>
1515
<tbody>
1616
{% for module in section.value %}
17-
<tr>
17+
<tr class="doc-section-item">
1818
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ module.name }}">{{ module.name }}</span></code></td>
1919
<td>
2020
<div class="doc-md-description">
@@ -28,10 +28,10 @@
2828
{% endblock table_style %}
2929
{% elif config.docstring_section_style == "list" %}
3030
{% block list_style scoped %}
31-
<p>{{ section.title or lang.t("Modules:") }}</p>
31+
<p><span class="doc-section-title">{{ section.title or lang.t("Modules:") }}</span></p>
3232
<ul>
3333
{% for module in section.value %}
34-
<li class="field-body">
34+
<li class="doc-section-item field-body">
3535
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ module.name }}">{{ module.name }}</span></code></b>
3636
3737
<div class="doc-md-description">
@@ -46,13 +46,13 @@
4646
<table>
4747
<thead>
4848
<tr>
49-
<th><b>{{ (section.title or lang.t("MODULE")).rstrip(":").upper() }}</b></th>
50-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
49+
<th><span class="doc-section-title">{{ (section.title or lang.t("MODULE")).rstrip(":").upper() }}</span></th>
50+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
5151
</tr>
5252
</thead>
5353
<tbody>
5454
{% for module in section.value %}
55-
<tr>
55+
<tr class="doc-section-item">
5656
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ module.name }}">{{ module.name }}</span></code></td>
5757
<td class="doc-module-details">
5858
<div class="doc-md-description">

src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Other Parameters:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Other Parameters:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -15,7 +15,7 @@
1515
</thead>
1616
<tbody>
1717
{% for parameter in section.value %}
18-
<tr>
18+
<tr class="doc-section-item">
1919
<td><code>{{ parameter.name }}</code></td>
2020
<td>
2121
{% if parameter.annotation %}
@@ -36,10 +36,10 @@
3636
{% endblock table_style %}
3737
{% elif config.docstring_section_style == "list" %}
3838
{% block list_style scoped %}
39-
<p>{{ section.title or lang.t("Other Parameters:") }}</p>
39+
<p><span class="doc-section-title">{{ section.title or lang.t("Other Parameters:") }}</span></p>
4040
<ul>
4141
{% for parameter in section.value %}
42-
<li class="field-body">
42+
<li class="doc-section-item field-body">
4343
<b><code>{{ parameter.name }}</code></b>
4444
{% if parameter.annotation %}
4545
{% with expression = parameter.annotation %}
@@ -59,13 +59,13 @@
5959
<table>
6060
<thead>
6161
<tr>
62-
<th><b>{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</b></th>
63-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
62+
<th><span class="doc-section-title">{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</span></th>
63+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
6464
</tr>
6565
</thead>
6666
<tbody>
6767
{% for parameter in section.value %}
68-
<tr>
68+
<tr class="doc-section-item">
6969
<td><code>{{ parameter.name }}</code></td>
7070
<td class="doc-param-details">
7171
<div class="doc-md-description">

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Parameters:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Parameters:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -16,7 +16,7 @@
1616
</thead>
1717
<tbody>
1818
{% for parameter in section.value %}
19-
<tr>
19+
<tr class="doc-section-item">
2020
<td><code>{{ parameter.name }}</code></td>
2121
<td>
2222
{% if parameter.annotation %}
@@ -46,10 +46,10 @@
4646
{% endblock table_style %}
4747
{% elif config.docstring_section_style == "list" %}
4848
{% block list_style scoped %}
49-
<p>{{ section.title or lang.t("Parameters:") }}</p>
49+
<p><span class="doc-section-title">{{ section.title or lang.t("Parameters:") }}</span></p>
5050
<ul>
5151
{% for parameter in section.value %}
52-
<li class="field-body">
52+
<li class="doc-section-item field-body">
5353
<b><code>{{ parameter.name }}</code></b>
5454
{% if parameter.annotation %}
5555
{% with expression = parameter.annotation %}
@@ -74,13 +74,13 @@
7474
<table>
7575
<thead>
7676
<tr>
77-
<th><b>{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</b></th>
78-
<th><b> {{ lang.t("DESCRIPTION") }}</b></th>
77+
<th><span class="doc-section-title">{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</span></th>
78+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
7979
</tr>
8080
</thead>
8181
<tbody>
8282
{% for parameter in section.value %}
83-
<tr>
83+
<tr class="doc-section-item">
8484
<td><code>{{ parameter.name }}</code></td>
8585
<td class="doc-param-details">
8686
<div class="doc-md-description">

src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
7-
<p><strong>{{ section.title or lang.t("Raises:") }}</strong></p>
7+
<p><span class="doc-section-title">{{ section.title or lang.t("Raises:") }}</span></p>
88
<table>
99
<thead>
1010
<tr>
@@ -14,7 +14,7 @@
1414
</thead>
1515
<tbody>
1616
{% for raises in section.value %}
17-
<tr>
17+
<tr class="doc-section-item">
1818
<td>
1919
{% if raises.annotation %}
2020
{% with expression = raises.annotation %}
@@ -34,10 +34,10 @@
3434
{% endblock table_style %}
3535
{% elif config.docstring_section_style == "list" %}
3636
{% block list_style scoped %}
37-
<p>{{ lang.t(section.title) or lang.t("Raises:") }}</p>
37+
<p><span class="doc-section-title">{{ lang.t(section.title) or lang.t("Raises:") }}</span></p>
3838
<ul>
3939
{% for raises in section.value %}
40-
<li class="field-body">
40+
<li class="doc-section-item field-body">
4141
{% if raises.annotation %}
4242
{% with expression = raises.annotation %}
4343
<code>{% include "expression.html" with context %}</code>
@@ -56,13 +56,13 @@
5656
<table>
5757
<thead>
5858
<tr>
59-
<th><b>{{ (section.title or lang.t("RAISES")).rstrip(":").upper() }}</b></th>
60-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
59+
<th><span class="doc-section-title">{{ (section.title or lang.t("RAISES")).rstrip(":").upper() }}</span></th>
60+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
6161
</tr>
6262
</thead>
6363
<tbody>
6464
{% for raises in section.value %}
65-
<tr>
65+
<tr class="doc-section-item">
6666
<td>
6767
<span class="doc-raises-annotation">
6868
{% with expression = raises.annotation %}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/receives.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% if config.docstring_section_style == "table" %}
66
{% block table_style scoped %}
77
{% set name_column = section.value|selectattr("name")|any %}
8-
<p><strong>{{ section.title or lang.t("Receives:") }}</strong></p>
8+
<p><span class="doc-section-title">{{ section.title or lang.t("Receives:") }}</span></p>
99
<table>
1010
<thead>
1111
<tr>
@@ -16,7 +16,7 @@
1616
</thead>
1717
<tbody>
1818
{% for receives in section.value %}
19-
<tr>
19+
<tr class="doc-section-item">
2020
{% if name_column %}<td>{% if receives.name %}<code>{{ receives.name }}</code>{% endif %}</td>{% endif %}
2121
<td>
2222
{% if receives.annotation %}
@@ -37,10 +37,10 @@
3737
{% endblock table_style %}
3838
{% elif config.docstring_section_style == "list" %}
3939
{% block list_style scoped %}
40-
<p>{{ section.title or lang.t("Receives:") }}</p>
40+
<p><span class="doc-section-title">{{ section.title or lang.t("Receives:") }}</span></p>
4141
<ul>
4242
{% for receives in section.value %}
43-
<li class="field-body">
43+
<li class="doc-section-item field-body">
4444
{% if receives.name %}<b><code>{{ receives.name }}</code></b>{% endif %}
4545
{% if receives.annotation %}
4646
{% with expression = receives.annotation %}
@@ -62,13 +62,13 @@
6262
<table>
6363
<thead>
6464
<tr>
65-
<th><b>{{ (section.title or lang.t("RECEIVES")).rstrip(":").upper() }}</b></th>
66-
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
65+
<th><span class="doc-section-title">{{ (section.title or lang.t("RECEIVES")).rstrip(":").upper() }}</span></th>
66+
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
6767
</tr>
6868
</thead>
6969
<tbody>
7070
{% for receives in section.value %}
71-
<tr>
71+
<tr class="doc-section-item">
7272
<td>
7373
{% if receives.name %}
7474
<code>{{ receives.name }}</code>

0 commit comments

Comments
 (0)