Skip to content

Commit 80249da

Browse files
committed
🆕 Traits list
1 parent 85e94ae commit 80249da

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
sidebarDepth: 2
3+
editLink: false
4+
pageClass: phpdoc-api-generated-page
5+
---
6+
7+
# Traits
8+
9+
::: danger Auto-generation note:
10+
{# FIXME #} :bug: Inherited members and used traits are ignored due to some issues.
11+
:::
12+
13+
{% for namespace in project.indexes.namespaces|sort_asc %}
14+
{%- for trait in namespace.traits|sort_asc %}
15+
{%- include 'trait.md.twig' %}
16+
{%- endfor %}
17+
{% endfor %}
18+
19+
20+
--------
21+
_This document was automatically generated from source code comments using [phpDocumentor](http://www.phpdoc.org/)._

data/templates/vuepress/template.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<transformation writer="twig" source="templates/vuepress/index.md.twig" artifact="README.md" />
1010
<transformation writer="twig" source="templates/vuepress/index-classes.md.twig" artifact="classes.md" />
1111
<transformation writer="twig" source="templates/vuepress/index-interfaces.md.twig" artifact="interfaces.md" />
12+
<transformation writer="twig" source="templates/vuepress/index-traits.md.twig" artifact="traits.md" />
1213
</transformations>
1314
<parameters>
1415
<parameter key="twig-debug">true</parameter>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
## {{ trait|trim('\\') }} <Badge v-if="'{{ trait.deprecated }}'" text="deprecated" type="error"/>
2+
3+
{{ trait.summary|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
4+
5+
{{ trait.description|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
6+
7+
{#- Used traits -#}
8+
{% set usedTraits = [] %}
9+
10+
{% macro getRecursiveTraits(targetTrait) %}
11+
{%- import _self as self -%}
12+
13+
{%- if targetTrait -%}
14+
{{- targetTrait.usedTraits|join(',') -}},
15+
16+
{%- for trait in targetTrait.usedTraits -%}
17+
{{- self.getRecursiveTraits(trait) -}}
18+
{%- endfor -%}
19+
{%- endif -%}
20+
{% endmacro %}
21+
22+
{% import _self as self %}
23+
{% set usedTraitsText = self.getRecursiveTraits(trait) %}
24+
25+
{#- Convert to array, sort and remove duplicates -#}
26+
{% for name in usedTraitsText|trim(', ')|split(',')|sort %}
27+
{%- set usedTraits = usedTraits|merge({ (name): (name|split('\\')|last) }) -%}
28+
{% endfor %}
29+
30+
| Name | {{ trait.name }} |
31+
| ----:|:---------------- |
32+
{% for tName, tShort in usedTraits if tShort is not empty %}{# FIXME #}
33+
{% if loop.first -%}
34+
**Uses** |
35+
{%- endif -%}
36+
[{{ tName|trim('\\')|split('\\')|slice(0, -1)|join('\\') }}\\<span style="font-weight: bold;">{{ tShort }}</span>](/api/traits.html#{{ tShort|lower|replace('\\', '-') }}) {{- '<br />' -}}
37+
{% endfor %}
38+
39+
40+
{% for author in trait.tags.author %}
41+
{% if loop.first %}- **Authors:**{% endif %}
42+
43+
- {{ author.description }}
44+
{%- endfor %}
45+
46+
47+
{% if trait.tags.see is not empty or trait.tags.link is not empty %}
48+
***See Also:***
49+
50+
{% for see in trait.tags.see %}
51+
* `{{ see.reference }}` {% if see.description %}-{% endif %} {{ see.description }}
52+
{% endfor %}
53+
54+
{% for link in trait.tags.link %}
55+
* [{{ link.description|default(link.link) }}]({{ link.link }})
56+
{% endfor %}
57+
58+
{% endif %}{# class.tags.see || class.tags.link #}
59+
60+
#### <span style="display: none;">{{ trait }}</span> Methods:
61+
{# Lista de métodos públicos y protegidos #}
62+
{% for method in trait.methods|sort_asc %}
63+
{% if method.visibility != 'private' %}
64+
{% include 'method.md.twig' %}
65+
{% endif %}
66+
{% else %}
67+
> This trait has not methods.
68+
{% endfor %}
69+
70+
#### <span style="display: none;">{{ trait }}</span> Inherited methods:
71+
{# Lista de métodos públicos y protegidos #}
72+
{% for method in trait.inheritedMethods -%}
73+
{%- if method.visibility != 'private' %}
74+
- [{{ method.parent.namespace|trim('\\') -}}\\<span style="font-weight: bold;">{{ method.parent.name }}</span>](/api/traits.html#
75+
{{- method.parent|trim('\\')|lower|replace('\\', '-') -}}
76+
)::
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" />
79+
{% endif %}
80+
{% else %}
81+
> This trait has not inherited methods.
82+
{% endfor %}

0 commit comments

Comments
 (0)