Skip to content

Commit

Permalink
fixup! docs: Document Jinja templates
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Apr 28, 2024
1 parent 6df2dcc commit 1ff3ac0
Show file tree
Hide file tree
Showing 20 changed files with 131 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<p><span class="doc-section-title">{{ section.title or lang.t("Examples:") }}</span></p>
{% for section_type, sub_section in section.value %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Context:
{% endblock logs %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
{% block table_style scoped %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Attributes" sections in docstrings.
This template renders a list of documented attributes in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Other parameters" sections in docstrings.
This template renders a list of documented other parameters in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Parameters" sections in docstrings.
This template renders a list of documented parameters in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Raises" sections in docstrings.
This template renders a list of documented exceptions in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Receives" sections in docstrings.
This template renders a list of documented received values (generators) in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Returns" sections in docstrings.
This template renders a list of documented returned values in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Warns" sections in docstrings.
This template renders a list of documented warnings in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{#- Template for "Yields" sections in docstrings.
This template renders a list of documented yielded values (generators) in the format
specified with the [`docstring_section_style`][] configuration option.
Context:
section (griffe.docstrings.dataclasses.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug() }}
{% endblock %}

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

<table class="field-list">
<colgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{#- Import translation macros for the given language and fallback language. -#}

{% block logs scoped %}
{#- Logging block.
This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{% endblock logs %}
<!-- Import translations for given language and fallback -->

{% set lang_pth = "languages/" ~ locale | get_template %}
{% if lang_pth is existing_template %}
{% import lang_pth as lang %}
Expand All @@ -9,4 +15,4 @@
{% else %}
{% import "languages/en"|get_template as lang %}
{% macro t(key) %}{{ lang.t(key) }}{% endmacro %}
{% endif %}
{% endif %}

0 comments on commit 1ff3ac0

Please sign in to comment.