From fcba6ecaad1f123d67d6db75c917c82c9369f855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:41:05 +0000 Subject: [PATCH] Omit default values for attributes. We copy the mkdocstrings template for attributes so that we can exclude the (default) value for attributes (and class variables) from the documentation as that is generally useless. --- .../_templates/python/material/attribute.html | 67 +++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 68 insertions(+) create mode 100644 docs/_templates/python/material/attribute.html diff --git a/docs/_templates/python/material/attribute.html b/docs/_templates/python/material/attribute.html new file mode 100644 index 000000000..b4f6bcaf8 --- /dev/null +++ b/docs/_templates/python/material/attribute.html @@ -0,0 +1,67 @@ +{{ log.debug("Rendering " + attribute.path) }} + +
+{% with html_id = attribute.path %} + + {% if root %} + {% set show_full_path = config.show_root_full_path %} + {% set root_members = True %} + {% elif root_members %} + {% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %} + {% set root_members = False %} + {% else %} + {% set show_full_path = config.show_object_full_path %} + {% endif %} + + {% if not root or config.show_root_heading %} + + {% filter heading(heading_level, + role="data" if attribute.parent.kind.value == "module" else "attr", + id=html_id, + class="doc doc-heading", + toc_label=attribute.name) %} + + {% if config.separate_signature %} + {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %} + {% else %} + {% filter highlight(language="python", inline=True) %} + {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %} + {% if attribute.annotation %}: {{ attribute.annotation }}{% endif %} + {% endfilter %} + {% endif %} + + {% with labels = attribute.labels %} + {% include "labels.html" with context %} + {% endwith %} + + {% endfilter %} + + {% if config.separate_signature %} + {% filter highlight(language="python", inline=False) %} + {% filter format_code(config.line_length) %} + {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %} + {% if attribute.annotation %}: {{ attribute.annotation|safe }}{% endif %} + {% endfilter %} + {% endfilter %} + {% endif %} + + {% else %} + {% if config.show_root_toc_entry %} + {% filter heading(heading_level, + role="data" if attribute.parent.kind.value == "module" else "attr", + id=html_id, + toc_label=attribute.path if config.show_root_full_path else attribute.name, + hidden=True) %} + {% endfilter %} + {% endif %} + {% set heading_level = heading_level - 1 %} + {% endif %} + +
+ {% with docstring_sections = attribute.docstring.parsed %} + {% include "docstring.html" with context %} + {% endwith %} +
+ +{% endwith %} +
diff --git a/mkdocs.yml b/mkdocs.yml index 5c29f469c..021c95400 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -251,6 +251,7 @@ plugins: - search: - autorefs: - mkdocstrings: + custom_templates: docs/_templates default_handler: python handlers: python: