Skip to content

Commit

Permalink
feat: Add CSS classes doc-section-title and doc-section-item in d…
Browse files Browse the repository at this point in the history
…ocstring sections

Issue-17: #17
  • Loading branch information
pawamoy committed Apr 12, 2024
1 parent 0a2e917 commit d6e1d68
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Attributes:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -15,7 +15,7 @@
</thead>
<tbody>
{% for attribute in section.value %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ attribute.name }}">{{ attribute.name }}</span></code></td>
<td>
{% if attribute.annotation %}
Expand All @@ -36,10 +36,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Attributes:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p>
<ul>
{% for attribute in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ attribute.name }}">{{ attribute.name }}</span></code></b>
{% if attribute.annotation %}
{% with expression = attribute.annotation %}
Expand All @@ -59,13 +59,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for attribute in section.value %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ attribute.name }}">{{ attribute.name }}</span></code></td>
<td class="doc-attribute-details">
<div class="doc-md-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Classes:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Classes:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -14,7 +14,7 @@
</thead>
<tbody>
{% for class in section.value %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ class.name }}">{{ class.name }}</span></code></td>
<td>
<div class="doc-md-description">
Expand All @@ -28,10 +28,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Classes:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Classes:") }}</span></p>
<ul>
{% for class in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ class.name }}">{{ class.name }}</span></code></b>
<div class="doc-md-description">
Expand All @@ -46,13 +46,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("CLASS")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("CLASS")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for class in section.value %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ class.name }}">{{ class.name }}</span></code></td>
<td class="doc-class-details">
<div class="doc-md-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<p><strong>{{ section.title or lang.t("Examples:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Examples:") }}</span></p>
{% for section_type, sub_section in section.value %}
{% if section_type.value == "text" %}
{{ sub_section|convert_markdown(heading_level, html_id) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -15,7 +15,7 @@
<tbody>
{% for function in section.value %}
{% if not function.name == "__init__" or not config.merge_init_into_class %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ function.name }}">{{ function.name }}</span></code></td>
<td>
<div class="doc-md-description">
Expand All @@ -30,11 +30,11 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}</span></p>
<ul>
{% for function in section.value %}
{% if not function.name == "__init__" or not config.merge_init_into_class %}
<li class="field-body">
<li class="doc-section-item field-body">
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ function.name }}">{{ function.name }}</span></code></b>
<div class="doc-md-description">
Expand All @@ -50,14 +50,14 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("METHOD") if obj.is_class else lang.t("FUNCTION")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("METHOD") if obj.is_class else lang.t("FUNCTION")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for function in section.value %}
{% if not function.name == "__init__" or not config.merge_init_into_class %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ function.name }}">{{ function.name }}</span></code></td>
<td class="doc-function-details">
<div class="doc-md-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Modules:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Modules:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -14,7 +14,7 @@
</thead>
<tbody>
{% for module in section.value %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ module.name }}">{{ module.name }}</span></code></td>
<td>
<div class="doc-md-description">
Expand All @@ -28,10 +28,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Modules:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Modules:") }}</span></p>
<ul>
{% for module in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
<b><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ module.name }}">{{ module.name }}</span></code></b>
<div class="doc-md-description">
Expand All @@ -46,13 +46,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("MODULE")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("MODULE")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for module in section.value %}
<tr>
<tr class="doc-section-item">
<td><code><span data-autorefs-optional-hover="{{ obj.path }}.{{ module.name }}">{{ module.name }}</span></code></td>
<td class="doc-module-details">
<div class="doc-md-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Other Parameters:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Other Parameters:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -15,7 +15,7 @@
</thead>
<tbody>
{% for parameter in section.value %}
<tr>
<tr class="doc-section-item">
<td><code>{{ parameter.name }}</code></td>
<td>
{% if parameter.annotation %}
Expand All @@ -36,10 +36,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Other Parameters:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Other Parameters:") }}</span></p>
<ul>
{% for parameter in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
<b><code>{{ parameter.name }}</code></b>
{% if parameter.annotation %}
{% with expression = parameter.annotation %}
Expand All @@ -59,13 +59,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for parameter in section.value %}
<tr>
<tr class="doc-section-item">
<td><code>{{ parameter.name }}</code></td>
<td class="doc-param-details">
<div class="doc-md-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Parameters:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Parameters:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -16,7 +16,7 @@
</thead>
<tbody>
{% for parameter in section.value %}
<tr>
<tr class="doc-section-item">
<td><code>{{ parameter.name }}</code></td>
<td>
{% if parameter.annotation %}
Expand Down Expand Up @@ -46,10 +46,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Parameters:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Parameters:") }}</span></p>
<ul>
{% for parameter in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
<b><code>{{ parameter.name }}</code></b>
{% if parameter.annotation %}
{% with expression = parameter.annotation %}
Expand All @@ -74,13 +74,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</b></th>
<th><b> {{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for parameter in section.value %}
<tr>
<tr class="doc-section-item">
<td><code>{{ parameter.name }}</code></td>
<td class="doc-param-details">
<div class="doc-md-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
<p><strong>{{ section.title or lang.t("Raises:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Raises:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -14,7 +14,7 @@
</thead>
<tbody>
{% for raises in section.value %}
<tr>
<tr class="doc-section-item">
<td>
{% if raises.annotation %}
{% with expression = raises.annotation %}
Expand All @@ -34,10 +34,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ lang.t(section.title) or lang.t("Raises:") }}</p>
<p><span class="doc-section-title">{{ lang.t(section.title) or lang.t("Raises:") }}</span></p>
<ul>
{% for raises in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
{% if raises.annotation %}
{% with expression = raises.annotation %}
<code>{% include "expression.html" with context %}</code>
Expand All @@ -56,13 +56,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("RAISES")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("RAISES")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for raises in section.value %}
<tr>
<tr class="doc-section-item">
<td>
<span class="doc-raises-annotation">
{% with expression = raises.annotation %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
{% set name_column = section.value|selectattr("name")|any %}
<p><strong>{{ section.title or lang.t("Receives:") }}</strong></p>
<p><span class="doc-section-title">{{ section.title or lang.t("Receives:") }}</span></p>
<table>
<thead>
<tr>
Expand All @@ -16,7 +16,7 @@
</thead>
<tbody>
{% for receives in section.value %}
<tr>
<tr class="doc-section-item">
{% if name_column %}<td>{% if receives.name %}<code>{{ receives.name }}</code>{% endif %}</td>{% endif %}
<td>
{% if receives.annotation %}
Expand All @@ -37,10 +37,10 @@
{% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
{% block list_style scoped %}
<p>{{ section.title or lang.t("Receives:") }}</p>
<p><span class="doc-section-title">{{ section.title or lang.t("Receives:") }}</span></p>
<ul>
{% for receives in section.value %}
<li class="field-body">
<li class="doc-section-item field-body">
{% if receives.name %}<b><code>{{ receives.name }}</code></b>{% endif %}
{% if receives.annotation %}
{% with expression = receives.annotation %}
Expand All @@ -62,13 +62,13 @@
<table>
<thead>
<tr>
<th><b>{{ (section.title or lang.t("RECEIVES")).rstrip(":").upper() }}</b></th>
<th><b>{{ lang.t("DESCRIPTION") }}</b></th>
<th><span class="doc-section-title">{{ (section.title or lang.t("RECEIVES")).rstrip(":").upper() }}</span></th>
<th><span>{{ lang.t("DESCRIPTION") }}</span></th>
</tr>
</thead>
<tbody>
{% for receives in section.value %}
<tr>
<tr class="doc-section-item">
<td>
{% if receives.name %}
<code>{{ receives.name }}</code>
Expand Down
Loading

0 comments on commit d6e1d68

Please sign in to comment.