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

Commit b602f72

Browse files
committed
chore(doc-gen): show 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 Attribute / CSS Class 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 5f76bc6 commit b602f72

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,23 @@ <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 %}
3545
<{$ doc.element $}
46+
{%- if not hasNameAsParam %}
47+
{$ lib.directiveParam(doc.name, {}, '', '') $}
48+
{%- endif -%}
3649
{%- for param in doc.params %}
3750
{$ lib.directiveParam(param.name, param.type, '="', '"') $}
3851
{%- endfor %}>
@@ -43,10 +56,14 @@ <h2 id="usage">Usage</h2>
4356
{% endif -%}
4457

4558
{%- if doc.restrict.cssClass -%}
59+
4660
<li>as CSS class:
4761
{% code %}
4862
{% set sep = joiner(' ') %}
4963
<{$ doc.element $} class="
64+
{%- if not hasNameAsParam -%}
65+
{$ sep() $}{$ lib.directiveParam(doc.name, {}, '', '') $}
66+
{%- endif -%}
5067
{%- for param in doc.params -%}
5168
{$ sep() $}{$ lib.directiveParam(param.name, param.type, ': ', ';') $}
5269
{%- endfor %}"> ... </{$ doc.element $}>

0 commit comments

Comments
 (0)