Skip to content

Commit de0268e

Browse files
committed
🎨 Simplify inclusion of badges
🆕 Template to include all badges at once 🆕 Badge for static members
1 parent 247a6a6 commit de0268e

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- ' ' -}}
2+
3+
{%- if elem.abstract -%}
4+
<Badge text="abstract"/>
5+
{%- endif -%}
6+
7+
{%- if elem.final -%}
8+
<Badge text="final"/>{{-' '}}
9+
{%- endif -%}
10+
11+
{%- if elem.static -%}
12+
<Badge text="static" type="warn"/>{{-' '}}
13+
{%- endif -%}
14+
15+
{% if elem.deprecated -%}
16+
<Badge text="deprecated" type="error"/>
17+
{%- endif -%}
18+
19+
{%- if elem.default -%}
20+
<Badge text="optional" type="warn"/>{{-' '}}
21+
{%- endif -%}
22+
23+
{{- ' ' -}}

data/templates/vuepress/class.md.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## {{ class|trim('\\') }} <Badge v-if="'{{ class.deprecated }}'" text="deprecated" type="error"/> <Badge v-if="'{{ class.abstract }}'" text="abstract"/> <Badge v-if="'{{ class.final }}'" text="final" />
1+
## {{ class|trim('\\') }} {{ include('badges.md.twig', { elem: class }) }}
22

33
{{ class.summary|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
44

@@ -119,8 +119,8 @@
119119
- [{{ method.parent.namespace|trim('\\') -}}\\<span style="font-weight: bold;">{{ method.parent.name }}</span>](/api/{{ parent_location }}.html#
120120
{{- method.parent|trim('\\')|lower|replace('\\', '-') -}}
121121
)::
122-
{{- include('method-anchor-link.md.twig', { text: method.name ~ '()' }) }}
123-
<Badge v-if="'{{ method.deprecated }}'" text="deprecated" type="error"/> <Badge v-if="'{{ method.abstract }}'" text="abstract"/> <Badge v-if="'{{ method.final }}'" text="final" />
122+
{{- include('method-anchor-link.md.twig', { text: method.name ~ '()' }) -}}
123+
{{ include('badges.md.twig', { elem: method }) }}
124124
{% endif %}
125125
{% else %}
126126
> This class has not inherited methods.

data/templates/vuepress/index.md.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This represents a `protected` member.
2525

2626
- Applied to any `abstract` class or method: <Badge text="abstract" />
2727
- Applied to any `final` class or method: <Badge text="final" />
28+
- Applied to any `static` property or method: <Badge text="static" type="warn"/>
2829
- Applied to any deprecated class, method or property: <Badge text="deprecated" type="error"/>
2930
- Applied to optional parameters in methods and functions: <Badge text="optional" type="warn"/>
3031

data/templates/vuepress/interface.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## {{ interface|trim('\\') }} <Badge v-if="'{{ class.deprecated }}'" text="deprecated" type="error"/>
1+
## {{ interface|trim('\\') }} {{ include('badges.md.twig', { elem: interface }) }}
22

33
{{ interface.summary|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
44

data/templates/vuepress/method-header.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
{% endif -%}
1010

1111
{{ include('method-anchor-ref.md.twig') }}
12-
{{- method.name }} <Badge v-if="'{{ method.deprecated }}'" text="deprecated" type="error"/> <Badge v-if="'{{ method.abstract }}'" text="abstract"/> <Badge v-if="'{{ method.final }}'" text="final" />
12+
{{- method.name }} {{ include('badges.md.twig', { elem: method }) }}
1313
-----

data/templates/vuepress/method.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| Parameter | Type(s) | Description |
1818
|-----------|------|-------------|
1919
{% for argument in method.arguments %}
20-
| `{{ argument.name }}` <Badge v-if="'{{ argument.default }}'" text="optional" type="warn"/> | **`{{ argument.types ? argument.types|join('`** <br /> **`')|raw }}`** | {{ argument.description|replace({'|': '&#124;', "\n": ' ', "\r": ' '})|raw }} |
20+
| `{{ argument.name }}` {{ include('badges.md.twig', { elem: argument }) }} | **`{{ argument.types ? argument.types|join('`** <br /> **`')|raw }}`** | {{ argument.description|replace({'|': '&#124;', "\n": ' ', "\r": ' '})|raw }} |
2121
{% endfor %}
2222
{% endif %}{# method.arguments is not empty #}
2323

data/templates/vuepress/trait.md.twig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## {{ trait|trim('\\') }} <Badge v-if="'{{ trait.deprecated }}'" text="deprecated" type="error"/>
1+
## {{ trait|trim('\\') }} {{ include('badges.md.twig', { elem: trait }) }}
22

33
{{ trait.summary|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
44

@@ -74,8 +74,7 @@
7474
- [{{ method.parent.namespace|trim('\\') -}}\\<span style="font-weight: bold;">{{ method.parent.name }}</span>](/api/traits.html#
7575
{{- method.parent|trim('\\')|lower|replace('\\', '-') -}}
7676
)::
77-
{{- include('method-anchor-link.md.twig', { text: method.name ~ '()' }) }}
78-
<Badge v-if="'{{ method.deprecated }}'" text="deprecated" type="error"/> <Badge v-if="'{{ method.abstract }}'" text="abstract"/> <Badge v-if="'{{ method.final }}'" text="final" />
77+
{{- include('method-anchor-link.md.twig', { text: method.name ~ '()' }) }} {{ include('badges.md.twig', { elem: method }) }}
7978
{% endif %}
8079
{% else %}
8180
> This trait has not inherited methods.

0 commit comments

Comments
 (0)