diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja new file mode 100644 index 00000000..fd537034 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html.jinja @@ -0,0 +1,82 @@ +{% block logs scoped %} + {{ log.debug("Rendering " + attribute.path) }} +{% endblock logs %} + +
+ {% 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=(' '|safe if config.show_symbol_type_toc else '') + attribute.name, + ) %} + + {% block heading scoped %} + {% if config.show_symbol_type_heading %}{% endif %} + {% if config.separate_signature %} + {{ attribute_name }} + {% 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=(' '|safe if config.show_symbol_type_toc else '') + attribute.name, + hidden=True, + ) %} + {% endfilter %} + {% endif %} + {% set heading_level = heading_level - 1 %} + {% endif %} + +
+ {% block contents scoped %} + {% block docstring scoped %} + {% with docstring_sections = attribute.docstring.parsed %} + {% include "docstring"|get_template with context %} + {% endwith %} + {% endblock docstring %} + {% endblock contents %} +
+ + {% endwith %} +
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja new file mode 100644 index 00000000..b63b9a6a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja @@ -0,0 +1,156 @@ +{% if obj.members %} + {% block logs scoped %} + {{ log.debug("Rendering children of " + obj.path) }} + {% endblock logs %} + +
+ + {% 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 %} + +
+ +{% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja new file mode 100644 index 00000000..2bfa2bf0 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja @@ -0,0 +1,144 @@ +{% block logs scoped %} + {{ log.debug("Rendering " + class.path) }} +{% endblock logs %} + +
+ {% 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=(' '|safe if config.show_symbol_type_toc else '') + class.name, + ) %} + + {% block heading scoped %} + {% if config.show_symbol_type_heading %}{% endif %} + {% if config.separate_signature %} + {{ class_name }} + {% 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 %} + {{ class_name }} + {% 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=(' '|safe if config.show_symbol_type_toc else '') + class.name, + hidden=True, + ) %} + {% endfilter %} + {% endif %} + {% set heading_level = heading_level - 1 %} + {% endif %} + +
+ {% block contents scoped %} + {% block bases scoped %} + {% if config.show_bases and class.bases %} +

+ Bases: {% for expression in class.bases -%} + {% include "expression"|get_template with context %}{% if not loop.last %}, {% endif %} + {% endfor -%} +

