build(docs-infra): render optional decorator options with a ? (#39167)

Decorator API pages list all their available options in an overview
table and also in a detailed view. Now the rendered syntax of each
option will show a `?` after the name if the option is not required.
This is inline with how class and interface members are rendered.

PR Close #39167
This commit is contained in:
Pete Bacon Darwin 2020-10-07 20:56:53 +01:00 committed by Joey Perrott
parent f28b451b0c
commit 293270696b
2 changed files with 15 additions and 10 deletions

View File

@ -12,12 +12,16 @@
{% for option in doc.members %} {% for option in doc.members %}
<a id="{$ option.anchor $}"></a> <a id="{$ option.anchor $}"></a>
<table class="is-full-width option-table"> <table class="is-full-width option-table">
<thead><tr><th> <thead>
<div class="with-github-links"> <tr>
<h3>{$ option.name $}</h3> <th>
{$ github.githubLinks(option, versionInfo) $} <div class="with-github-links">
</div> <h3>{$ option.name $}</h3>
</th></tr></thead> {$ github.githubLinks(option, versionInfo) $}
</div>
</th>
</tr>
</thead>
<tbody> <tbody>
<tr> <tr>
<td> <td>
@ -26,8 +30,9 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<code-example language="ts" hideCopy="true" class="no-box api-heading{% if option.deprecated %} deprecated-api-item{% endif %}"> <code-example language="ts" hideCopy="true"
{$ option.name $}: {$ option.type | escape $} class="no-box api-heading{% if option.deprecated %} deprecated-api-item{% endif %}">
{$ option.name $}{%- if option.isOptional %}?{% endif -%}: {$ option.type | escape $}
</code-example> </code-example>
</td> </td>
</tr> </tr>
@ -46,4 +51,4 @@
</table> </table>
{% endfor %} {% endfor %}
</section> </section>
{% endblock %} {% endblock %}

View File

@ -10,7 +10,7 @@
<tr class="option"> <tr class="option">
<td> <td>
<a class="code-anchor" href="{$ doc.path $}#{$ option.anchor | urlencode $}"> <a class="code-anchor" href="{$ doc.path $}#{$ option.anchor | urlencode $}">
<code>{$ option.name $}</code> <code>{$ option.name $}{%- if option.isOptional %}?{% endif -%}</code>
</a> </a>
</td> </td>
<td>{$ option.shortDescription | marked $}</td> <td>{$ option.shortDescription | marked $}</td>