Skip to content

Commit e4e3623

Browse files
committed
🆕 Properties sections for classes and traits
🆕 Property templates 🎨 Increase header for Methods for sidebar
1 parent df5120b commit e4e3623

File tree

6 files changed

+107
-5
lines changed

6 files changed

+107
-5
lines changed

data/templates/vuepress/class.md.twig

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
{% endif %}{# class.tags.see || class.tags.link #}
9494

9595
{% set methodsList = [] %}
96-
#### <span style="display: none;">{{ class }}</span> Methods:
96+
### <span style="display: none;">{{ class }}</span> Methods
9797
{# Lista de métodos públicos y protegidos #}
9898
{% for method in class.methods|sort_asc %}
9999
{% set methodsList = methodsList|merge([method.name]) %}
@@ -104,7 +104,7 @@
104104
> This class has not methods.
105105
{% endfor %}
106106

107-
#### <span style="display: none;">{{ class }}</span> Inherited methods:
107+
#### <span style="display: none;">{{ class }}</span> Inherited methods
108108
{# Lista de métodos públicos y protegidos #}
109109
{% for method in class.inheritedMethods if method.name not in methodsList -%}
110110
{%- if method.parent in project.indexes.classes %}
@@ -125,3 +125,33 @@
125125
{% else %}
126126
> This class has not inherited methods.
127127
{% endfor %}
128+
129+
{% set propertiesList = [] %}
130+
### <span style="display: none;">{{ class }}</span> Properties
131+
{# Lista de propiedades públicas y protegidas #}
132+
{% for property in class.properties|merge(class.magicProperties|default([]))|sort_asc if property.visibility != 'private' %}
133+
{% set propertiesList = propertiesList|merge([property.name]) %}
134+
{% include 'property.md.twig' %}
135+
{% else %}
136+
> This class has not properties.
137+
{% endfor %}
138+
139+
#### <span style="display: none;">{{ class }}</span> Inherited properties
140+
{# Lista de métodos públicos y protegidos #}
141+
{% for property in class.inheritedProperties if property.name not in propertiesList and property.visibility != 'private'-%}
142+
{%- if property.parent in project.indexes.classes %}
143+
{%- set parent_location = 'classes' %}
144+
{%- elseif property.parent in project.indexes.interfaces %}
145+
{%- set parent_location = 'interfaces' %}
146+
{%- else %}
147+
{%- set parent_location = 'traits' %}
148+
{%- endif %}
149+
150+
- [{{ property.parent.namespace|trim('\\') -}}\\<span style="font-weight: bold;">{{ property.parent.name }}</span>](/api/{{ parent_location }}.html#
151+
{{- property.parent|trim('\\')|lower|replace('\\', '-') -}}
152+
)::
153+
{{- include('property-anchor-link.md.twig', { text: '$' ~ property.name }) -}}
154+
{{ include('badges.md.twig', { elem: property }) }}
155+
{% else %}
156+
> This class has not inherited properties.
157+
{% endfor %}

data/templates/vuepress/interface.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
{% endif %}{# class.tags.see || class.tags.link #}
5757

58-
#### <span style="display: none;">{{ class.FullyQualifiedStructuralElementName }}</span> Methods:
58+
### <span style="display: none;">{{ interface }}</span> Methods
5959
{# Lista de métodos públicos y protegidos #}
6060
{% for method in interface.methods|sort_asc %}
6161
{% if method.visibility != 'private' %}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% if property.parent in project.indexes.classes %}
2+
{%- set parent_location = 'classes' %}
3+
{%- elseif property.parent in project.indexes.interfaces %}
4+
{%- set parent_location = 'interfaces' %}
5+
{%- else %}
6+
{%- set parent_location = 'traits' %}
7+
{%- endif -%}
8+
9+
<a href="{{ parent_location }}.html#{{ property.parent|trim('\\')|replace('\\', '-') }}::${{ property.name }}">
10+
{{- text|default(property.name|default(property))|raw -}}
11+
</a> {{ '' -}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a id="{{ property.parent|trim('\\')|replace('\\', '-') }}::${{ property.name }}" style="display: block; position: relative; top: -5rem; visibility: hidden;"></a> {{ ''-}}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
:::
3+
{%- if property.visibility == 'protected' %}
4+
{{- 'warning ' -}}
5+
{% elseif property.visibility == 'public' %}
6+
{{- 'tip ' -}}
7+
{% else %}
8+
{{- 'danger ' -}}
9+
{% endif -%}
10+
11+
{{ include('property-anchor-ref.md.twig') }}
12+
{{- '$' ~ property.name }} {{ include('badges.md.twig', { elem: property }) }}
13+
-----
14+
15+
{# property signature #}
16+
```php
17+
{{ property.visibility }}{% if property.static %} static{% endif %} {{ property.types|default(['mixed'])|join('|')}} ${{ property.name }}
18+
{%- if property.default %} = {{ property.default|raw }}{% endif %};
19+
```
20+
21+
{{ property.summary|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
22+
23+
{% if property.description is not empty %}
24+
***Description:***
25+
26+
{{ property.description|replace({'#### ': '- ', '### ': '- ', '## ': '- ', '# ': '- ',}) }}
27+
{% endif %}
28+
29+
{% if method.response.description %}
30+
***Return Value:***
31+
32+
{{ method.response.description|raw }}
33+
34+
{% endif %}
35+
36+
37+
{% if method.tags.see is not empty or method.tags.link is not empty %}
38+
***See Also:***
39+
40+
{% for see in method.tags.see %}
41+
* `{{ see.reference }}` {% if see.description %}-{% endif %} {{ see.description }}
42+
{% endfor %}
43+
44+
{% for link in class.tags.link %}
45+
* [{{ link.description|default(link.link) }}]({{ link.link }})
46+
{% endfor %}
47+
48+
{% endif %}{# class.tags.see || class.tags.link #}
49+
50+
:::

data/templates/vuepress/trait.md.twig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
{% endif %}{# class.tags.see || class.tags.link #}
5959

60-
#### <span style="display: none;">{{ trait }}</span> Methods:
60+
### <span style="display: none;">{{ trait }}</span> Methods
6161
{# Lista de métodos públicos y protegidos #}
6262
{% for method in trait.methods|sort_asc %}
6363
{% if method.visibility != 'private' %}
@@ -67,7 +67,7 @@
6767
> This trait has not methods.
6868
{% endfor %}
6969

70-
#### <span style="display: none;">{{ trait }}</span> Inherited methods:
70+
#### <span style="display: none;">{{ trait }}</span> Inherited methods
7171
{# Lista de métodos públicos y protegidos #}
7272
{% for method in trait.inheritedMethods -%}
7373
{%- if method.visibility != 'private' %}
@@ -79,3 +79,13 @@
7979
{% else %}
8080
> This trait has not inherited methods.
8181
{% endfor %}
82+
83+
{% set propertiesList = [] %}
84+
### <span style="display: none;">{{ trait }}</span> Properties
85+
{# Lista de propiedades públicas y protegidas #}
86+
{% for property in trait.properties|merge(trait.magicProperties)|sort_asc if property.visibility != 'private' %}
87+
{% set propertiesList = propertiesList|merge([property.name]) %}
88+
{% include 'property.md.twig' %}
89+
{% else %}
90+
> This trait has not properties.
91+
{% endfor %}

0 commit comments

Comments
 (0)