Skip to content

Commit 7adbb76

Browse files
committed
phpdoc: Resync with 5.0
1 parent b1b7c64 commit 7adbb76

6 files changed

Lines changed: 153 additions & 17 deletions

File tree

tools/php_api_ref/.phpdoc/template/components/constant-signature.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<span class="phpdocumentor-signature__visibility">{{ node.visibility }} </span>
33
{% if node.final %}<span class="phpdocumentor-signature__final">final </span>{% endif %}
44
<span class="phpdocumentor-signature__type">{{ not node.type ? "mixed" : node.type|route('class:short')|join('|')|raw }} </span>
5-
<span class="phpdocumentor-signature__name">{{ node.name }}</span> = <span class="phpdocumentor-signature__default-value">{{ node.value | default('""') }}</span>
5+
<span class="phpdocumentor-signature__name">{{ node.name }}</span> = <span class="phpdocumentor-signature__default-value">{% if node.value.render starts with '\\Ibexa\\Contracts\\' %}{{ node.value|route('class:short') }}{% else %}{{ node.value | default('""') }}{% endif %}</span>
66
{% endapply %}{% endset %}
77

88
{% include 'components/signature.html.twig' with { code } %}

tools/php_api_ref/.phpdoc/template/components/method-arguments.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
</td>
2121
<td{{ argument.default is empty ? ' class="empty"' }}>
2222
{% if argument.default is not empty %}
23-
{% if 'self::' in argument.default %}
24-
{{ argument.default|replace({'self':argument.method|split('::')[0]})|route('class:short')|raw }}
23+
{% if 'self::' in argument.default.render %}
24+
{{ argument.default.render|replace({'\\self':argument.method|split('::')[0]})|route('class:short')|raw }}
25+
{% elseif argument.default.render starts with '\\Ibexa\\Contracts\\' %}
26+
{{ argument.default.render|route('class:short') }}
2527
{% else %}
2628
{{ argument.default }}
2729
{% endif %}

