-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
show_signature
rendering option
Co-authored-by: Will Da Silva <will@willdasilva.xyz>
- Loading branch information
1 parent
8f0aa42
commit 0f07c2e
Showing
2 changed files
with
35 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 32 additions & 29 deletions
61
src/mkdocstrings/templates/python/material/_base/signature.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
{{ log.debug() }} | ||
{%- with -%} | ||
{%- set ns = namespace(render_pos_only_separator=True, render_kw_only_separator=True, equal="=") -%} | ||
{%- if config.show_signature -%} | ||
{%- with -%} | ||
|
||
{%- if config.show_signature_annotations -%} | ||
{%- set ns.equal = " = " -%} | ||
{%- endif -%} | ||
{%- set ns = namespace(render_pos_only_separator=True, render_kw_only_separator=True, equal="=") -%} | ||
|
||
( | ||
{%- for parameter in function.parameters -%} | ||
{%- if config.show_signature_annotations -%} | ||
{%- set ns.equal = " = " -%} | ||
{%- endif -%} | ||
|
||
{%- if parameter.kind.value == "positional-only" -%} | ||
{%- if ns.render_pos_only_separator -%} | ||
{%- set ns.render_pos_only_separator = False %}/, {% endif -%} | ||
{%- elif parameter.kind.value == "keyword-only" -%} | ||
{%- if ns.render_kw_only_separator -%} | ||
{%- set ns.render_kw_only_separator = False %}*, {% endif -%} | ||
{%- endif -%} | ||
( | ||
{%- for parameter in function.parameters -%} | ||
|
||
{%- if config.show_signature_annotations and parameter.annotation is not none -%} | ||
{%- set annotation = ": " + parameter.annotation|safe -%} | ||
{%- endif -%} | ||
{%- if parameter.kind.value == "positional-only" -%} | ||
{%- if ns.render_pos_only_separator -%} | ||
{%- set ns.render_pos_only_separator = False %}/, {% endif -%} | ||
{%- elif parameter.kind.value == "keyword-only" -%} | ||
{%- if ns.render_kw_only_separator -%} | ||
{%- set ns.render_kw_only_separator = False %}*, {% 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 config.show_signature_annotations and parameter.annotation is not none -%} | ||
{%- set annotation = ": " + parameter.annotation|safe -%} | ||
{%- endif -%} | ||
|
||
{%- if parameter.kind.value == "variadic positional" -%} | ||
{%- set ns.render_kw_only_separator = False -%} | ||
{%- 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 -%} | ||
|
||
{{ parameter.name }}{{ annotation }}{{ default }} | ||
{%- if not loop.last %}, {% endif -%} | ||
{%- if parameter.kind.value == "variadic positional" -%} | ||
{%- set ns.render_kw_only_separator = False -%} | ||
{%- endif -%} | ||
|
||
{%- endfor -%} | ||
) | ||
{%- if config.show_signature_annotations and "return_annotation" in signature %} -> {{ signature.return_annotation }}{%- endif -%} | ||
{{ parameter.name }}{{ annotation }}{{ default }} | ||
{%- if not loop.last %}, {% endif -%} | ||
|
||
{%- endwith -%} | ||
{%- endfor -%} | ||
) | ||
{%- if config.show_signature_annotations and "return_annotation" in signature %} -> {{ signature.return_annotation }}{%- endif -%} | ||
|
||
{%- endwith -%} | ||
{%- endif -%} |