Skip to content

Commit f9e8ba3

Browse files
authored
[FEATURE] JSON with class/interface API information (#682)
Outputs information about all classes/interfaces in the TYPO3 Core in the following form, so that it can be consumed by the guides for help texts etc: ``` "\\TYPO3\\CMS\\Adminpanel\\Log\\InMemoryLogWriter": { "url": "https://api.typo3.org/12.4/classes/TYPO3-CMS-Adminpanel-Log-InMemoryLogWriter.html", "short": "InMemoryLogWriter", "fqn": "\\TYPO3\\CMS\\Adminpanel\\Log\\InMemoryLogWriter", "github": "https://github.com/TYPO3/typo3/blob/12.4/typo3/sysext/adminpanel/Classes/Log/InMemoryLogWriter.php", "file": "typo3/sysext/adminpanel/Classes/Log/InMemoryLogWriter.php", "type": "class", "final": "1", "abstract": "", "readonly": "", "internal": "1", "internal-message": "", "deprecated": "", "deprecation": "", "extends": "\\TYPO3\\CMS\\Core\\Log\\Writer\\AbstractWriter", "implements": " \\TYPO3\\CMS\\Core\\SingletonInterface", "summary": "Log writer that writes the log records into a static public class variable for InMemory processing. Note this implements SingletonInterface so multiple calls to this class can accumulate log records in the same instance." } ```
1 parent 8d1db8a commit f9e8ba3

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{% set hasLooped = false %}
2+
{
3+
{% for element in documentationSet.indexes.classes -%}
4+
{% if loop.first and hasLooped %},{% endif %}
5+
{% set hasLooped = false %}
6+
{{ _self.link(project, element) }}
7+
{% if not loop.last -%},
8+
{% else %}
9+
{% set hasLooped = true %}
10+
{% endif %}
11+
{% endfor %}
12+
13+
{% for element in documentationSet.indexes.interfaces -%}
14+
{% if loop.first and hasLooped %},{% endif %}
15+
{% set hasLooped = false %}
16+
{{ _self.link(project, element) }}
17+
{% if not loop.last -%},
18+
{% else %}
19+
{% set hasLooped = true %}
20+
{% endif %}
21+
{% endfor %}
22+
23+
{% for element in documentationSet.indexes.traits -%}
24+
{% if loop.first and hasLooped %},{% endif %}
25+
{% set hasLooped = false %}
26+
{{ _self.link(project, element) }}
27+
{% if not loop.last -%},
28+
{% else %}
29+
{% set hasLooped = true %}
30+
{% endif %}
31+
{% endfor %}
32+
33+
{% for element in documentationSet.indexes.enums -%}
34+
{% if loop.first and hasLooped %},{% endif %}
35+
{% set hasLooped = false %}
36+
{{ _self.link(project, element) }}
37+
{% if not loop.last -%},
38+
{% else %}
39+
{% set hasLooped = true %}
40+
{% endif %}
41+
{% endfor %}
42+
43+
{% for element in documentationSet.indexes.functions -%}
44+
{% if loop.first and hasLooped %},{% endif %}
45+
{% set hasLooped = false %}
46+
{{ _self.link(project, element) }}
47+
{% if not loop.last -%},
48+
{% else %}
49+
{% set hasLooped = true %}
50+
{% endif %}
51+
{% endfor %}
52+
}
53+
54+
{% macro link(project, element) %}
55+
"{{ element.fullyQualifiedStructuralElementName|replace({'\\': '\\\\'}) }}": {
56+
{% set internalTags = element.tags|filter((v,k) => k in ['internal']) %}
57+
"url": "https://api.typo3.org/{{ parameter.typo3_version }}/{{ element | route('url') }}",
58+
"short": "{{ element.name|replace({'\\': '\\\\'}) }}",
59+
"fqn": "{{ element.fullyQualifiedStructuralElementName|replace({'\\': '\\\\'}) }}",
60+
"github": "{{ parameter.typo3_github_url }}/{{ parameter.typo3_version }}/{{ element.file.path }}",
61+
"file": "{{ element.file.path }}",
62+
"type": "{% if element is class %}class{% endif %}{% if element is interface %}interface{% endif %}{% if element is trait %}trait{% endif %}{% if element is enum %}enum{% endif %}",
63+
"final": "{{ element.isFinal }}",
64+
"abstract": "{{ element.isAbstract }}",
65+
"readonly": "{{ element.isReadonly }}",
66+
"internal": "{% if internalTags|length > 0 and internalTags|first|length > 0 %}1{% endif %}",
67+
"internal-message": "{% for tag in internalTags %}{{ tag.description|replace({'\\': '\\\\'})|replace({'\n': ' '})|replace({' ': ' '}) }}{% endfor %}",
68+
"deprecated": "{% if element.deprecated %}1{% endif %}",
69+
"deprecation": "{% for deprecation in element.deprecations %}{{ deprecation.description|replace({'\\': '\\\\'})|replace({'\n': ' '})|replace({' ': ' '})}} {% endfor %}",
70+
"extends": "{% if element.parent %}{{ element.parent.fullyQualifiedStructuralElementName|replace({'\\': '\\\\'})|replace({'\n': ' '})|replace({' ': ' '}) }}{% endif %}",
71+
"implements": "{% if element.interfaces is not empty -%}
72+
{%- for interface in element.interfaces %}{{ interface.fullyQualifiedStructuralElementName|replace({'\\': '\\\\'})|replace({'\n': ' '})|replace({' ': ' '}) }}{% if not loop.last %}, {% endif %}{% endfor -%}
73+
{% endif %}",
74+
"summary": "{{ element.summary|replace({'\\': '\\\\'})|replace({'\n': ' '})|replace({' ': ' '}) }}"
75+
}
76+
{% endmacro %}

packages/typo3-api/template/template.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<extends>default</extends>
88
<transformations>
99
<transformation writer="twig" source="index.json.twig" artifact="objects.inv.json"/>
10+
<transformation writer="twig" source="api-info.json.twig" artifact="api-info.json"/>
1011
<transformation writer="twig" source="404.html.twig" artifact="404.html"/>
1112
</transformations>
1213
</template>

0 commit comments

Comments
 (0)