Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4921e3f

Browse files
committed
chore(doc-gen): render void attributes in directive usage
When a directive doesn't take a value, its name is not included in the parameters, which previously meant that the directive name was missing from the Usage section of the docs. This commit adds the name to the Usage section when it is missing from the parameters. Closes #14045
1 parent 35f4e2f commit 4921e3f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

docs/config/templates/ngdoc/api/directive.template.html

+17-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,22 @@ <h2 id="usage">Usage</h2>
2929
</li>
3030
{% endif -%}
3131

32+
33+
{% set hasNameAsParam = false %}
34+
35+
{# when a directive's name is not a parameter (i.e. doesn't take a value),
36+
add the directive name to the list of attributes and/or css classes #}
37+
38+
{%- for param in doc.params %}
39+
{% set hasNameAsParam = true if param.name === doc.name else hasNameAsParam %}
40+
{%- endfor %}
41+
3242
{%- if doc.restrict.attribute -%}
3343
<li>as attribute:
3444
{% code %}
35-
<{$ doc.element $}
36-
{%- for param in doc.params %}
45+
<{$ doc.element $} {%- if not hasNameAsParam %}
46+
{$ lib.directiveParam(doc.name, {}, '', '') $}
47+
{%- endif -%} {%- for param in doc.params %}
3748
{$ lib.directiveParam(param.name, param.type, '="', '"') $}
3849
{%- endfor %}>
3950
...
@@ -43,10 +54,14 @@ <h2 id="usage">Usage</h2>
4354
{% endif -%}
4455

4556
{%- if doc.restrict.cssClass -%}
57+
4658
<li>as CSS class:
4759
{% code %}
4860
{% set sep = joiner(' ') %}
4961
<{$ doc.element $} class="
62+
{%- if not hasNameAsParam -%}
63+
{$ sep() $}{$ lib.directiveParam(doc.name, {}, '', '') $}
64+
{%- endif -%}
5065
{%- for param in doc.params -%}
5166
{$ sep() $}{$ lib.directiveParam(param.name, param.type, ': ', ';') $}
5267
{%- endfor %}"> ... </{$ doc.element $}>

0 commit comments

Comments
 (0)