Skip to content

Commit dcf9cd1

Browse files
authored
Merge pull request #55 from ConvertKit/phpdocumentor
Add phpDocumentor generated PHP SDK Documentation
2 parents ba74ace + 0ebf834 commit dcf9cd1

File tree

10 files changed

+1208
-7
lines changed

10 files changed

+1208
-7
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{% block content %}
2+
# {{ node.name }}
3+
4+
{% if node.summary %}{{ node.summary|raw }}{% endif %}
5+
{% if node.description %}{{ node.description|raw }}{% endif %}
6+
7+
* Full name: `{{ node.FullyQualifiedStructuralElementName }}`
8+
{% if node.parent and node.parent is not empty %}* Parent class: {{ macros.mdClassLink(node.parent, macros.mdClassPath(node), node.parent.FullyQualifiedStructuralElementName) }}
9+
{% endif %}
10+
{% if node.final %}* This class is marked as **final** and can't be subclassed
11+
{% endif %}
12+
{% if node.deprecated %}* **Warning:** this class is **deprecated**. This means that this class will likely be removed in a future version.
13+
{% endif %}
14+
{% if node.interfaces is not empty %}
15+
* This class implements:
16+
{% for interface in node.interfaces %}
17+
{% if loop.index0 > 0 %}{{ ', ' }}{% endif %}{{ macros.mdClassLink(interface, macros.mdClassPath(node), interface) }}{% endfor %}
18+
19+
{% endif %}
20+
{% if node.abstract %}* This class is an **Abstract class**
21+
{% endif %}
22+
{% if node.final %}* This class is a **Final class**
23+
{% endif %}
24+
25+
{% if node.tags.see is not empty or node.tags.link is not empty %}
26+
**See Also:**
27+
28+
{% for see in node.tags.see %}
29+
* {{ see.reference }} {% if see.description %}- {{ see.description|raw }}{% endif %}
30+
31+
{% endfor %}
32+
{% for link in node.tags.link %}
33+
* {{ link.link }} {% if link.description and link.description != link.link %}- {{ link.description|raw }}{% endif %}
34+
35+
{% endfor %}
36+
37+
{% endif %}{# node.tags.see || node.tags.link #}
38+
{% if node.constants | length > 0 %}
39+
## Constants
40+
41+
| Constant | Visibility | Type | Value |
42+
|:---------|:-----------|:-----|:------|
43+
{% for constant in node.constants %}
44+
|`{{constant.name}}`|{{ constant.visibility | default('*default*') }}|{{constant.type | default(' ')}}|{{constant.value}}|
45+
{% endfor %}
46+
{% endif %}
47+
{% if node.properties | length > 0 %}
48+
## Properties
49+
50+
{% for property in node.properties %}
51+
{% include 'property.md.twig' %}
52+
{% endfor %}
53+
{% endif %}
54+
{% if node.methods|length > 0 %}
55+
## Methods
56+
57+
{% for method in node.methods %}
58+
{% include 'method.md.twig' %}
59+
{% endfor %}
60+
{% endif %}{# if methods #}
61+
62+
{% if node.InheritedMethods|length > 0 %}
63+
## Inherited methods
64+
65+
{% for method in node.InheritedMethods %}
66+
{% include 'method.md.twig' %}
67+
{% endfor %}
68+
69+
{% endif %}{# if InheritedMethods #}
70+
71+
{% endblock %}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
### {{ method.name }}
2+
3+
{{ method.summary | raw }}
4+
5+
{# Method signature #}
6+
```php
7+
{% if method.final %}{{ 'final' ~ ' ' }}{% endif %}{{ method.visibility ~ ' ' }}{%if method.static%}{{ 'static' ~ ' ' }}{% endif %}{{ method.name }}({% for argument in method.arguments %}
8+
{{- argument.type | raw }}
9+
{{- argument.byReference ? '&' }} $
10+
{{- argument.name | raw }}{% if argument.default %} = {{ argument.default | raw }}{% endif %}
11+
{%- if not loop.last %}, {% endif %}
12+
{%- endfor %}): {{ method.response.type | raw }}
13+
```
14+
{% if method.description %}{{ method.description | raw }}{% endif %}
15+
{% if method.static %}* This method is **static**.{% endif %}
16+
{% if method.abstract %}* This method is **abstract**.{% endif %}
17+
{% if method.final %}* This method is **final**.{% endif %}
18+
{% if method.deprecated %}* **Warning:** this method is **deprecated**. This means that this method will likely be removed in a future version.
19+
{% endif %}
20+
21+
{% if method.arguments is not empty %}
22+
23+
**Parameters:**
24+
25+
| Parameter | Type | Description |
26+
|-----------|------|-------------|
27+
{% for argument in method.arguments %}
28+
| `{{ '$' ~ argument.name }}` | **{{ argument.type ? argument.type | default(' ') | replace({'|': '\\|'}) | raw }}** | {{ argument.description | replace({'|': '\\|'}) | nl2br | replace({"\n": "", "\r": "", "\t": ""}) | raw }} |
29+
{% endfor %}
30+
{% endif %}{# method.arguments is not empty #}
31+
{% if method.response.description and method.response.description is not empty %}
32+
33+
**Return Value:**
34+
35+
{{ method.response.description | raw }}
36+
{% endif %}
37+
38+
{% if method.tags.see is not empty or method.tags.link is not empty %}
39+
**See Also:**
40+
41+
{% for see in method.tags.see %}
42+
* {{ see.reference }} {% if see.description is not empty %}- {{ see.description | raw }}{% endif %}
43+
{% endfor %}
44+
{% for link in method.tags.link %}
45+
* {{ link.link }} {% if link.description and link.description != link.link %}- {{ link.description | raw }}{% endif %}
46+
{% endfor %}
47+
48+
{% endif %}{# method.tags.see || method.tags.link #}
49+
50+
---
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### {{ property.name }}
2+
3+
{{ property.summary | raw }}
4+
5+
```php
6+
{{ property.visibility ~ ' ' }}{% if property.static %}{{ 'static' ~ ' ' }}{% endif %}{% if property.type and property.type is not empty %}{{ property.type ~ ' ' }}{% endif %}{{ '$' ~ property.name }}
7+
```
8+
9+
{% if property.description %}{{ property.description | raw }}{% endif %}
10+
{% if property.static %}* This property is **static**.{% endif %}
11+
{% if property.deprecated %}* **Warning:** this property is **deprecated**. This means that this property will likely be removed in a future version.{% endif %}
12+
{% if property.tags.see is not empty or property.tags.link is not empty %}
13+
{% for see in property.tags.see %}
14+
* {{ see.reference }} {% if see.description %}- {{ see.description | raw }}{% endif %}
15+
{% endfor %}
16+
{% for link in property.tags.link %}
17+
* {{ link.link }} {% if link.description and link.description != link.link %}- {{ link.description | raw }}{% endif %}
18+
{% endfor %}
19+
{% endif %}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<template>
3+
<name>markdown</name>
4+
<author>Sakri Koskimies</author>
5+
<email>[email protected]</email>
6+
<version>0.0.2</version>
7+
<transformations>
8+
<transformation writer="twig" query="indexes.classes" source="class.md.twig"
9+
artifact="classes/{{FullyQualifiedStructuralElementName}}.md"/>
10+
</transformations>
11+
<parameters>
12+
<parameter key="twig-debug">true</parameter>
13+
</parameters>
14+
</template>

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
.phpdoc
12
.DS_Store
23
.env
34
.env.testing
45
.phpunit.result.cache
6+
ast.dump
57
composer.lock
68
phpstan.neon
79
src/logs

DEPLOYMENT.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ We follow [Semantic Versioning](https://semver.org/).
1616

1717
## Run phpDocumentor
1818

19-
We use [phpDocumentor](https://www.phpdoc.org/) to automatically generate the [PHP SDK documentation](./docs/classes/ConvertKit_API/ConvertKit_API.md).
19+
We use [phpDocumentor](https://www.phpdoc.org/), with a custom markdown template, to automatically generate the [PHP SDK documentation](./docs/classes/ConvertKit_API/ConvertKit_API.md).
2020

2121
In a Terminal window, run the phpDocumentor command to generate documentation in markdown format:
2222

2323
```bash
24-
phpDocumentor --directory=src --target=docs --template="vendor/saggre/phpdocumentor-markdown/themes/markdown"
24+
phpDocumentor --directory=src --target=docs --template=".github/phpdoc-template"
2525
```
2626

27+
Markdown is generated using Twig. Changes can be made to the template files in the `.github/phpdoc-template` folder.
28+
2729
## Commit Changes
2830

2931
Commit the updated files, which should comprise of:

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
}
3232
},
3333
"minimum-stability": "dev",
34-
"prefer-stable": true
35-
}
34+
"prefer-stable": true,
35+
"scripts": {
36+
"create-docs": "phpDocumentor --directory=src --target=docs --template='vendor/saggre/phpdocumentor-markdown/themes/markdown'"
37+
}
38+
}

0 commit comments

Comments
 (0)