Skip to content

Commit

Permalink
feat: Support attributes section in Google-style docstrings
Browse files Browse the repository at this point in the history
Issue #88
  • Loading branch information
pawamoy committed Jun 14, 2020
1 parent d52d821 commit 8300253
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mkdocstrings/handlers/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class PythonRenderer(BaseRenderer):
It defines some configuration options, implements the `render` method,
and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.BaseRenderer].
Attributes:
FALLBACK_THEME: The theme to fallback to.
DEFAULT_CONFIG: The default rendering options,
see [`DEFAULT_CONFIG`][mkdocstrings.handlers.python.PythonRenderer.DEFAULT_CONFIG].
"""

FALLBACK_THEME = "material"
Expand Down
19 changes: 19 additions & 0 deletions src/mkdocstrings/templates/python/material/attributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<p><strong>Attributes:</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for attribute in attributes %}
<tr>
<td><code>{{ attribute.name }}</code></td>
<td><code>{{ attribute.annotation }}</code></td>
<td>{{ attribute.description|convert_markdown }}</td>
</tr>
{% endfor %}
</tbody>
</table>
4 changes: 4 additions & 0 deletions src/mkdocstrings/templates/python/material/docstring.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{% for section in docstring_sections %}
{% if section.type == "markdown" %}
{{ section.value|convert_markdown }}
{% elif section.type == "attributes" %}
{% with attributes = section.value %}
{% include "attributes.html" with context %}
{% endwith %}
{% elif section.type == "parameters" %}
{% with parameters = section.value %}
{% include "parameters.html" with context %}
Expand Down

0 comments on commit 8300253

Please sign in to comment.