GenerateDocumentation¶
Generate keyword documentation with the documentation template.
Enabling the formatter
GenerateDocumentation is not included in default formatters.
You can enable it by using --select and --extend-select options.
By default, GenerateDocumentation uses Google docstring as the documentation template.
Overwriting documentation¶
The documentation will not be added if it is already present in the keyword. You can configure it by using
overwrite parameter:
Custom template¶
Custom templates can be loaded from the file using doc_template parameter. If you pass
google string it will use default template:
Templates support Jinja templating engine and we are providing several variables based on the keyword data. Here is the default template:
{% if keyword.arguments|length > 0 %}
{{ formatting.cont_indent }}Args:
{%- for arg in keyword.arguments %}
{{ formatting.cont_indent }}{{ formatting.cont_indent }}{{ arg.name }}: {% endfor %}
{% endif -%}
{% if keyword.returns|length > 0 %}
{{ formatting.cont_indent }}Returns:
{%- for value in keyword.returns %}
{{ formatting.cont_indent }}{{ formatting.cont_indent }}{{ value }}: {% endfor %}
{% endif -%}
The Jinja syntax is described in Jinja documentation. You can use it as a reference to create your own template. The following subsections explain in detail possible features.
Path to template can be absolute or relative (to working directory or configuration file directory):
First line of the documentation¶
The first line of the template is also the first line of the documentation that goes next to the [Documentation]
setting.
Leave the first line empty in the template if you want to start documentation from the second line.
Whitespace can be static or dynamic¶
Any whitespace in the template will apply to the documentation. For example you can put 4 spaces after every argument
and before -> sign:
Robocop provides also formatting class that contains two variables:
separator(default 4 spaces) - spacing between tokenscont_indent(default 4 spaces) - spacing after...signs
When used in the template, these variables will reflect the values defined in your configuration:
Arguments data¶
Robocop provides arguments as a list of variables in keyword.arguments variable. Every argument contains the following
variables:
name- name of the argument without default value (i.e.${arg})default- default value (i.e.value)full_name- name with default value (i.e.${arg} = value)
You can use them in the template:
You can take advantage of Jinja templating features such as if blocks. For instance, to include an = between
the argument name and its default value only when the default value is not empty, you can use:
Returned values data¶
Returned values are provided as a list of variables names in keyword.returns variable.
Keyword name¶
You can add current keyword name to the documentation using keyword.name variable.