tools/php_api_ref/.phpdoc/template/components/method-signature.html.twig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
<span class="phpdocumentor-signature__argument__name">${{ argument.name }}</span>
1717
{% if argument.default is not null %}
1818
<span> = </span>
19-
<span class="phpdocumentor-signature__argument__default-value">{{ argument.default }}</span>
19+
<span class="phpdocumentor-signature__argument__default-value">
20+
{%- if argument.default.render starts with '\\Ibexa\\Contracts\\' -%}
21+
{{ argument.default.render|route('class:short') }}
22+
{%- else -%}
23+
{{ argument.default }}
24+
{%- endif -%}
25+
</span>
2026
<span> ]</span>
2127
{% endif %}
2228
</span>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% set is_nested = entry.children.count or entry.interfaces[0] is defined or entry.classes[0] is defined or entry.traits[0] is defined or entry.enums[0] is defined %}
2+
{% set url = entry|route("url")|raw %}
3+
{% set type = type|default('') %}
4+
5+
{% if type != 'namespace' or is_nested %}
6+
<li class="md-nav__item {{ is_nested ? 'md-nav__item--nested' : '' }}">
7+
<input class="md-nav__toggle md-toggle" data-md-toggle="nav-{{ nav_id }}" type="checkbox" id="nav-{{ nav_id }}" {{ expanded|default(false) ? 'checked' : ''}}>
8+
<label class="md-nav__link level-{{ depth }}" for="nav-{{ nav_id }}">
9+
{% if icon is defined and depth > 1 %}
10+
<img src="./images/{{ icon }}" alt="{{ icon }}" />
11+
{% endif %}
12+
{% if url %}
13+
<a href="{{ url }}" title="{{ title }}">
14+
{% endif %}
15+
{{ title }}
16+
{% if url %}
17+
</a>
18+
{% endif %}
19+
</label>
20+
{% if is_nested %}
21+
<nav class="md-nav" aria-label="{{ title }}" data-md-level="{{ depth }}">
22+
<label class="md-nav__link-title md-nav__link level-{{ depth }}" title="{{ node.name }}">
23+
{{ title }}
24+
</label>
25+
{% include 'components/menu.html.twig' with { entry, nav_id, depth: depth + 1, type: '' } %}
26+
</nav>
27+
{% endif %}
28+
</li>
29+
{% endif %}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{% if depth == 0 %}
2+
{% if entry.children.count > 0 %}
3+
{% for child in entry.children %}
4+
{% include 'components/menu-entry.html.twig' with {
5+
title: entry.name|shortFQSEN ~ ' ' ~ child.name|shortFQSEN,
6+
nav_id: nav_id ~ '-' ~ loop.index,
7+
expanded: true,
8+
entry: child,
9+
} %}
10+
{% endfor %}
11+
{% endif %}
12+
{% else %}
13+
14+
{% set index = 0 %}
15+
16+
{% if entry.children.count > 0 %}
17+
{% if depth > 1 %}
18+
<label class="md-nav__list-title md-nav__list-title--namespaces">
19+
Namespaces
20+
</label>
21+
{% endif %}
22+
<ul class="md-nav__list">
23+
{% for child in entry.children %}
24+
{% include 'components/menu-entry.html.twig' with {
25+
title: child.name|shortFQSEN,
26+
nav_id: nav_id ~ '-' ~ index,
27+
entry: child,
28+
expanded: false,
29+
icon: 'folder.svg',
30+
type: 'namespace',
31+
} %}
32+
33+
{% set index = index + 1 %}
34+
{% endfor %}
35+
</ul>
36+
{% endif %}
37+
38+
{% if entry.interfaces[0] is defined or entry.classes[0] is defined or entry.traits[0] is defined or entry.enums[0] is defined %}
39+
{% if depth > 1 %}
40+
<label class="md-nav__list-title">
41+
Interfaces, classes, traits, and enums
42+
</label>
43+
{% endif %}
44+
<ul class="md-nav__list">
45+
{% if entry.interfaces[0] is defined %}
46+
{% for element in entry.interfaces|sort_asc %}
47+
{% include 'components/menu-entry.html.twig' with {
48+
title: element.name|shortFQSEN,
49+
nav_id: nav_id ~ '-' ~ index,
50+
entry: element,
51+
expanded: false,
52+
icon: 'file.svg',
53+
} %}
54+
55+
{% set index = index + 1 %}
56+
{% endfor %}
57+
{% endif %}
58+
{% if entry.classes[0] is defined %}
59+
{% for element in entry.classes|sort_asc %}
60+
{% include 'components/menu-entry.html.twig' with {
61+
title: element.name|shortFQSEN,
62+
nav_id: nav_id ~ '-' ~ index,
63+
entry: element,
64+
expanded: false,
65+
icon: 'file.svg',
66+
} %}
67+
68+
{% set index = index + 1 %}
69+
{% endfor %}
70+
{% endif %}
71+
{% if entry.traits[0] is defined %}
72+
{% for element in entry.traits|sort_asc %}
73+
{% include 'components/menu-entry.html.twig' with {
74+
title: element.name|shortFQSEN,
75+
nav_id: nav_id ~ '-' ~ index,
76+
entry: element,
77+
expanded: false,
78+
icon: 'file.svg',
79+
} %}
80+
81+
{% set index = index + 1 %}
82+
{% endfor %}
83+
{% endif %}
84+
{% if entry.enums[0] is defined %}
85+
{% for element in entry.enums|sort_asc %}
86+
{% include 'components/menu-entry.html.twig' with {
87+
title: element.name|shortFQSEN,
88+
nav_id: nav_id ~ '-' ~ index,
89+
entry: element,
90+
expanded: false,
91+
icon: 'file.svg',
92+
} %}
93+
94+
{% set index = index + 1 %}
95+
{% endfor %}
96+
{% endif %}
97+
</ul>
98+
{% endif %}
99+
{% endif %}

tools/php_api_ref/phpdoc.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
set +x;
44

55
AUTH_JSON=${1:-~/.composer/auth.json}; # Path to an auth.json file allowing to install the targeted edition and version
6-
OUTPUT_DIR=${2:-./docs/api/php_api/php_api_reference}; # Path to the directory where the built PHP API Reference is hosted
6+
PHP_API_OUTPUT_DIR=${2:-./docs/api/php_api/php_api_reference}; # Path to the directory where the built PHP API Reference is hosted
77

