2018-09-14 10:05:57 +01:00
{% macro renderSyntax(container, prefix) -%}
2022-03-02 09:49:57 +01:00
{% for usage in container.usages %}
< code-example hideCopy = "true" class = "api-heading no-auto-link{% if container.deprecated %} deprecated-api-item{% endif %}" >
{$ usage $}
2018-09-14 10:05:57 +01:00
</ code-example >
{% endfor %}
{% endmacro %}
{% macro renderArguments(arguments, level = 2) %}
{% if arguments.length %}
< h {$ level $} class = "no-anchor" > Arguments< /h{$ level $}>
< table class = "is-full-width list-table property-table" >
< thead >
< tr >
2023-05-26 21:11:32 +05:30
< th style = "width:15%" > Argument</ th >
< th style = "width:40%" > Description</ th >
2020-12-09 13:09:14 +01:00
< th > Value Type</ th >
2018-09-14 10:05:57 +01:00
</ tr >
</ thead >
< tbody >
{% for option in arguments %}
< tr class = "cli-option" >
2022-03-02 09:49:57 +01:00
< td >< code class = "cli-option-syntax no-auto-link" > {$ option.name $}</ code ></ td >
2018-09-14 10:05:57 +01:00
< td >
{$ option.description | marked $}
</ td >
2020-12-09 13:09:14 +01:00
< td >< code class = "cli-option-syntax no-auto-link" > {% if option.enum.length > 0 %}{$ renderValues(option.enum) $}{% else %}string{% endif %}</ code ></ td >
2018-09-14 10:05:57 +01:00
</ tr >
{% endfor %}
</ tbody >
</ table >
{% endif %}
{% endmacro %}
{% macro renderNamedOptions(options, level = 2) %}
{% if options.length %}
< h {$ level $} class = "no-anchor" > Options< /h{$ level $}>
< table class = "is-full-width list-table property-table" >
< thead >
< tr >
2023-05-26 21:11:32 +05:30
< th style = "width:15%" > Option</ th >
< th style = "width:40%" > Description</ th >
2020-12-09 13:09:14 +01:00
< th > Value Type</ th >
< th > Default Value</ th >
</ tr >
2018-09-14 10:05:57 +01:00
</ thead >
< tbody >
{% for option in options %}
< tr class = "cli-option" >
< td >
2020-12-09 13:09:14 +01:00
< code class = "cli-option-syntax no-auto-link{% if option.deprecated %} deprecated-api-item{% endif %}" > {$ renderOptionName(option.name) $}</ code >
2018-09-14 10:05:57 +01:00
</ td >
< td >
2019-01-14 15:33:18 +01:00
{% if option.deprecated %}
{% if option.deprecated === true %}
2019-01-14 16:31:04 +01:00
< p >< strong > Deprecated</ strong ></ p >
{% else %}
{$ ('**Deprecated:** ' + option.deprecated) | marked $}
2019-01-14 15:33:18 +01:00
{% endif %}
{% endif %}
2018-09-14 10:05:57 +01:00
{$ option.description | marked $}
2018-10-05 13:50:29 +01:00
{% if option.aliases.length %}< p >< span class = "cli-aliases" > Aliases:</ span > {% for alias in option.aliases %}{$ renderOptionName(alias) $}{% if not loop.last %}, {% endif %}{% endfor %}</ p > {% endif %}
2018-09-14 10:05:57 +01:00
</ td >
2020-12-09 13:09:14 +01:00
< td >< code class = "no-auto-link" > {$ renderOptionValues(option.type, option.enum) $}</ td >
2022-03-02 09:49:57 +01:00
< td > {% if option.default !== undefined and option.default !== '' %}< code class = "no-auto-link" > {$ option.default $}</ code > {% endif %}</ td >
2018-09-14 10:05:57 +01:00
</ tr >
{% endfor %}
</ tbody >
</ table >
{% endif %}
{% endmacro %}
2018-10-05 13:50:29 +01:00
{%- macro renderOptionName(name) -%}
{% if name.length > 1 %}-{% endif %}-{$ name $}
{%- endmacro %}
2018-09-14 10:05:57 +01:00
2020-12-09 13:09:14 +01:00
{%- macro renderValues(values) -%}
2022-07-01 07:40:33 +00:00
{$ values.join(' | ') $}
2018-09-14 10:05:57 +01:00
{%- endmacro -%}
2020-12-09 13:09:14 +01:00
{%- macro renderOptionValues(type, values) -%}
{%- if values.length -%}
{$ renderValues(values) $}
2018-09-14 10:05:57 +01:00
{%- else -%}
2020-12-09 13:09:14 +01:00
{$ type $}
2018-09-14 10:05:57 +01:00
{%- endif -%}
{%- endmacro -%}
{%- macro renderSubcommands(container) -%}
2022-03-02 09:49:57 +01:00
{% if container.subcommands.length %}
< h2 >< a id = "{$ container.name $}-commands" ></ a > {$ container.name | title $} commands</ h2 >
{% for subcommand in container.subcommands %}
2022-03-15 07:44:55 +01:00
< h3 >< a id = "{$ subcommand.name $}-command" ></ a > {$ subcommand.name $}</ h3 >
2018-09-14 10:05:57 +01:00
{$ renderSyntax(subcommand, name) $}
2022-03-02 09:49:57 +01:00
{$ subcommand.shortDescription | marked $}
2018-09-14 10:05:57 +01:00
{# for now we assume that commands do not have further sub-commands #}
{$ renderArguments(subcommand.positionalOptions, 4) $}
{$ renderNamedOptions(subcommand.namedOptions, 4) $}
{% endfor %}
2022-03-02 09:49:57 +01:00
{% endif %}
2022-07-01 07:40:33 +00:00
{%- endmacro -%}