-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add
*.html.jinja
base templates, which are copies of `*.h…
…tml` templates, with an additional `logs` block, and using the updated `get_template` filter Issue-151: #151
- Loading branch information
Showing
43 changed files
with
2,308 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{% block logs scoped %} | ||
{{ log.debug("Rendering " + attribute.path) }} | ||
{% endblock logs %} | ||
|
||
<div class="doc doc-object doc-attribute"> | ||
{% with obj = attribute, 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 %} | ||
|
||
{% set attribute_name = attribute.path if show_full_path else attribute.name %} | ||
|
||
{% 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=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> '|safe if config.show_symbol_type_toc else '') + attribute.name, | ||
) %} | ||
|
||
{% block heading scoped %} | ||
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code>{% endif %} | ||
{% if config.separate_signature %} | ||
<span class="doc doc-object-name doc-attribute-name">{{ attribute_name }}</span> | ||
{% else %} | ||
{%+ filter highlight(language="python", inline=True) %} | ||
{{ attribute_name }}{% if attribute.annotation %}: {{ attribute.annotation }}{% endif %} | ||
{% if attribute.value %} = {{ attribute.value }}{% endif %} | ||
{% endfilter %} | ||
{% endif %} | ||
{% endblock heading %} | ||
|
||
{% block labels scoped %} | ||
{% with labels = attribute.labels %} | ||
{% include "labels"|get_template with context %} | ||
{% endwith %} | ||
{% endblock labels %} | ||
|
||
{% endfilter %} | ||
|
||
{% block signature scoped %} | ||
{% if config.separate_signature %} | ||
{% filter format_attribute(attribute, config.line_length, crossrefs=config.signature_crossrefs) %} | ||
{{ attribute.name }} | ||
{% endfilter %} | ||
{% endif %} | ||
{% endblock signature %} | ||
|
||
{% 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=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code> '|safe if config.show_symbol_type_toc else '') + attribute.name, | ||
hidden=True, | ||
) %} | ||
{% endfilter %} | ||
{% endif %} | ||
{% set heading_level = heading_level - 1 %} | ||
{% endif %} | ||
|
||
<div class="doc doc-contents {% if root %}first{% endif %}"> | ||
{% block contents scoped %} | ||
{% block docstring scoped %} | ||
{% with docstring_sections = attribute.docstring.parsed %} | ||
{% include "docstring"|get_template with context %} | ||
{% endwith %} | ||
{% endblock docstring %} | ||
{% endblock contents %} | ||
</div> | ||
|
||
{% endwith %} | ||
</div> |
156 changes: 156 additions & 0 deletions
156
src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
{% if obj.members %} | ||
{% block logs scoped %} | ||
{{ log.debug("Rendering children of " + obj.path) }} | ||
{% endblock logs %} | ||
|
||
<div class="doc doc-children"> | ||
|
||
{% if root_members %} | ||
{% set members_list = config.members %} | ||
{% else %} | ||
{% set members_list = none %} | ||
{% endif %} | ||
|
||
{% if config.group_by_category %} | ||
|
||
{% with %} | ||
|
||
{% if config.show_category_heading %} | ||
{% set extra_level = 1 %} | ||
{% else %} | ||
{% set extra_level = 0 %} | ||
{% endif %} | ||
|
||
{% with attributes = obj.attributes|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if attributes %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-attributes") %}Attributes{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for attribute in attributes|order_members(config.members_order, members_list) %} | ||
{% if members_list is not none or attribute.is_public(check_name=False) %} | ||
{% include attribute|get_template with context %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% with classes = obj.classes|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if classes %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-classes") %}Classes{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for class in classes|order_members(config.members_order, members_list) %} | ||
{% if members_list is not none or class.is_public(check_name=False) %} | ||
{% include class|get_template with context %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% with functions = obj.functions|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if functions %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-functions") %}Functions{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for function in functions|order_members(config.members_order, members_list) %} | ||
{% if not (obj.kind.value == "class" and function.name == "__init__" and config.merge_init_into_class) %} | ||
{% if members_list is not none or function.is_public(check_name=False) %} | ||
{% include function|get_template with context %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% if config.show_submodules %} | ||
{% with modules = obj.modules|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if modules %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-modules") %}Modules{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for module in modules|order_members(config.members_order.alphabetical, members_list) %} | ||
{% if members_list is not none or module.is_public(check_name=False) %} | ||
{% include module|get_template with context %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
{% endif %} | ||
|
||
{% endwith %} | ||
|
||
{% else %} | ||
|
||
{% for child in obj.all_members | ||
|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) | ||
|order_members(config.members_order, members_list) | ||
%} | ||
|
||
{% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %} | ||
|
||
{% if members_list is not none or child.is_public(check_name=False) %} | ||
{% if child.is_attribute %} | ||
{% with attribute = child %} | ||
{% include attribute|get_template with context %} | ||
{% endwith %} | ||
|
||
{% elif child.is_class %} | ||
{% with class = child %} | ||
{% include class|get_template with context %} | ||
{% endwith %} | ||
|
||
{% elif child.is_function %} | ||
{% with function = child %} | ||
{% include function|get_template with context %} | ||
{% endwith %} | ||
|
||
{% elif child.is_module and config.show_submodules %} | ||
{% with module = child %} | ||
{% include module|get_template with context %} | ||
{% endwith %} | ||
|
||
{% endif %} | ||
{% endif %} | ||
|
||
{% endif %} | ||
|
||
{% endfor %} | ||
|
||
{% endif %} | ||
|
||
</div> | ||
|
||
{% endif %} |
144 changes: 144 additions & 0 deletions
144
src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{% block logs scoped %} | ||
{{ log.debug("Rendering " + class.path) }} | ||
{% endblock logs %} | ||
|
||
<div class="doc doc-object doc-class"> | ||
{% with obj = class, html_id = class.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 %} | ||
|
||
{% set class_name = class.path if show_full_path else class.name %} | ||
|
||
{% if not root or config.show_root_heading %} | ||
{% filter heading( | ||
heading_level, | ||
role="class", | ||
id=html_id, | ||
class="doc doc-heading", | ||
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> '|safe if config.show_symbol_type_toc else '') + class.name, | ||
) %} | ||
|
||
{% block heading scoped %} | ||
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code>{% endif %} | ||
{% if config.separate_signature %} | ||
<span class="doc doc-object-name doc-class-name">{{ class_name }}</span> | ||
{% elif config.merge_init_into_class and "__init__" in class.all_members %} | ||
{% with function = class.all_members["__init__"] %} | ||
{%+ filter highlight(language="python", inline=True) %} | ||
{{ class_name }}{% include "signature"|get_template with context %} | ||
{% endfilter %} | ||
{% endwith %} | ||
{% else %} | ||
<code>{{ class_name }}</code> | ||
{% endif %} | ||
{% endblock heading %} | ||
|
||
{% block labels scoped %} | ||
{% with labels = class.labels %} | ||
{% include "labels"|get_template with context %} | ||
{% endwith %} | ||
{% endblock labels %} | ||
|
||
{% endfilter %} | ||
|
||
{% block signature scoped %} | ||
{% if config.separate_signature and config.merge_init_into_class %} | ||
{% if "__init__" in class.all_members %} | ||
{% with function = class.all_members["__init__"] %} | ||
{% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} | ||
{{ class.name }} | ||
{% endfilter %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endif %} | ||
{% endblock signature %} | ||
|
||
{% else %} | ||
{% if config.show_root_toc_entry %} | ||
{% filter heading(heading_level, | ||
role="class", | ||
id=html_id, | ||
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code> '|safe if config.show_symbol_type_toc else '') + class.name, | ||
hidden=True, | ||
) %} | ||
{% endfilter %} | ||
{% endif %} | ||
{% set heading_level = heading_level - 1 %} | ||
{% endif %} | ||
|
||
<div class="doc doc-contents {% if root %}first{% endif %}"> | ||
{% block contents scoped %} | ||
{% block bases scoped %} | ||
{% if config.show_bases and class.bases %} | ||
<p class="doc doc-class-bases"> | ||
Bases: {% for expression in class.bases -%} | ||
<code>{% include "expression"|get_template with context %}</code>{% if not loop.last %}, {% endif %} | ||
{% endfor -%} | ||
</p> | ||
{% endif %} | ||
{% endblock bases %} | ||
|
||
{% block docstring scoped %} | ||
{% with docstring_sections = class.docstring.parsed %} | ||
{% include "docstring"|get_template with context %} | ||
{% endwith %} | ||
{% if config.merge_init_into_class %} | ||
{% if "__init__" in class.all_members and class.all_members["__init__"].has_docstring %} | ||
{% with docstring_sections = class.all_members["__init__"].docstring.parsed %} | ||
{% include "docstring"|get_template with context %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endif %} | ||
{% endblock docstring %} | ||
|
||
{% block source scoped %} | ||
{% if config.show_source %} | ||
{% if config.merge_init_into_class %} | ||
{% if "__init__" in class.all_members and class.all_members["__init__"].source %} | ||
{% with init = class.all_members["__init__"] %} | ||
<details class="quote"> | ||
<summary>Source code in <code> | ||
{%- if init.relative_filepath.is_absolute() -%} | ||
{{ init.relative_package_filepath }} | ||
{%- else -%} | ||
{{ init.relative_filepath }} | ||
{%- endif -%} | ||
</code></summary> | ||
{{ init.source|highlight(language="python", linestart=init.lineno, linenums=True) }} | ||
</details> | ||
{% endwith %} | ||
{% endif %} | ||
{% elif class.source %} | ||
<details class="quote"> | ||
<summary>Source code in <code> | ||
{%- if class.relative_filepath.is_absolute() -%} | ||
{{ class.relative_package_filepath }} | ||
{%- else -%} | ||
{{ class.relative_filepath }} | ||
{%- endif -%} | ||
</code></summary> | ||
{{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }} | ||
</details> | ||
{% endif %} | ||
{% endif %} | ||
{% endblock source %} | ||
|
||
{% block children scoped %} | ||
{% set root = False %} | ||
{% set heading_level = heading_level + 1 %} | ||
{% include "children"|get_template with context %} | ||
{% endblock children %} | ||
{% endblock contents %} | ||
</div> | ||
|
||
{% endwith %} | ||
|
||
</div> |
Oops, something went wrong.