88
DXP_EDITION='commerce'; # Edition from and for which the Reference is built
99
DXP_VERSION='4.6.*'; # Version from and for which the Reference is built
1010
DXP_ADD_ONS=(connector-ai connector-openai automated-translation product-catalog-date-time-attribute rector discounts discounts-codes product-catalog-symbol-attribute collaboration share fieldtype-richtext-rte integrated-help cdp); # Packages not included in $DXP_EDITION but added to the Reference, listed without their vendor "ibexa"
1111
DXP_EDITIONS=(oss headless experience commerce); # Available editions ordered by ascending capabilities
1212
SF_VERSION='5.4'; # Symfony version used by Ibexa DXP
13-
PHPDOC_VERSION='3.8.0'; # Version of phpDocumentor used to build the Reference
13+
PHPDOC_VERSION='3.9.1'; # Version of phpDocumentor used to build the Reference
1414
PHPDOC_CONF="$(pwd)/tools/php_api_ref/phpdoc.dist.xml"; # Absolute path to phpDocumentor configuration file
1515
#PHPDOC_CONF="$(pwd)/tools/php_api_ref/phpdoc.dev.xml"; # Absolute path to phpDocumentor configuration file
16-
PHPDOC_TEMPLATE_VERSION='3.8.0'; # Version of the phpDocumentor base template set
16+
PHPDOC_TEMPLATE_VERSION='3.9.1'; # Version of the phpDocumentor base template set
1717
PHPDOC_DIR="$(pwd)/tools/php_api_ref/.phpdoc"; # Absolute path to phpDocumentor resource directory (containing the override template set)
1818

1919
PHP_BINARY="php -d error_reporting=`php -r 'echo E_ALL & ~E_DEPRECATED;'`"; # Avoid depreciation messages from phpDocumentor/Reflection/issues/529 when using PHP 8.2 or higher
@@ -22,16 +22,16 @@ FORCE_DXP_INSTALL=1; # If 1, empty the temporary directory, install DXP from scr
2222
BASE_DXP_BRANCH=''; # Branch from and for which the Reference is built when using a dev branch as version
2323
VIRTUAL_DXP_VERSION=''; # Version for which the reference is supposedly built when using dev branch as version
2424

25-
if [ ! -d $OUTPUT_DIR ]; then
26-
echo -n "Creating ${OUTPUT_DIR}";
27-
mkdir -p $OUTPUT_DIR;
25+
if [ ! -d $PHP_API_OUTPUT_DIR ]; then
26+
echo -n "Creating ${PHP_API_OUTPUT_DIR}";
27+
mkdir -p $PHP_API_OUTPUT_DIR;
2828
if [ $? -eq 0 ]; then
2929
echo 'OK';
3030
else
3131
exit 1;
3232
fi;
3333
fi;
34-
OUTPUT_DIR=$(realpath $OUTPUT_DIR); # Transform to absolute path before changing the working directory
34+
PHP_API_OUTPUT_DIR=$(realpath $PHP_API_OUTPUT_DIR); # Transform into absolute path before changing the working directory
3535

3636
if [ 1 -eq $FORCE_DXP_INSTALL ]; then
3737
echo 'Remove temporary directory…';
@@ -78,7 +78,7 @@ export COMPOSER_ROOT_VERSION=$DXP_VERSION;
7878

7979
if [ 0 -eq $DXP_ALREADY_EXISTS ]; then
8080
for additional_package in "${DXP_ADD_ONS[@]}"; do
81-
composer require --no-interaction --ignore-platform-reqs --no-scripts --with-all-dependencies ibexa/$additional_package:$DXP_VERSION
81+
composer require --no-interaction --ignore-platform-reqs --no-scripts --with-all-dependencies ibexa/$additional_package:$DXP_VERSION;
8282
done;
8383
fi;
8484

@@ -179,18 +179,18 @@ if [ $? -eq 0 ]; then
179179
./php_api_reference/js/searchIndex.js \
180180
> ./php_api_reference/js/searchIndex.new.js;
181181
mv -f ./php_api_reference/js/searchIndex.new.js ./php_api_reference/js/searchIndex.js;
182-
echo -n "Copy phpDocumentor output to ${OUTPUT_DIR}";
183-
cp -rf ./php_api_reference/* $OUTPUT_DIR;
182+
echo -n "Copy phpDocumentor output to ${PHP_API_OUTPUT_DIR}";
183+
cp -rf ./php_api_reference/* $PHP_API_OUTPUT_DIR;
184184
echo -n 'Remove surplus… ';
185185
while IFS= read -r line; do
186186
file="$(echo $line | sed -r 's/Only in (.*): (.*)/\1\/\2/')";
187-
if [[ $file = $OUTPUT_DIR/* ]]; then
187+
if [[ $file = $PHP_API_OUTPUT_DIR/* ]]; then
188188
rm -rf $file;
189189
fi;
190-
done <<< "$(diff -qr ./php_api_reference $OUTPUT_DIR | grep 'Only in ')";
190+
done <<< "$(diff -qr ./php_api_reference $PHP_API_OUTPUT_DIR | grep 'Only in ')";
191191
echo 'OK.';
192192
else
193-
echo 'A phpDocumentor error prevents reference update.';
193+
echo 'A phpDocumentor error prevents PHP Reference update.';
194194
exit 3;
195195
fi;
196196

0 commit comments

Comments
 (0)