8000 refactor: Update `*.html` base templates to extend their `*.html.jinj… · melissawm/mkdocstrings-python@e6f1b9c · GitHub
[go: up one dir, main page]

Skip to content

Commit e6f1b9c

Browse files
committed
refactor: Update *.html base templates to extend their *.html.jinja counterpart, while overriding the logs block to issue a logging message (info) stating that extending *.html templates is deprecated
Issue-151: mkdocstrings#151
1 parent 7c14924 commit e6f1b9c

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

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

0 commit comments

Comments
 (0)
0