@@ -8,92 +8,82 @@ Context:
88 obj (griffe.Object): The object to render.
99 config (dict): The configuration options.
1010-#}
11- {% macro render_type_parameters (obj ) %}
11+
12+ {% - if config .show_signature_type_parameters -%}
13+ {% - block logs scoped -%}
14+ {#- Logging block.
15+
16+ This block can be used to log debug messages, deprecation messages, warnings, etc.
17+ -#}
18+ {{ log.debug("Rendering type parameters") }}
19+ {% - endblock logs -%}
20+
1221 {% - with ns = namespace (annotation ="" , equal ="=" , default =False ) -%}
13- {% - for type_parameter in obj .type_parameters -%}
14- {#- Prepare type bound or constraints. -#}
15- {% - if config .show_signature_annotations and type_parameter .annotation is not none -%}
16- {% - set ns .equal = " = " -%}
17- {% - if config .separate_signature and config .signature_crossrefs -%}
18- {% - with expression = type_parameter .annotation -%}
19- {% - set ns .annotation -%} : {% include "expression" |get_template with context %}{% - endset -%}
20- {% - endwith -%}
22+ {% - if obj .is_generic -%}
23+ [
24+ {% - for type_parameter in obj .type_parameters -%}
25+ {#- Prepare type bound or constraints. -#}
26+ {% - if config .show_signature_annotations and type_parameter .annotation is not none -%}
27+ {% - set ns .equal = " = " -%}
28+ {% - if config .separate_signature and config .signature_crossrefs -%}
29+ {% - with expression = type_parameter .annotation -%}
30+ {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
31+ {% - set ns .annotation -%} : {% include "expression" |get_template with context %}{% - endset -%}
32+ {% - endwith -%}
33+ {% - else -%}
34+ {% - set ns .annotation = ": " + type_parameter .annotation |safe -%}
35+ {% - endif -%}
2136 {% - else -%}
22- {% - set ns .annotation = ": " + type_parameter .annotation |safe -%}
37+ {% - set ns .equal = "=" -%}
38+ {% - set ns .annotation = "" -%}
2339 {% - endif -%}
24- {% - else -%}
25- {% - set ns .equal = "=" -%}
26- {% - set ns .annotation = "" -%}
27- {% - endif -%}
28-
29- {#- Prepare default value. -#}
30- {% - if type_parameter .default is not none -%}
31- {% - set ns .default = True -%}
32- {% - else -%}
33- {% - set ns .default = False -%}
34- {% - endif -%}
3540
36- {#- Prepare name. -#}
37- {% - set type_param_prefix -%}
38- {% - if type_parameter .kind == "type-var-tuple" -%}
39- *
40- {% - elif type_parameter .kind == "param-spec" -%}
41- **
41+ {#- Prepare default value. -#}
42+ {% - if type_parameter .default is not none -%}
43+ {% - set ns .default = True -%}
44+ {% - else -%}
45+ {% - set ns .default = False -%}
4246 {% - endif -%}
43- {% - endset -%}
44-
45- {#- Render type parameter name with optional cross-reference to its heading. -#}
46- {{ type_param_prefix }}
47- {% - if config .separate_signature and config .type_parameter_headings and config .signature_crossrefs -%}
48- {% - filter stash_crossref (length =type_parameter .name |length ) -%}
49- <autoref identifier =" {{ obj.path }}[{{ type_param_prefix }}{{ type_parameter.name }}]" optional >{{ type_parameter.name }}</autoref >
50- {% - endfilter -%}
51- {% - else -%}
52- {{ type_parameter.name }}
53- {% - endif -%}
5447
55- {#- Render type parameter bound or constraints. -#}
56- {{ ns.annotation }}
48+ {#- Prepare name. -#}
49+ {% - set type_param_prefix -%}
50+ {% - if type_parameter .kind == "type-var-tuple" -%}
51+ *
52+ {% - elif type_parameter .kind == "param-spec" -%}
53+ **
54+ {% - endif -%}
55+ {% - endset -%}
5756
58- {#- Render type parameter default value. -#}
59- {% - if ns .default -%}
60- {{ ns.equal }}
61- {% - if config .signature_crossrefs and config .separate_signature -%}
62- {% - with expression = type_parameter .default -%}
63- {% - include "expression" |get_template with context -%}
64- {% - endwith -%}
57+ {#- Render type parameter name with optional cross-reference to its heading. -#}
58+ {{ type_param_prefix }}
59+ {% - if config .separate_signature and config .type_parameter_headings and config .signature_crossrefs -%}
60+ {% - filter stash_crossref (length =type_parameter .name |length ) -%}
61+ <autoref identifier =" {{ obj.path }}[{{ type_param_prefix }}{{ type_parameter.name }}]" optional >{{ type_parameter.name }}</autoref >
62+ {% - endfilter -%}
6563 {% - else -%}
66- {{ type_parameter.default|safe }}
64+ {{ type_parameter.name }}
6765 {% - endif -%}
68- {% - endif -%}
6966
70- {% - if not loop .last %} , {% endif -%}
71- {% - endfor -%}
72- {% - endwith -%}
73- {% endmacro %}
67+ {#- Render type parameter bound or constraints. -#}
68+ {{ ns.annotation }}
7469
75- {% - if config .show_signature_annotations and config .show_signature_type_parameters -%}
76- {% - block logs scoped -%}
77- {#- Logging block.
78-
79- This block can be used to log debug messages, deprecation messages, warnings, etc.
80- -#}
81- {{ log.debug("Rendering type parameters") }}
82- {% - endblock logs -%}
70+ {#- Render type parameter default value. -#}
71+ {% - if ns .default -%}
72+ {{ ns.equal }}
73+ {% - if config .signature_crossrefs and config .separate_signature -%}
74+ {% - with expression = type_parameter .default -%}
75+ {#- YORE: Bump 2: Replace `"|get_template` with `.html.jinja"` within line. -#}
76+ {% - include "expression" |get_template with context -%}
77+ {% - endwith -%}
78+ {% - else -%}
79+ {{ type_parameter.default|safe }}
80+ {% - endif -%}
81+ {% - endif -%}
8382
84- {% - with class_tparams = obj .is_init_method and config .merge_init_into_class and obj .parent .is_generic -%}
85- {% - if obj .is_generic or class_tparams -%}
86- [
87- {% - endif -%}
88- {% - if class_tparams -%}
89- {{ render_type_parameters(obj.parent) }}
90- {% - if obj .is_generic %} , {% endif -%}
91- {% - endif -%}
92- {% - if obj .is_generic -%}
93- {{ render_type_parameters(obj) }}
94- {% - endif -%}
95- {% - if obj .is_generic or class_tparams -%}
83+ {% - if not loop .last %} , {% endif -%}
84+ {% - endfor -%}
9685 ]
9786 {% - endif -%}
87+
9888 {% - endwith -%}
9989{% - endif -%}
0 commit comments