8000 docs: Document Jinja templates by pawamoy · Pull Request #156 · mkdocstrings/python · GitHub
[go: up one dir, main page]

Skip to content

docs: Document Jinja templates #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! docs: Document Jinja templates
  • Loading branch information
pawamoy committed Apr 28, 2024
commit d57ad294d4c863a6477cf3c1bb2c22ca24ee8d81
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Context:
-#}

{%- if config.show_signature -%}
{% block logs scoped %}
{%- block logs scoped -%}
{#- Logging block.

This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug("Rendering signature") }}
{% endblock logs %}
{%- endblock logs -%}
{%- with -%}

{%- set ns = namespace(
Expand All @@ -31,6 +31,7 @@ Context:
{%- 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) -%}

{#- Handle parameter kind. -#}
{%- if parameter.kind.value == "positional-only" -%}
{%- set ns.has_pos_only = True -%}
{%- else -%}
Expand All @@ -42,6 +43,7 @@ Context:
{%- endif -%}
{%- endif -%}

{#- Prepare type annotation. -#}
{%- if config.show_signature_annotations and parameter.annotation is not none -%}
{%- set ns.equal = " = " -%}
{%- if config.separate_signature and config.signature_crossrefs -%}
Expand All @@ -56,21 +58,26 @@ Context:
{%- set ns.annotation = "" -%}
{%- endif -%}

{#- Prepare default value. -#}
{%- 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 -%}

{#- TODO: Move inside kind handling above? -#}
{%- if parameter.kind.value == "variadic positional" -%}
{%- set ns.render_kw_only_separator = False -%}
{%- endif -%}

{#- Render name, annotation and default. -#}
{% 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 -%}
)

{#- Render return type. -#}
{%- if config.show_signature_annotations
and function.annotation
and not (config.merge_init_into_class and function.name == "__init__" )
Expand Down
0