2018-09-14 10:05:57 +01:00
{% macro renderSyntax(container, prefix) -%}
{% for name in container.names %}
2019-12-04 06:27:41 +05:30
< code-example hideCopy = "true" class = "no-box api-heading no-auto-link{% if container.deprecated %} deprecated-api-item{% endif %}" > ng {%if prefix %}{$ prefix $} {% endif %}< span class = "cli-name" > {$ name $}< / span >
2018-09-14 10:05:57 +01:00
{%- for arg in container.positionalOptions %} < < var > {$ arg.name $}< / var > > {% endfor %}
{%- if container.namedOptions.length %} [< var > options< / var > ]{% endif -%}
< / 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 >
2020-12-09 13:09:14 +01:00
< th width = "15%" > Argument< / th >
< th width = "40%" > Description< / th >
< th > Value Type< / th >
2018-09-14 10:05:57 +01:00
< / tr >
< / thead >
< tbody >
{% for option in arguments %}
< tr class = "cli-option" >
2020-12-09 13:09:14 +01:00
< td > < code class = "cli-option-syntax no-auto-link" > < < var > {$ option.name $}< / var > > < / code > < / td >
2018-09-14 10:05:57 +01:00
< td >
{$ option.description | marked $}
{% if option.subcommands.length -%}
< p > This option can take one of the following < a href = "#{$ option.name $}-commands" > sub-commands< / a > :< p >
< ul >
{% for subcommand in option.subcommands %}
2018-10-23 11:10:59 +01:00
< li > < code class = "no-auto-link" > < a class = "code-anchor" href = "#{$ subcommand.name $}-command" > {$ subcommand.name $}< / a > < / code > < / li >
2018-09-14 10:05:57 +01:00
{% endfor %}
< / ul >
{%- endif %}
< / 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 >
2020-12-09 13:09:14 +01:00
< th width = "15%" > Option< / th >
< th width = "40%" > Description< / th >
< 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 >
< td > {% if option.default !== undefined %}< 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) -%}
{$ 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) -%}
{% for command in container.positionalOptions %}{% if command.subcommands.length %}
< h2 > < a id = "{$ command.name $}-commands" > < / a > {$ command.name | title $} commands< / h2 >
{% for subcommand in command.subcommands %}
2018-10-23 11:10:59 +01:00
< h3 > < code class = "no-auto-link" > < a id = "{$ subcommand.name $}-command" > < / a > {$ subcommand.name $}< / code > < / h3 >
2018-09-14 10:05:57 +01:00
{% for name in container.names %}
{$ renderSyntax(subcommand, name) $}
{% endfor %}
{$ subcommand.description | marked $}
{# for now we assume that commands do not have further sub-commands #}
{$ renderArguments(subcommand.positionalOptions, 4) $}
{$ renderNamedOptions(subcommand.namedOptions, 4) $}
{% endfor %}
{% endif %}{% endfor %}
{%- endmacro -%}