|
6 | 6 |
|
7 | 7 | {#- Class and parent interfaces -#} |
8 | 8 | {% set interfaces = [] %} |
| 9 | +{#- Class and parent traits -#} |
| 10 | +{% set traits = [] %} |
9 | 11 |
|
10 | 12 | {% macro getRecursiveInterfaces(targetClass) %} |
11 | 13 | {%- import _self as self -%} |
|
20 | 22 | {%- endif -%} |
21 | 23 | {% endmacro %} |
22 | 24 |
|
| 25 | +{% macro getRecursiveTraits(targetClass, includeTraitsInTraits) %} |
| 26 | + {%- import _self as self -%} |
| 27 | + |
| 28 | + {%- if targetClass -%} |
| 29 | + {{- targetClass.usedTraits|join(',') -}}, |
| 30 | + |
| 31 | + {{- self.getRecursiveTraits(targetClass.parent, includeTraitsInTraits) -}} |
| 32 | + |
| 33 | + {%- if includeTraitsInTraits -%} |
| 34 | + {%- for trait in targetClass.usedTraits -%} |
| 35 | + {{- self.getRecursiveTraits(trait, includeTraitsInTraits) -}} |
| 36 | + {%- endfor -%} |
| 37 | + {%- endif -%} |
| 38 | + |
| 39 | + {%- endif -%} |
| 40 | +{% endmacro %} |
| 41 | + |
23 | 42 | {% import _self as self %} |
24 | 43 | {% set interfacesText = self.getRecursiveInterfaces(class) %} |
| 44 | +{% set traitsText = self.getRecursiveTraits(class, false) %} |
25 | 45 |
|
26 | 46 | {#- Convert to array, sort and remove duplicates -#} |
27 | 47 | {% for name in interfacesText|trim(', ')|split(',')|sort %} |
28 | 48 | {%- set interfaces = interfaces|merge({ (name): (name|split('\\')|last) }) -%} |
29 | 49 | {% endfor %} |
30 | 50 |
|
| 51 | +{% for name in traitsText|trim(', ')|split(',')|sort %} |
| 52 | + {%- set traits = traits|merge({ (name): (name|split('\\')|last) }) -%} |
| 53 | +{% endfor %} |
| 54 | + |
31 | 55 | | Name | {{ class.name }} | |
32 | 56 | | ----:|:---------------- | |
33 | 57 | {% if class.parent %} |
|
41 | 65 | [{{ iname|trim('\\')|split('\\')|slice(0, -1)|join('\\') }}\\<span style="font-weight: bold;">{{ ishort }}</span>](/api/interfaces.html#{{ iname|lower|replace('\\', '-') }}) {{- '<br />' -}} |
42 | 66 | {% endfor %} |
43 | 67 |
|
| 68 | +{% for tName, tShort in traits if tShort is not empty %} |
| 69 | +{% if loop.first -%} |
| 70 | +**Uses** | |
| 71 | +{%- endif -%} |
| 72 | + [{{ tName|trim('\\')|split('\\')|slice(0, -1)|join('\\') }}\\<span style="font-weight: bold;">{{ tShort }}</span>](/api/traits.html#{{ tShort|lower|replace('\\', '-') }}) {{- '<br />' -}} |
| 73 | +{% endfor %} |
44 | 74 |
|
45 | 75 | {% for author in class.tags.author %} |
46 | 76 | {% if loop.first %}- **Authors:**{% endif %} |
|
0 commit comments