Skip to content

Commit 3c76d21

Browse files
committed
Add template
template.xml with Twig transformation. Twig template for classes.
1 parent e52f7fc commit 3c76d21

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## {{ class.name }}
2+
3+
{{ class.summary|raw }}
4+
5+
{{ class.description|raw }}
6+
7+
* Full name: {{ class.FullyQualifiedStructuralElementName }}
8+
{% if class.parent %}* Parent class: {{ class.parent.FullyQualifiedStructuralElementName }}
9+
{% endif %}
10+
{% if class.interfaces is not empty %}* This class implements: {{ class.interfaces|join(', ')|raw }}
11+
{% endif %}
12+
{% if class.deprecated %}* **Warning:** this class is **deprecated**. This means that this class will likely be removed in a future version.
13+
{% endif %}
14+
15+
{% if class.tags.see is not empty or class.tags.link is not empty %}
16+
**See Also:**
17+
18+
{% for see in class.tags.see %}
19+
* {{ see.reference }} {% if see.description %}- {{ see.description|raw }}{% endif %}
20+
{% endfor %}
21+
{% for link in class.tags.link %}
22+
* {{ link.link }} {% if link.description and link.description != link.link %}- {{ link.description|raw }}{% endif %}
23+
{% endfor %}
24+
25+
{% endif %}{# class.tags.see || class.tags.link #}
26+
27+
{% set specialMethods = class.magicMethods ? class.inheritedMethods.merge(class.magicMethods) : class.inheritedMethods %}
28+
{% for method in class.methods.merge(specialMethods) %}
29+
{% if method.visibility == 'public' %}
30+
31+
### {{ method.name }}
32+
33+
{{ method.summary|raw }}
34+
35+
{# Method signature #}
36+
```php
37+
{{ class.name }}::{{ method.name }}( {% for argument in method.arguments %}
38+
{{- argument.types ? argument.types|join('|')~' ' }}
39+
{{- argument.byReference ? '&' }}
40+
{{- argument.name }}{{ argument.default ? ' = '~argument.default }}
41+
{%- if not loop.last %}, {% endif %}
42+
{%- endfor %} )
43+
{{- method.response.types ? ': '~method.response.types|join('|') }}
44+
```
45+
46+
{{ method.description|raw }}
47+
48+
{% if method.static %}* This method is **static**.{% endif %}
49+
{% if method.deprecated %}* **Warning:** this method is **deprecated**. This means that this method will likely be removed in a future version.
50+
{% endif %}
51+
52+
{% if method.arguments is not empty %}
53+
**Parameters:**
54+
55+
| Parameter | Type | Description |
56+
|-----------|------|-------------|
57+
{% for argument in method.arguments %}
58+
| `{{ argument.name }}` | **{{ argument.types ? argument.types|join('|')|raw }}** | {{ argument.description|replace({'|': '|'})|raw }} |
59+
{% endfor %}
60+
61+
{% endif %}{# method.arguments is not empty #}
62+
63+
{% if method.response.description %}
64+
**Return Value:**
65+
66+
{{ method.response.description|raw }}
67+
68+
{% endif %}
69+
70+
{% if method.tags.see is not empty or method.tags.link is not empty %}
71+
**See Also:**
72+
73+
{% for see in method.tags.see %}
74+
* {{ see.reference }} {% if see.description %}- {{ see.description|raw }}{% endif %}
75+
{% endfor %}
76+
{% for link in method.tags.link %}
77+
* {{ link.link }} {% if link.description and link.description != link.link %}- {{ link.description|raw }}{% endif %}
78+
{% endfor %}
79+
80+
{% endif %}{# method.tags.see || method.tags.link #}
81+
82+
---
83+
84+
{% endif %}{# method.visibility == 'public' #}
85+
{% endfor %}{# method in class.methods #}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# {{ project.name|raw }}
2+
3+
{# TODO ToC #}
4+
5+
{% for class in project.indexes.classes|sort_asc %}
6+
{% if not class.abstract %}
7+
{% include 'class.md.twig' %}
8+
{% endif %}
9+
{% endfor %}
10+
11+
12+
--------
13+
> This document was automatically generated from source code comments on {{ "now"|date("Y-m-d") }} using [phpDocumentor](http://www.phpdoc.org/) and [cvuorinen/phpdoc-markdown-public](https://github.com/cvuorinen/phpdoc-markdown-public)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<template>
3+
<author>Carl Vuorinen</author>
4+
<email>carl.vuorinen@gmail.com</email>
5+
<version>1.0.0</version>
6+
<copyright>Carl Vuorinen 2015</copyright>
7+
<description>Generate usage documentation (documents only it's public API) for a small library in Markdown format so it can be published in GitHub.</description>
8+
<transformations>
9+
<transformation writer="twig" source="templates/markdown-public/index.md.twig" artifact="README.md" />
10+
</transformations>
11+
<parameters>
12+
<parameter key="twig-debug">true</parameter>
13+
</parameters>
14+
</template>

0 commit comments

Comments
 (0)