+ {% 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__"] %} +
+ Source code in + {%- if init.relative_filepath.is_absolute() -%} + {{ init.relative_package_filepath }} + {%- else -%} + {{ init.relative_filepath }} + {%- endif -%} + + {{ init.source|highlight(language="python", linestart=init.lineno, linenums=True) }} +
+ {% endwith %} + {% endif %} + {% elif class.source %} +
+ Source code in + {%- if class.relative_filepath.is_absolute() -%} + {{ class.relative_package_filepath }} + {%- else -%} + {{ class.relative_filepath }} + {%- endif -%} + + {{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }} +
+ {% 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 %} +
+ + {% endwith %} + +
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja new file mode 100644 index 00000000..8477dc0a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring.html.jinja @@ -0,0 +1,36 @@ +{% if docstring_sections %} + {% block logs scoped %} + {{ log.debug("Rendering docstring") }} + {% endblock logs %} + {% for section in docstring_sections %} + {% if config.show_docstring_description and section.kind.value == "text" %} + {{ section.value|convert_markdown(heading_level, html_id) }} + {% elif config.show_docstring_attributes and section.kind.value == "attributes" %} + {% include "docstring/attributes"|get_template with context %} + {% elif config.show_docstring_functions and section.kind.value == "functions" %} + {% include "docstring/functions"|get_template with context %} + {% elif config.show_docstring_classes and section.kind.value == "classes" %} + {% include "docstring/classes"|get_template with context %} + {% elif config.show_docstring_modules and section.kind.value == "modules" %} + {% include "docstring/modules"|get_template with context %} + {% elif config.show_docstring_parameters and section.kind.value == "parameters" %} + {% include "docstring/parameters"|get_template with context %} + {% elif config.show_docstring_other_parameters and section.kind.value == "other parameters" %} + {% include "docstring/other_parameters"|get_template with context %} + {% elif config.show_docstring_raises and section.kind.value == "raises" %} + {% include "docstring/raises"|get_template with context %} + {% elif config.show_docstring_warns and section.kind.value == "warns" %} + {% include "docstring/warns"|get_template with context %} + {% elif config.show_docstring_yields and section.kind.value == "yields" %} + {% include "docstring/yields"|get_template with context %} + {% elif config.show_docstring_receives and section.kind.value == "receives" %} + {% include "docstring/receives"|get_template with context %} + {% elif config.show_docstring_returns and section.kind.value == "returns" %} + {% include "docstring/returns"|get_template with context %} + {% elif config.show_docstring_examples and section.kind.value == "examples" %} + {% include "docstring/examples"|get_template with context %} + {% elif config.show_docstring_description and section.kind.value == "admonition" %} + {% include "docstring/admonition"|get_template with context %} + {% endif %} + {% endfor %} +{% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/admonition.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/admonition.html.jinja new file mode 100644 index 00000000..b5053342 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/admonition.html.jinja @@ -0,0 +1,7 @@ +{% block logs scoped %} + {{ log.debug("Rendering admonition") }} +{% endblock logs %} +
+ {{ section.title|convert_markdown(heading_level, html_id, strip_paragraph=True) }} + {{ section.value.contents|convert_markdown(heading_level, html_id) }} +
\ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja new file mode 100644 index 00000000..d1bb3bb0 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja @@ -0,0 +1,92 @@ +{% block logs scoped %} + {{ log.debug("Rendering attributes section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Attributes:") }}

+ + + + + + + + + + {% for attribute in section.value %} + + + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Type") }}{{ lang.t("Description") }}
{{ attribute.name }} + {% if attribute.annotation %} + {% with expression = attribute.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ attribute.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Attributes:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for attribute in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ attribute.name }} +
+ {{ attribute.description|convert_markdown(heading_level, html_id) }} +
+

+ {% if attribute.annotation %} + + TYPE: + {% with expression = attribute.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} +

+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja new file mode 100644 index 00000000..60ec7e54 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/classes.html.jinja @@ -0,0 +1,69 @@ +{% block logs scoped %} + {{ log.debug("Rendering classes section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Classes:") }}

+ + + + + + + + + {% for class in section.value %} + + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Description") }}
{{ class.name }} +
+ {{ class.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Classes:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for class in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("CLASS")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ class.name }} +
+ {{ class.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja new file mode 100644 index 00000000..1e79a53a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/examples.html.jinja @@ -0,0 +1,14 @@ +{% block logs scoped %} + {{ log.debug("Rendering examples section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +

{{ section.title or lang.t("Examples:") }}

+{% for section_type, sub_section in section.value %} + {% if section_type.value == "text" %} + {{ sub_section|convert_markdown(heading_level, html_id) }} + {% elif section_type.value == "examples" %} + {{ sub_section|highlight(language="pycon", linenums=False) }} + {% endif %} +{% endfor %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja new file mode 100644 index 00000000..35197c80 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/functions.html.jinja @@ -0,0 +1,75 @@ +{% block logs scoped %} + {{ log.debug("Rendering functions section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}

+ + + + + + + + + {% for function in section.value %} + {% if not function.name == "__init__" or not config.merge_init_into_class %} + + + + + {% endif %} + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Description") }}
{{ function.name }} +
+ {{ function.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Methods:") if obj.is_class else lang.t("Functions:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for function in section.value %} + {% if not function.name == "__init__" or not config.merge_init_into_class %} + + + + + {% endif %} + {% endfor %} + +
{{ (section.title or lang.t("METHOD") if obj.is_class else lang.t("FUNCTION")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ function.name }} +
+ {{ function.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja new file mode 100644 index 00000000..fc212db9 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/modules.html.jinja @@ -0,0 +1,69 @@ +{% block logs scoped %} + {{ log.debug("Rendering modules section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Modules:") }}

+ + + + + + + + + {% for module in section.value %} + + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Description") }}
{{ module.name }} +
+ {{ module.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Modules:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for module in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("MODULE")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ module.name }} +
+ {{ module.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja new file mode 100644 index 00000000..c3d4af97 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/other_parameters.html.jinja @@ -0,0 +1,92 @@ +{% block logs scoped %} + {{ log.debug("Rendering other parameters section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Other Parameters:") }}

+ + + + + + + + + + {% for parameter in section.value %} + + + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Type") }}{{ lang.t("Description") }}
{{ parameter.name }} + {% if parameter.annotation %} + {% with expression = parameter.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ parameter.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Other Parameters:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for parameter in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ parameter.name }} +
+ {{ parameter.description|convert_markdown(heading_level, html_id) }} +
+

+ {% if parameter.annotation %} + + {{ lang.t("TYPE:") }} + {% with expression = parameter.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} +

+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja new file mode 100644 index 00000000..f411e114 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/parameters.html.jinja @@ -0,0 +1,115 @@ +{% block logs scoped %} + {{ log.debug("Rendering parameters section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Parameters:") }}

+ + + + + + + + + + + {% for parameter in section.value %} + + + + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Type") }}{{ lang.t("Description") }}{{ lang.t("Default") }}
{{ parameter.name }} + {% if parameter.annotation %} + {% with expression = parameter.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ parameter.description|convert_markdown(heading_level, html_id) }} +
+
+ {% if parameter.default %} + {% with expression = parameter.default %} + {% include "expression"|get_template with context %} + {% endwith %} + {% else %} + {{ lang.t("required") }} + {% endif %} +
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Parameters:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for parameter in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("PARAMETER")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
{{ parameter.name }} +
+ {{ parameter.description|convert_markdown(heading_level, html_id) }} +
+

+ {% if parameter.annotation %} + + {{ lang.t("TYPE:") }} + {% with expression = parameter.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} + {% if parameter.default %} + + {{ lang.t("DEFAULT:") }} + {% with expression = parameter.default %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} +

+
+ {% endblock spacy_style %} +{% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja new file mode 100644 index 00000000..12ff1496 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/raises.html.jinja @@ -0,0 +1,85 @@ +{% block logs scoped %} + {{ log.debug("Rendering raises section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Raises:") }}

+ + + + + + + + + {% for raises in section.value %} + + + + + {% endfor %} + +
{{ lang.t("Type") }}{{ lang.t("Description") }}
+ {% if raises.annotation %} + {% with expression = raises.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ raises.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ lang.t(section.title) or lang.t("Raises:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for raises in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("RAISES")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
+ + {% with expression = raises.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + +
+ {{ raises.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/receives.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/receives.html.jinja new file mode 100644 index 00000000..13e0ea30 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/receives.html.jinja @@ -0,0 +1,105 @@ +{% block logs scoped %} + {{ log.debug("Rendering receives section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} + {% set name_column = section.value|selectattr("name")|any %} +

{{ section.title or lang.t("Receives:") }}

+ + + + {% if name_column %}{% endif %} + + + + + + {% for receives in section.value %} + + {% if name_column %}{% endif %} + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Type") }}{{ lang.t("Description") }}
{% if receives.name %}{{ receives.name }}{% endif %} + {% if receives.annotation %} + {% with expression = receives.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ receives.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Receives:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for receives in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("RECEIVES")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
+ {% if receives.name %} + {{ receives.name }} + {% elif receives.annotation %} + + {% with expression = receives.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} + +
+ {{ receives.description|convert_markdown(heading_level, html_id) }} +
+ {% if receives.name and receives.annotation %} +

+ + {{ lang.t("TYPE:") }} + {% with expression = receives.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + +

+ {% endif %} +
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja new file mode 100644 index 00000000..9a330780 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/returns.html.jinja @@ -0,0 +1,105 @@ +{% block logs scoped %} + {{ log.debug("Rendering returns section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} + {% set name_column = section.value|selectattr("name")|any %} +

{{ section.title or lang.t("Returns:") }}

+ + + + {% if name_column %}{% endif %} + + + + + + {% for returns in section.value %} + + {% if name_column %}{% endif %} + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Type") }}{{ lang.t("Description") }}
{% if returns.name %}{{ returns.name }}{% endif %} + {% if returns.annotation %} + {% with expression = returns.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ returns.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Returns:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for returns in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("RETURNS")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION").upper() }}
+ {% if returns.name %} + {{ returns.name }} + {% elif returns.annotation %} + + {% with expression = returns.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} + +
+ {{ returns.description|convert_markdown(heading_level, html_id) }} +
+ {% if returns.name and returns.annotation %} +

+ + {{ lang.t("TYPE:") }} + {% with expression = returns.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + +

+ {% endif %} +
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/warns.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/warns.html.jinja new file mode 100644 index 00000000..b8ed3851 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/warns.html.jinja @@ -0,0 +1,85 @@ +{% block logs scoped %} + {{ log.debug("Rendering warns section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} +

{{ section.title or lang.t("Warns:") }}

+ + + + + + + + + {% for warns in section.value %} + + + + + {% endfor %} + +
{{ lang.t("Type") }}{{ lang.t("Description") }}
+ {% if warns.annotation %} + {% with expression = warns.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ warns.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Warns:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for warns in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("WARNS")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
+ + {% with expression = warns.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + +
+ {{ warns.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html.jinja new file mode 100644 index 00000000..6172a254 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/docstring/yields.html.jinja @@ -0,0 +1,105 @@ +{% block logs scoped %} + {{ log.debug("Rendering yields section") }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +{% if config.docstring_section_style == "table" %} + {% block table_style scoped %} + {% set name_column = section.value|selectattr("name")|any %} +

{{ section.title or lang.t("Yields:") }}

+ + + + {% if name_column %}{% endif %} + + + + + + {% for yields in section.value %} + + {% if name_column %}{% endif %} + + + + {% endfor %} + +
{{ lang.t("Name") }}{{ lang.t("Type") }}{{ lang.t("Description") }}
{% if yields.name %}{{ yields.name }}{% endif %} + {% if yields.annotation %} + {% with expression = yields.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + +
+ {{ yields.description|convert_markdown(heading_level, html_id) }} +
+
+ {% endblock table_style %} +{% elif config.docstring_section_style == "list" %} + {% block list_style scoped %} +

{{ section.title or lang.t("Yields:") }}

+ + {% endblock list_style %} +{% elif config.docstring_section_style == "spacy" %} + {% block spacy_style scoped %} + + + + + + + + + {% for yields in section.value %} + + + + + {% endfor %} + +
{{ (section.title or lang.t("YIELDS")).rstrip(":").upper() }}{{ lang.t("DESCRIPTION") }}
+ {% if yields.name %} + {{ yields.name }} + {% elif yields.annotation %} + + {% with expression = yields.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + + {% endif %} + +
+ {{ yields.description|convert_markdown(heading_level, html_id) }} +
+ {% if yields.name and yields.annotation %} +

+ + {{ lang.t("TYPE:") }}: + {% with expression = yields.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + +

+ {% endif %} +
+ {% endblock spacy_style %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja new file mode 100644 index 00000000..c219f636 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja @@ -0,0 +1,59 @@ +{% block logs scoped %} +{% endblock logs %} + +{%- macro crossref(name, annotation_path) -%} + {%- with full = name.canonical_path -%} + {%- if annotation_path == "brief" -%} + {%- set annotation = name.canonical_name -%} + {%- elif annotation_path == "source" -%} + {%- set annotation = name.name -%} + {%- elif annotation_path == "full" -%} + {%- set annotation = full -%} + {%- endif -%} + {%- for title, path in annotation|split_path(full) -%} + {%- if not signature or config.signature_crossrefs -%} + {%- filter stash_crossref(length=title|length) -%} + {{ title }} + {%- endfilter -%} + {%- else -%} + {{ title }} + {%- endif -%} + {%- if not loop.last -%}.{%- endif -%} + {%- endfor -%} + {%- endwith -%} +{%- endmacro -%} + +{%- macro render(expression, annotations_path) -%} + {%- if expression is string -%} + {%- if signature -%}{{ expression|safe }}{%- else -%}{{ expression }}{%- endif -%} + {%- elif expression.classname == "ExprName" -%} + {{ crossref(expression, annotations_path) }} + {%- elif config.unwrap_annotated and expression.classname == "ExprSubscript" and expression.canonical_path in ("typing.Annotated", "typing_extensions.Annotated") -%} + {{ render(expression.slice.elements[0], annotations_path) }} + {%- elif expression.classname == "ExprAttribute" -%} + {%- if annotations_path == "brief" -%} + {%- if expression.last.is_enum_value -%} + {{ crossref(expression.last.parent, "brief") }}.value + {%- else -%} + {{ render(expression.last, "brief") }} + {%- endif -%} + {%- elif annotations_path == "full" -%} + {{ render(expression.first, "full") }} + {%- for element in expression -%} + {%- if not loop.first -%} + {{ render(element, "brief") }} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {%- for element in expression -%} + {{ render(element, annotations_path) }} + {%- endfor -%} + {%- endif -%} + {%- else -%} + {%- for element in expression -%} + {{ render(element, annotations_path) }} + {%- endfor -%} + {%- endif -%} +{%- endmacro -%} + +{{ render(expression, config.annotations_path) }} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja new file mode 100644 index 00000000..c4d0f1fc --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja @@ -0,0 +1,100 @@ +{% block logs scoped %} + {{ log.debug("Rendering " + function.path) }} +{% endblock logs %} + +{% import "language"|get_template as lang with context %} + +
+ {% with obj = function, html_id = function.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 function_name = function.path if show_full_path else function.name %} + {% set symbol_type = "method" if function.parent.is_class else "function" %} + + {% if not root or config.show_root_heading %} + {% filter heading( + heading_level, + role="function", + id=html_id, + class="doc doc-heading", + toc_label=((' ')|safe if config.show_symbol_type_toc else '') + function.name, + ) %} + + {% block heading scoped %} + {% if config.show_symbol_type_heading %}{% endif %} + {% if config.separate_signature %} + {{ function_name }} + {% else %} + {%+ filter highlight(language="python", inline=True) %} + {{ function_name }}{% include "signature"|get_template with context %} + {% endfilter %} + {% endif %} + {% endblock heading %} + + {% block labels scoped %} + {% with labels = function.labels %} + {% include "labels"|get_template with context %} + {% endwith %} + {% endblock labels %} + + {% endfilter %} + + {% block signature scoped %} + {% if config.separate_signature %} + {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} + {{ function.name }} + {% endfilter %} + {% endif %} + {% endblock signature %} + + {% else %} + + {% if config.show_root_toc_entry %} + {% filter heading( + heading_level, + role="function", + id=html_id, + toc_label=((' ')|safe if config.show_symbol_type_toc else '') + function.name, + hidden=True, + ) %} + {% endfilter %} + {% endif %} + {% set heading_level = heading_level - 1 %} + {% endif %} + +
+ {% block contents scoped %} + {% block docstring scoped %} + {% with docstring_sections = function.docstring.parsed %} + {% include "docstring"|get_template with context %} + {% endwith %} + {% endblock docstring %} + + {% block source scoped %} + {% if config.show_source and function.source %} +
+ {{ lang.t("Source code in") }} + {%- if function.relative_filepath.is_absolute() -%} + {{ function.relative_package_filepath }} + {%- else -%} + {{ function.relative_filepath }} + {%- endif -%} + + {{ function.source|highlight(language="python", linestart=function.lineno, linenums=True) }} +
+ {% endif %} + {% endblock source %} + {% endblock contents %} +
+ + {% endwith %} +
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/labels.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/labels.html.jinja new file mode 100644 index 00000000..bcdc112b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/labels.html.jinja @@ -0,0 +1,10 @@ +{% if config.show_labels and labels %} + {% block logs scoped %} + {{ log.debug("Rendering labels") }} + {% endblock logs %} + + {% for label in labels|sort %} + {{ label }} + {% endfor %} + +{% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja new file mode 100644 index 00000000..dd3fe800 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/language.html.jinja @@ -0,0 +1,12 @@ +{% block logs scoped %} +{% endblock logs %} + +{% set lang_pth = "languages/" ~ locale | get_template %} +{% if lang_pth is existing_template %} + {% import lang_pth as lang %} + {% import "languages/en"|get_template as fallback %} + {% macro t(key) %}{{ lang.t(key) or fallback.t(key) }}{% endmacro %} +{% else %} + {% import "languages/en"|get_template as lang %} + {% macro t(key) %}{{ lang.t(key) }}{% endmacro %} +{% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja new file mode 100644 index 00000000..5a771d30 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja @@ -0,0 +1,39 @@ + +{% block logs scoped %} +{% endblock logs %} +{% macro t(key) %}{{ { + "ATTRIBUTE": "ATTRIBUTE", + "Attributes:": "Attributes:", + "Classes:": "Classes:", + "CLASS": "CLASS", + "DEFAULT:": "DEFAULT:", + "Default": "Default", + "default:": "default:", + "DESCRIPTION": "DESCRIPTION", + "Description": "Description", + "Examples:": "Examples:", + "Functions:": "Functions:", + "FUNCTION": "FUNCTION", + "Methods:": "Methods:", + "METHOD": "METHOD", + "Modules:": "Modules:", + "MODULE": "MODULE", + "Name": "Name", + "Other Parameters:": "Other Parameters:", + "PARAMETER": "PARAMETER", + "Parameters:": "Parameters:", + "RAISES": "RAISES", + "Raises:" : "Raises:", + "RECEIVES": "RECEIVES", + "Receives:": "Receives:", + "required": "required", + "RETURNS": "RETURNS", + "Returns:": "Returns:", + "Source code in": "Source code in", + "TYPE:": "TYPE:", + "Type": "Type", + "WARNS": "WARNS", + "Warns:": "Warns:", + "YIELDS": "YIELDS", + "Yields:": "Yields:", +}[key] }}{% endmacro %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja new file mode 100644 index 00000000..748fd8b7 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja @@ -0,0 +1,39 @@ + +{% block logs scoped %} +{% endblock logs %} +{% macro t(key) %}{{ { + "ATTRIBUTE": "属性", + "Attributes:": "属性:", + "Classes:": "", + "CLASS": "", + "DEFAULT:": "デフォルト:", + "Default": "デフォルト", + "default:": "デフォルト:", + "DESCRIPTION": "デスクリプション", + "Description": "デスクリプション", + "Examples:": "例:", + "Functions:": "", + "FUNCTION": "", + "Methods:": "", + "METHOD": "", + "Modules:": "", + "MODULE": "", + "Name": "名前", + "Other Parameters:": "他の引数:", + "PARAMETER": "引数", + "Parameters:": "引数:", + "RAISES": "発生", + "Raises:" : "発生:", + "RECEIVES": "取得", + "Receives:": "取得:", + "required": "必須", + "RETURNS": "戻り値", + "Returns:": "戻り値:", + "Source code in": "ソースコード位置:", + "TYPE:": "タイプ:", + "Type": "タイプ", + "WARNS": "警告", + "Warns:": "警告:", + "YIELDS": "返す", + "Yields:": "返す:", +}[key] }}{% endmacro %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja new file mode 100644 index 00000000..772e33cd --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja @@ -0,0 +1,39 @@ + +{% block logs scoped %} +{% endblock logs %} +{% macro t(key) %}{{ { + "ATTRIBUTE": "属性", + "Attributes:": "属性:", + "Classes:": "", + "CLASS": "", + "DEFAULT:": "默认:", + "Default": "默认", + "default:": "默认:", + "DESCRIPTION": "描述", + "Description": "描述", + "Examples:": "示例:", + "Functions:": "", + "FUNCTION": "", + "Methods:": "", + "METHOD": "", + "Modules:": "", + "MODULE": "", + "Name": "名称", + "Other Parameters:": "其他参数:", + "PARAMETER": "参数", + "Parameters:": "参数:", + "RAISES": "引发", + "Raises:" : "引发:", + "Receives:": "接收:", + "RECEIVES": "接收", + "required": "必需", + "RETURNS": "返回", + "Returns:": "返回:", + "Source code in": "源代码位于:", + "TYPE:": "类型:", + "Type": "类型", + "Warns:": "警告:", + "WARNS": "警告", + "YIELDS": "产生", + "Yields:": "产生:", +}[key] }}{% endmacro %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja new file mode 100644 index 00000000..02665e20 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/module.html.jinja @@ -0,0 +1,76 @@ +{% block logs scoped %} + {{ log.debug("Rendering " + module.path) }} +{% endblock logs %} + +
+ {% with obj = module, html_id = module.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 module_name = module.path if show_full_path else module.name %} + + {% if not root or config.show_root_heading %} + {% filter heading( + heading_level, + role="module", + id=html_id, + class="doc doc-heading", + toc_label=(' '|safe if config.show_symbol_type_toc else '') + module.name, + ) %} + + {% block heading scoped %} + {% if config.show_symbol_type_heading %}{% endif %} + {% if config.separate_signature %} + {{ module_name }} + {% else %} + {{ module_name }} + {% endif %} + {% endblock heading %} + + {% block labels scoped %} + {% with labels = module.labels %} + {% include "labels"|get_template with context %} + {% endwith %} + {% endblock labels %} + + {% endfilter %} + + {% else %} + {% if config.show_root_toc_entry %} + {% filter heading(heading_level, + role="module", + id=html_id, + toc_label=(' '|safe if config.show_symbol_type_toc else '') + module.name, + hidden=True, + ) %} + {% endfilter %} + {% endif %} + {% set heading_level = heading_level - 1 %} + {% endif %} + +
+ {% block contents scoped %} + {% block docstring scoped %} + {% with docstring_sections = module.docstring.parsed %} + {% include "docstring"|get_template with context %} + {% endwith %} + {% endblock docstring %} + + {% block children scoped %} + {% set root = False %} + {% set heading_level = heading_level + 1 %} + {% include "children"|get_template with context %} + {% endblock children %} + {% endblock contents %} +
+ + {% endwith %} +
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html.jinja new file mode 100644 index 00000000..d5bd4220 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html.jinja @@ -0,0 +1,70 @@ +{%- if config.show_signature -%} + {% block logs scoped %} + {{ log.debug("Rendering signature") }} + {% endblock logs %} + {%- with -%} + + {%- set ns = namespace( + has_pos_only=False, + render_pos_only_separator=True, + render_kw_only_separator=True, + annotation="", + equal="=", + ) -%} + + ( + {%- for parameter in function.parameters -%} + {%- if parameter.name not in ("self", "cls") or loop.index0 > 0 or not (function.parent and function.parent.is_class) -%} + + {%- if parameter.kind.value == "positional-only" -%} + {%- set ns.has_pos_only = True -%} + {%- else -%} + {%- if ns.has_pos_only and ns.render_pos_only_separator -%} + {%- set ns.render_pos_only_separator = False %}/, {% endif -%} + {%- if parameter.kind.value == "keyword-only" -%} + {%- if ns.render_kw_only_separator -%} + {%- set ns.render_kw_only_separator = False %}*, {% endif -%} + {%- endif -%} + {%- endif -%} + + {%- if config.show_signature_annotations and parameter.annotation is not none -%} + {%- set ns.equal = " = " -%} + {%- if config.separate_signature and config.signature_crossrefs -%} + {%- with expression = parameter.annotation -%} + {%- set ns.annotation -%}: {% include "expression"|get_template with context %}{%- endset -%} + {%- endwith -%} + {%- else -%} + {%- set ns.annotation = ": " + parameter.annotation|safe -%} + {%- endif -%} + {%- else -%} + {%- set ns.equal = "=" -%} + {%- set ns.annotation = "" -%} + {%- endif -%} + + {%- if parameter.default is not none and parameter.kind.value != "variadic positional" and parameter.kind.value != "variadic keyword" -%} + {%- set default = ns.equal + parameter.default|safe -%} + {%- endif -%} + + {%- if parameter.kind.value == "variadic positional" -%} + {%- set ns.render_kw_only_separator = False -%} + {%- endif -%} + + {% if parameter.kind.value == "variadic positional" %}*{% elif parameter.kind.value == "variadic keyword" %}**{% endif -%} + {{ parameter.name }}{{ ns.annotation }}{{ default }} + {%- if not loop.last %}, {% endif -%} + + {%- endif -%} + {%- endfor -%} + ) + {%- if config.show_signature_annotations + and function.annotation + and not (config.merge_init_into_class and function.name == "__init__" ) + %} -> {% if config.separate_signature and config.signature_crossrefs -%} + {%- with expression = function.annotation %}{% include "expression"|get_template with context %}{%- endwith -%} + {%- else -%} + {{ function.annotation|safe }} + {%- endif -%} + {%- endif -%} + + {%- endwith -%} +{%- endif -%} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja new file mode 100644 index 00000000..a9aba29b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary.html.jinja @@ -0,0 +1,2 @@ +{% block logs scoped %} +{% endblock logs %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary/attributes.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary/attributes.html.jinja new file mode 100644 index 00000000..a9aba29b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/attributes.html.jinja @@ -0,0 +1,2 @@ +{% block logs scoped %} +{% endblock logs %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary/classes.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary/classes.html.jinja new file mode 100644 index 00000000..a9aba29b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/classes.html.jinja @@ -0,0 +1,2 @@ +{% block logs scoped %} +{% endblock logs %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary/functions.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary/functions.html.jinja new file mode 100644 index 00000000..a9aba29b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/functions.html.jinja @@ -0,0 +1,2 @@ +{% block logs scoped %} +{% endblock logs %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/summary/modules.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/summary/modules.html.jinja new file mode 100644 index 00000000..a9aba29b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/material/_base/summary/modules.html.jinja @@ -0,0 +1,2 @@ +{% block logs scoped %} +{% endblock logs %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/attributes.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/attributes.html.jinja new file mode 100644 index 00000000..c3586f6a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/attributes.html.jinja @@ -0,0 +1,35 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Attributes:") }} +
    + {% for attribute in section.value %} +
  • + {{ attribute.name }} + {% if attribute.annotation %} + {% with expression = attribute.annotation %} + ({% include "expression"|get_template with context %}) + {% endwith %} + {% endif %} + – +
    + {{ attribute.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/other_parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/other_parameters.html.jinja new file mode 100644 index 00000000..339a0cee --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/other_parameters.html.jinja @@ -0,0 +1,35 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Other parameters:") }} +
    + {% for parameter in section.value %} +
  • + {{ parameter.name }} + {% if parameter.annotation %} + {% with expression = parameter.annotation %} + ({% include "expression"|get_template with context %}) + {% endwith %} + {% endif %} + – +
    + {{ parameter.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/parameters.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/parameters.html.jinja new file mode 100644 index 00000000..ad69e78a --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/parameters.html.jinja @@ -0,0 +1,40 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Parameters:") }} +
    + {% for parameter in section.value %} +
  • + {{ parameter.name }} + {% if parameter.annotation %} + {% with expression = parameter.annotation %} + ({% include "expression"|get_template with context %} + {%- if parameter.default %}, {{ lang.t("default:") }} + {% with expression = parameter.default %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %}) + {% endwith %} + {% endif %} + – +
    + {{ parameter.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/raises.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/raises.html.jinja new file mode 100644 index 00000000..ae7f38dc --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/raises.html.jinja @@ -0,0 +1,34 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Raises:") }} +
    + {% for raises in section.value %} +
  • + {% if raises.annotation %} + {% with expression = raises.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + – +
    + {{ raises.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/receives.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/receives.html.jinja new file mode 100644 index 00000000..a37db154 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/receives.html.jinja @@ -0,0 +1,37 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Receives:") }} +
    + {% for receives in section.value %} +
  • + {% if receives.name %}{{ receives.name }}{% endif %} + {% if receives.annotation %} + {% with expression = receives.annotation %} + {% if receives.name %}({% endif %} + {% include "expression"|get_template with context %} + {% if receives.name %}){% endif %} + {% endwith %} + {% endif %} + – +
    + {{ receives.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/returns.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/returns.html.jinja new file mode 100644 index 00000000..8f7dbd9b --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/returns.html.jinja @@ -0,0 +1,37 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Returns:") }} +
    + {% for returns in section.value %} +
  • + {% if returns.name %}{{ returns.name }}{% endif %} + {% if returns.annotation %} + {% with expression = returns.annotation %} + {% if returns.name %}({% endif %} + {% include "expression"|get_template with context %} + {% if returns.name %}){% endif %} + {% endwith %} + {% endif %} + – +
    + {{ returns.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/warns.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/warns.html.jinja new file mode 100644 index 00000000..8ae5eb17 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/warns.html.jinja @@ -0,0 +1,34 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Warns:") }} +
    + {% for warns in section.value %} +
  • + {% if warns.annotation %} + {% with expression = warns.annotation %} + {% include "expression"|get_template with context %} + {% endwith %} + {% endif %} + – +
    + {{ warns.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/yields.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/yields.html.jinja new file mode 100644 index 00000000..44670856 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/docstring/yields.html.jinja @@ -0,0 +1,37 @@ +{% block logs scoped %} + {{ log.debug() }} +{% endblock %} + +{% import "language"|get_template as lang with context %} + + + + + + + + + + + + +
{{ section.title or lang.t("Yields:") }} +
    + {% for yields in section.value %} +
  • + {% if yields.name %}{{ yields.name }}{% endif %} + {% if yields.annotation %} + {% with expression = yields.annotation %} + {% if yields.name %}({% endif %} + {% include "expression"|get_template with context %} + {% if yields.name %}){% endif %} + {% endwith %} + {% endif %} + – +
    + {{ yields.description|convert_markdown(heading_level, html_id) }} +
    +
  • + {% endfor %} +
+
diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/language.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/language.html.jinja new file mode 100644 index 00000000..9c03b815 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/language.html.jinja @@ -0,0 +1,12 @@ +{% block logs scoped %} +{% endblock logs %} + +{% set lang_pth = "languages/" ~ locale | get_template %} +{% if lang_pth is existing_template %} + {% import lang_pth as lang %} + {% import "languages/en"|get_template as fallback %} + {% macro t(key) %}{{ lang.t(key) or fallback.t(key) }}{% endmacro %} +{% else %} + {% import "languages/en"|get_template as lang %} + {% macro t(key) %}{{ lang.t(key) }}{% endmacro %} +{% endif %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/en.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/en.html.jinja new file mode 100644 index 00000000..5a771d30 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/en.html.jinja @@ -0,0 +1,39 @@ + +{% block logs scoped %} +{% endblock logs %} +{% macro t(key) %}{{ { + "ATTRIBUTE": "ATTRIBUTE", + "Attributes:": "Attributes:", + "Classes:": "Classes:", + "CLASS": "CLASS", + "DEFAULT:": "DEFAULT:", + "Default": "Default", + "default:": "default:", + "DESCRIPTION": "DESCRIPTION", + "Description": "Description", + "Examples:": "Examples:", + "Functions:": "Functions:", + "FUNCTION": "FUNCTION", + "Methods:": "Methods:", + "METHOD": "METHOD", + "Modules:": "Modules:", + "MODULE": "MODULE", + "Name": "Name", + "Other Parameters:": "Other Parameters:", + "PARAMETER": "PARAMETER", + "Parameters:": "Parameters:", + "RAISES": "RAISES", + "Raises:" : "Raises:", + "RECEIVES": "RECEIVES", + "Receives:": "Receives:", + "required": "required", + "RETURNS": "RETURNS", + "Returns:": "Returns:", + "Source code in": "Source code in", + "TYPE:": "TYPE:", + "Type": "Type", + "WARNS": "WARNS", + "Warns:": "Warns:", + "YIELDS": "YIELDS", + "Yields:": "Yields:", +}[key] }}{% endmacro %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/ja.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/ja.html.jinja new file mode 100644 index 00000000..748fd8b7 --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/ja.html.jinja @@ -0,0 +1,39 @@ + +{% block logs scoped %} +{% endblock logs %} +{% macro t(key) %}{{ { + "ATTRIBUTE": "属性", + "Attributes:": "属性:", + "Classes:": "", + "CLASS": "", + "DEFAULT:": "デフォルト:", + "Default": "デフォルト", + "default:": "デフォルト:", + "DESCRIPTION": "デスクリプション", + "Description": "デスクリプション", + "Examples:": "例:", + "Functions:": "", + "FUNCTION": "", + "Methods:": "", + "METHOD": "", + "Modules:": "", + "MODULE": "", + "Name": "名前", + "Other Parameters:": "他の引数:", + "PARAMETER": "引数", + "Parameters:": "引数:", + "RAISES": "発生", + "Raises:" : "発生:", + "RECEIVES": "取得", + "Receives:": "取得:", + "required": "必須", + "RETURNS": "戻り値", + "Returns:": "戻り値:", + "Source code in": "ソースコード位置:", + "TYPE:": "タイプ:", + "Type": "タイプ", + "WARNS": "警告", + "Warns:": "警告:", + "YIELDS": "返す", + "Yields:": "返す:", +}[key] }}{% endmacro %} \ No newline at end of file diff --git a/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/zh.html.jinja b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/zh.html.jinja new file mode 100644 index 00000000..772e33cd --- /dev/null +++ b/src/mkdocstrings_handlers/python/templates/readthedocs/_base/languages/zh.html.jinja @@ -0,0 +1,39 @@ + +{% block logs scoped %} +{% endblock logs %} +{% macro t(key) %}{{ { + "ATTRIBUTE": "属性", + "Attributes:": "属性:", + "Classes:": "", + "CLASS": "", + "DEFAULT:": "默认:", + "Default": "默认", + "default:": "默认:", + "DESCRIPTION": "描述", + "Description": "描述", + "Examples:": "示例:", + "Functions:": "", + "FUNCTION": "", + "Methods:": "", + "METHOD": "", + "Modules:": "", + "MODULE": "", + "Name": "名称", + "Other Parameters:": "其他参数:", + "PARAMETER": "参数", + "Parameters:": "参数:", + "RAISES": "引发", + "Raises:" : "引发:", + "Receives:": "接收:", + "RECEIVES": "接收", + "required": "必需", + "RETURNS": "返回", + "Returns:": "返回:", + "Source code in": "源代码位于:", + "TYPE:": "类型:", + "Type": "类型", + "Warns:": "警告:", + "WARNS": "警告", + "YIELDS": "产生", + "Yields:": "产生:", +}[key] }}{% endmacro %} \ No newline at end of file