{%- if config.show_signature -%} {{ log.debug("Rendering signature") }} {%- with -%} {%- set ns = namespace( has_pos_only=False, render_pos_only_separator=True, render_kw_only_separator=True, annotation="", equal="=", ) -%} {%- if config.show_signature_annotations -%} {%- set ns.equal = " = " -%} {%- endif -%} ( {%- 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) -%} {%- if parameter.kind.value == "positional-only" -%} {%- set ns.has_pos_only = True -%} {%- else -%} {%- if ns.has_pos_only and ns.render_pos_only_separator -%} {%- set ns.render_pos_only_separator = False %}/, {% endif -%} {%- if parameter.kind.value == "keyword-only" -%} {%- if ns.render_kw_only_separator -%} {%- set ns.render_kw_only_separator = False %}*, {% endif -%} {%- endif -%} {%- endif -%} {%- if config.show_signature_annotations and parameter.annotation is not none -%} {%- if config.separate_signature and config.signature_crossrefs -%} {%- with expression = parameter.annotation -%} {%- set ns.annotation -%}: {% include "expression.html" with context %}{%- endset -%} {%- endwith -%} {%- else -%} {%- set ns.annotation = ": " + parameter.annotation|safe -%} {%- endif -%} {%- endif -%} {%- 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 -%} {%- if parameter.kind.value == "variadic positional" -%} {%- set ns.render_kw_only_separator = False -%} {%- endif -%} {% 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 -%} ) {%- if config.show_signature_annotations and function.annotation and not (config.merge_init_into_class and function.name == "__init__" ) %} -> {% if config.separate_signature and config.signature_crossrefs -%} {%- with expression = function.annotation %}{% include "expression.html" with context %}{%- endwith -%} {%- else -%} {{ function.annotation|safe }} {%- endif -%} {%- endif -%} {%- endwith -%} {%- endif -%}