Skip to content

Commit eced9a5

Browse files
committed
refactor: Add *.html.jinja base templates, which are copies of *.html templates, with an additional logs block, and using the updated get_template filter
Issue-151: #151
1 parent 3546fd7 commit eced9a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2308
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{% block logs scoped %}
2+
{{ log.debug("Rendering " + attribute.path) }}
3+
{% endblock logs %}
4+
5+
<div class="doc doc-object doc-attribute">
6+
{% with obj = attribute, html_id = attribute.path %}
7+
8+
{% if root %}
9+
{% set show_full_path = config.show_root_full_path %}
10+
{% set root_members = True %}
11+
{% elif root_members %}
12+
{% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %}
13+
{% set root_members = False %}
14+
{% else %}
15+
{% set show_full_path = config.show_object_full_path %}
16+
{% endif %}
17+
18+
{% set attribute_name = attribute.path if show_full_path else attribute.name %}
19+
20+
{% if not root or config.show_root_heading %}
21+
{% filter heading(
22+
heading_level,
23+
role="data" if attribute.parent.kind.value == "module" else "attr",
24+
id=html_id,
25+
class="doc doc-heading",
26+
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + attribute.name,
27+
) %}
28+
29+
{% block heading scoped %}
30+
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-attribute"></code>{% endif %}
31+
{% if config.separate_signature %}
32+
<span class="doc doc-object-name doc-attribute-name">{{ attribute_name }}</span>
33+
{% else %}
34+
{%+ filter highlight(language="python", inline=True) %}
35+
{{ attribute_name }}{% if attribute.annotation %}: {{ attribute.annotation }}{% endif %}
36+
{% if attribute.value %} = {{ attribute.value }}{% endif %}
37+
{% endfilter %}
38+
{% endif %}
39+
{% endblock heading %}
40+
41+
{% block labels scoped %}
42+
{% with labels = attribute.labels %}
43+
{% include "labels"|get_template with context %}
44+
{% endwith %}
45+
{% endblock labels %}
46+
47+
{% endfilter %}
48+
49+
{% block signature scoped %}
50+
{% if config.separate_signature %}
51+
{% filter format_attribute(attribute, config.line_length, crossrefs=config.signature_crossrefs) %}
52+
{{ attribute.name }}
53+
{% endfilter %}
54+
{% endif %}
55+
{% endblock signature %}
56+
57+
{% else %}
58+
59+
{% if config.show_root_toc_entry %}
60+
{% filter heading(heading_level,
61+
role="data" if attribute.parent.kind.value == "module" else "attr",
62+
id=html_id,
63+
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-attribute"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + attribute.name,
64+
hidden=True,
65+
) %}
66+
{% endfilter %}
67+
{% endif %}
68+
{% set heading_level = heading_level - 1 %}
69+
{% endif %}
70+
71+
<div class="doc doc-contents {% if root %}first{% endif %}">
72+
{% block contents scoped %}
73+
{% block docstring scoped %}
74+
{% with docstring_sections = attribute.docstring.parsed %}
75+
{% include "docstring"|get_template with context %}
76+
{% endwith %}
77+
{% endblock docstring %}
78+
{% endblock contents %}
79+
</div>
80+
81+
{% endwith %}
82+
</div>
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{% if obj.members %}
2+
{% block logs scoped %}
3+
{{ log.debug("Rendering children of " + obj.path) }}
4+
{% endblock logs %}
5+
6+
<div class="doc doc-children">
7+
8+
{% if root_members %}
9+
{% set members_list = config.members %}
10+
{% else %}
11+
{% set members_list = none %}
12+
{% endif %}
13+
14+
{% if config.group_by_category %}
15+
16+
{% with %}
17+
18+
{% if config.show_category_heading %}
19+
{% set extra_level = 1 %}
20+
{% else %}
21+
{% set extra_level = 0 %}
22+
{% endif %}
23+
24+
{% with attributes = obj.attributes|filter_objects(
25+
filters=config.filters,
26+
members_list=members_list,
27+
inherited_members=config.inherited_members,
28+
keep_no_docstrings=config.show_if_no_docstring,
29+
) %}
30+
{% if attributes %}
31+
{% if config.show_category_heading %}
32+
{% filter heading(heading_level, id=html_id ~ "-attributes") %}Attributes{% endfilter %}
33+
{% endif %}
34+
{% with heading_level = heading_level + extra_level %}
35+
{% for attribute in attributes|order_members(config.members_order, members_list) %}
36+
{% if members_list is not none or attribute.is_public(check_name=False) %}
37+
{% include attribute|get_template with context %}
38+
{% endif %}
39+
{% endfor %}
40+
{% endwith %}
41+
{% endif %}
42+
{% endwith %}
43+
44+
{% with classes = obj.classes|filter_objects(
45+
filters=config.filters,
46+
members_list=members_list,
47+
inherited_members=config.inherited_members,
48+
keep_no_docstrings=config.show_if_no_docstring,
49+
) %}
50+
{% if classes %}
51+
{% if config.show_category_heading %}
52+
{% filter heading(heading_level, id=html_id ~ "-classes") %}Classes{% endfilter %}
53+
{% endif %}
54+
{% with heading_level = heading_level + extra_level %}
55+
{% for class in classes|order_members(config.members_order, members_list) %}
56+
{% if members_list is not none or class.is_public(check_name=False) %}
57+
{% include class|get_template with context %}
58+
{% endif %}
59+
{% endfor %}
60+
{% endwith %}
61+
{% endif %}
62+
{% endwith %}
63+
64+
{% with functions = obj.functions|filter_objects(
65+
filters=config.filters,
66+
members_list=members_list,
67+
inherited_members=config.inherited_members,
68+
keep_no_docstrings=config.show_if_no_docstring,
69+
) %}
70+
{% if functions %}
71+
{% if config.show_category_heading %}
72+
{% filter heading(heading_level, id=html_id ~ "-functions") %}Functions{% endfilter %}
73+
{% endif %}
74+
{% with heading_level = heading_level + extra_level %}
75+
{% for function in functions|order_members(config.members_order, members_list) %}
76+
{% if not (obj.kind.value == "class" and function.name == "__init__" and config.merge_init_into_class) %}
77+
{% if members_list is not none or function.is_public(check_name=False) %}
78+
{% include function|get_template with context %}
79+
{% endif %}
80+
{% endif %}
81+
{% endfor %}
82+
{% endwith %}
83+
{% endif %}
84+
{% endwith %}
85+
86+
{% if config.show_submodules %}
87+
{% with modules = obj.modules|filter_objects(
88+
filters=config.filters,
89+
members_list=members_list,
90+
inherited_members=config.inherited_members,
91+
keep_no_docstrings=config.show_if_no_docstring,
92+
) %}
93+
{% if modules %}
94+
{% if config.show_category_heading %}
95+
{% filter heading(heading_level, id=html_id ~ "-modules") %}Modules{% endfilter %}
96+
{% endif %}
97+
{% with heading_level = heading_level + extra_level %}
98+
{% for module in modules|order_members(config.members_order.alphabetical, members_list) %}
99+
{% if members_list is not none or module.is_public(check_name=False) %}
100+
{% include module|get_template with context %}
101+
{% endif %}
102+
{% endfor %}
103+
{% endwith %}
104+
{% endif %}
105+
{% endwith %}
106+
{% endif %}
107+
108+
{% endwith %}
109+
110+
{% else %}
111+
112+
{% for child in obj.all_members
113+
|filter_objects(
114+
filters=config.filters,
115+
members_list=members_list,
116+
inherited_members=config.inherited_members,
117+
keep_no_docstrings=config.show_if_no_docstring,
118+
)
119+
|order_members(config.members_order, members_list)
120+
%}
121+
122+
{% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %}
123+
124+
{% if members_list is not none or child.is_public(check_name=False) %}
125+
{% if child.is_attribute %}
126+
{% with attribute = child %}
127+
{% include attribute|get_template with context %}
128+
{% endwith %}
129+
130+
{% elif child.is_class %}
131+
{% with class = child %}
132+
{% include class|get_template with context %}
133+
{% endwith %}
134+
135+
{% elif child.is_function %}
136+
{% with function = child %}
137+
{% include function|get_template with context %}
138+
{% endwith %}
139+
140+
{% elif child.is_module and config.show_submodules %}
141+
{% with module = child %}
142+
{% include module|get_template with context %}
143+
{% endwith %}
144+
145+
{% endif %}
146+
{% endif %}
147+
148+
{% endif %}
149+
150+
{% endfor %}
151+
152+
{% endif %}
153+
154+
</div>
155+
156+
{% endif %}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{% block logs scoped %}
2+
{{ log.debug("Rendering " + class.path) }}
3+
{% endblock logs %}
4+
5+
<div class="doc doc-object doc-class">
6+
{% with obj = class, html_id = class.path %}
7+
8+
{% if root %}
9+
{% set show_full_path = config.show_root_full_path %}
10+
{% set root_members = True %}
11+
{% elif root_members %}
12+
{% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %}
13+
{% set root_members = False %}
14+
{% else %}
15+
{% set show_full_path = config.show_object_full_path %}
16+
{% endif %}
17+
18+
{% set class_name = class.path if show_full_path else class.name %}
19+
20+
{% if not root or config.show_root_heading %}
21+
{% filter heading(
22+
heading_level,
23+
role="class",
24+
id=html_id,
25+
class="doc doc-heading",
26+
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + class.name,
27+
) %}
28+
29+
{% block heading scoped %}
30+
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code>{% endif %}
31+
{% if config.separate_signature %}
32+
<span class="doc doc-object-name doc-class-name">{{ class_name }}</span>
33+
{% elif config.merge_init_into_class and "__init__" in class.all_members %}
34+
{% with function = class.all_members["__init__"] %}
35+
{%+ filter highlight(language="python", inline=True) %}
36+
{{ class_name }}{% include "signature"|get_template with context %}
37+
{% endfilter %}
38+
{% endwith %}
39+
{% else %}
40+
<code>{{ class_name }}</code>
41+
{% endif %}
42+
{% endblock heading %}
43+
44+
{% block labels scoped %}
45+
{% with labels = class.labels %}
46+
{% include "labels"|get_template with context %}
47+
{% endwith %}
48+
{% endblock labels %}
49+
50+
{% endfilter %}
51+
52+
{% block signature scoped %}
53+
{% if config.separate_signature and config.merge_init_into_class %}
54+
{% if "__init__" in class.all_members %}
55+
{% with function = class.all_members["__init__"] %}
56+
{% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %}
57+
{{ class.name }}
58+
{% endfilter %}
59+
{% endwith %}
60+
{% endif %}
61+
{% endif %}
62+
{% endblock signature %}
63+
64+
{% else %}
65+
{% if config.show_root_toc_entry %}
66+
{% filter heading(heading_level,
67+
role="class",
68+
id=html_id,
69+
toc_label=('<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code>&nbsp;'|safe if config.show_symbol_type_toc else '') + class.name,
70+
hidden=True,
71+
) %}
72+
{% endfilter %}
73+
{% endif %}
74+
{% set heading_level = heading_level - 1 %}
75+
{% endif %}
76+
77+
<div class="doc doc-contents {% if root %}first{% endif %}">
78+
{% block contents scoped %}
79+
{% block bases scoped %}
80+
{% if config.show_bases and class.bases %}
81+
<p class="doc doc-class-bases">
82+
Bases: {% for expression in class.bases -%}
83+
<code>{% include "expression"|get_template with context %}</code>{% if not loop.last %}, {% endif %}
84+
{% endfor -%}
85+
</p>
86+
{% endif %}
87+
{% endblock bases %}
88+
89+
{% block docstring scoped %}
90+
{% with docstring_sections = class.docstring.parsed %}
91+
{% include "docstring"|get_template with context %}
92+
{% endwith %}
93+
{% if config.merge_init_into_class %}
94+
{% if "__init__" in class.all_members and class.all_members["__init__"].has_docstring %}
95+
{% with docstring_sections = class.all_members["__init__"].docstring.parsed %}
96+
{% include "docstring"|get_template with context %}
97+
{% endwith %}
98+
{% endif %}
99+
{% endif %}
100+
{% endblock docstring %}
101+
102+
{% block source scoped %}
103+
{% if config.show_source %}
104+
{% if config.merge_init_into_class %}
105+
{% if "__init__" in class.all_members and class.all_members["__init__"].source %}
106+
{% with init = class.all_members["__init__"] %}
107+
<details class="quote">
108+
<summary>Source code in <code>
109+
{%- if init.relative_filepath.is_absolute() -%}
110+
{{ init.relative_package_filepath }}
111+
{%- else -%}
112+
{{ init.relative_filepath }}
113+
{%- endif -%}
114+
</code></summary>
115+
{{ init.source|highlight(language="python", linestart=init.lineno, linenums=True) }}
116+
</details>
117+
{% endwith %}
118+
{% endif %}
119+
{% elif class.source %}
120+
<details class="quote">
121+
<summary>Source code in <code>
122+
{%- if class.relative_filepath.is_absolute() -%}
123+
{{ class.relative_package_filepath }}
124+
{%- else -%}
125+
{{ class.relative_filepath }}
126+
{%- endif -%}
127+
</code></summary>
128+
{{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }}
129+
</details>
130+
{% endif %}
131+
{% endif %}
132+
{% endblock source %}
133+
134+
{% block children scoped %}
135+
{% set root = False %}
136+
{% set heading_level = heading_level + 1 %}
137+
{% include "children"|get_template with context %}
138+
{% endblock children %}
139+
{% endblock contents %}
140+
</div>
141+
142+
{% endwith %}
143+
144+
</div>

0 commit comments

Comments
 (0)