chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:05:14 +08:00
commit 2a547be7fe
7904 changed files with 1000926 additions and 0 deletions
+126
View File
@@ -0,0 +1,126 @@
{# Very minimally patched from:
https://github.com/mkdocstrings/python/blob/b0123719ae90cb2d47e9b923166ac69fdce86632/src/mkdocstrings_handlers/python/templates/material/_base/class.html
See: CHANGE comments below
#}
{{ log.debug("Rendering " + class.path) }}
<div class="doc doc-object doc-class">
{% with 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 %}
{% if not root or config.show_root_heading %}
{% filter heading(heading_level,
role="class",
id=html_id,
class="doc doc-heading",
toc_label=class.name) %}
{% if config.separate_signature %}
<span class="doc doc-object-name doc-class-name">{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}</span>
{% elif config.merge_init_into_class and "__init__" in class.members -%}
{%- with function = class.members["__init__"] -%}
{%- filter highlight(language="python", inline=True) -%}
{# CHANGE: Insert class before class for better highlighting #}
class {% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
{%- include "signature.html" with context -%}
{%- endfilter -%}
{%- endwith -%}
{% else %}
{# CHANGE: Insert class before class for better highlighting #}
{%- filter highlight(language="python", inline=True) -%}
class {% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
{%- endfilter -%}
{% endif %}
{% with labels = class.labels %}
{% include "labels.html" with context %}
{% endwith %}
{% endfilter %}
{% if config.separate_signature and config.merge_init_into_class %}
{% if "__init__" in class.members %}
{% with function = class.members["__init__"] %}
{% filter highlight(language="python", inline=False) %}
{% filter format_signature(config.line_length) %}
{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
{% include "signature.html" with context %}
{% endfilter %}
{% endfilter %}
{% endwith %}
{% endif %}
{% endif %}
{% else %}
{% if config.show_root_toc_entry %}
{% filter heading(heading_level,
role="class",
id=html_id,
toc_label=class.path if config.show_root_full_path else class.name,
hidden=True) %}
{% endfilter %}
{% endif %}
{% set heading_level = heading_level - 1 %}
{% endif %}
{# CHANGE Relative to Upstream: don't apply the 'first' class since it causes worse CSS formatting for our #}
{# generated common API index since we inline bare functions that become root-level rather than modules. #}
{#<div class="doc doc-contents {% if root %}first{% endif %}">#}
<div class="doc doc-contents">
{% if config.show_bases and class.bases %}
<p class="doc doc-class-bases">
Bases: {% for expression in class.bases -%}
<code>{% include "expression.html" with context %}</code>{% if not loop.last %}, {% endif %}
{% endfor -%}
</p>
{% endif %}
{% with docstring_sections = class.docstring.parsed %}
{% include "docstring.html" with context %}
{% endwith %}
{% if config.merge_init_into_class %}
{% if "__init__" in class.members and class.members["__init__"].has_docstring %}
{% with docstring_sections = class.members["__init__"].docstring.parsed %}
{% include "docstring.html" with context %}
{% endwith %}
{% endif %}
{% endif %}
{% if config.show_source %}
{% if config.merge_init_into_class %}
{% if "__init__" in class.members and class.members["__init__"].source %}
<details class="quote">
<summary>Source code in <code>{{ class.relative_filepath }}</code></summary>
{{ class.members["__init__"].source|highlight(language="python", linestart=class.members["__init__"].lineno, linenums=True) }}
</details>
{% endif %}
{% elif class.source %}
<details class="quote">
<summary>Source code in <code>{{ class.relative_filepath }}</code></summary>
{{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }}
</details>
{% endif %}
{% endif %}
{% with obj = class %}
{% set root = False %}
{% set heading_level = heading_level + 1 %}
{% include "children.html" with context %}
{% endwith %}
</div>
{% endwith %}
</div>
@@ -0,0 +1,142 @@
{#- Minimally patched from upstream mkdocstrings-python:
material/_base/function.html.jinja
Our deviations from upstream are marked with `CHANGE relative to upstream`
comments below:
- prefix each signature (and overload) with a `def ` keyword
- drop the `first` CSS class (better formatting for the common API index)
Re-derive from the installed upstream template when bumping mkdocstrings,
re-applying those changes.
-#}
{% block logs scoped %}
{{ log.debug("Rendering " + function.path) }}
{% endblock logs %}
{% import "language"|get_template as lang with context %}
<div class="doc doc-object doc-function">
{% 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=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else function.name),
) %}
{% block heading scoped %}
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-{{ symbol_type }}"></code>{% endif %}
{% if config.heading and root %}
{{ config.heading }}
{% elif config.separate_signature %}
<span class="doc doc-object-name doc-function-name">{{ function_name }}</span>
{% 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 function.overloads and config.show_overloads %}
{# CHANGE relative to upstream: prefix each signature with a `def ` keyword. #}
{# `format_signature` deliberately omits it, but we prefer the fuller form. #}
{# It always emits the function name as the first `nf` span, so inject before that. #}
<div class="doc-overloads">
{% for overload in function.overloads %}
{% set rendered_overload %}
{% filter format_signature(overload, config.line_length, annotations=True, crossrefs=config.signature_crossrefs) %}
{{ overload.name }}
{% endfilter %}
{% endset %}
{% autoescape false %}
{{ rendered_overload | replace('<span class="nf">', '<span class="k">def </span><span class="nf">', 1) }}
{% endautoescape %}
{% endfor %}
</div>
{% endif %}
{% if config.separate_signature %}
{% set rendered_signature %}
{% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %}
{{ function_name }}
{% endfilter %}
{% endset %}
{% autoescape false %}
{{ rendered_signature | replace('<span class="nf">', '<span class="k">def </span><span class="nf">', 1) }}
{% endautoescape %}
{% endif %}
{% endblock signature %}
{% else %}
{% if config.show_root_toc_entry %}
{% filter heading(
heading_level,
role="function",
id=html_id,
toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + (config.toc_label if config.toc_label and root else function.name),
hidden=True,
) %}
{% endfilter %}
{% endif %}
{% set heading_level = heading_level - 1 %}
{% endif %}
{# CHANGE relative to upstream: don't apply the 'first' class. It causes worse CSS #}
{# formatting for our generated common API index, since we inline bare functions #}
{# that become root-level rather than modules. #}
<div class="doc doc-contents">
{% block contents scoped %}
{% block docstring scoped %}
{% with docstring_sections = function.docstring.parsed %}
{% include "docstring"|get_template with context %}
{% endwith %}
{% endblock docstring %}
{% if config.backlinks %}
<backlinks identifier="{{ html_id }}" handler="python" />
{% endif %}
{% block source scoped %}
{% if config.show_source and function.source %}
<details class="quote">
<summary>{{ lang.t("Source code in") }} <code>
{%- if function.relative_filepath.is_absolute() -%}
{{ function.relative_package_filepath }}
{%- else -%}
{{ function.relative_filepath }}
{%- endif -%}
</code></summary>
{{ function.source|highlight(language="python", linestart=function.lineno or 0, linenums=True) }}
</details>
{% endif %}
{% endblock source %}
{% endblock contents %}
</div>
{% endwith %}
</div>