Skip to content

Commit 0bf3893

Browse files
committed
.phpdoc/template/: Redo external links to GitHub using JS
1 parent cb1243e commit 0bf3893

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

tools/php_api_ref/.phpdoc/template/base.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{{ parent() }}
77

88
<script>
9+
window.symfonyVersion = '5.4';
910
window.addEventListener('keyup', (event) => {
1011
if (event.key === '/') {
1112
event.stopImmediatePropagation();

tools/php_api_ref/.phpdoc/template/class.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
{% block content %}
1010
{% include 'components/breadcrumbs.html.twig' %}
11-
{% include 'components/class-title.html.twig' with { symfony_version: symfony_version } %}
11+
{% include 'components/class-title.html.twig' %}
1212
{% include('components/element-header.html.twig') %}
1313
{% include 'components/constants.html.twig' %}
1414
{% include 'components/properties.html.twig' %}

tools/php_api_ref/.phpdoc/template/components/class-title.html.twig

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@
1414

1515
{% if node.parent %}
1616
<div class="content-header__subheader">
17-
{% if node.parent.__toString starts with '\\Symfony\\' %}
18-
Extends
19-
<a href="{{ 'https://github.com/symfony/symfony/blob/' ~ symfony_version ~ '/src' ~ node.parent|replace({'\\': '/'}) ~ '.php' }}" class="external">
20-
<abbr title="{{ node.parent }}">{{ node.parent.name }}</abbr>
21-
</a>
22-
{% else %}
23-
Extends {{ node.parent|route('class:short') }}
24-
{% endif %}
17+
Extends {{ node.parent|route('class:short') }}
2518
</div>
2619
{% endif %}
2720

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$(() => {
2+
$('abbr').each((index, element) => {
3+
let $this = $(element);
4+
let fqcn = $this.attr('title');
5+
if (fqcn.startsWith('\\Symfony\\') && 'a' != $this.parent().prop('tagName')) {
6+
let href = 'https://github.com/symfony/symfony/blob/' + symfonyVersion + '/src' + fqcn.replaceAll('\\', '/') + '.php';
7+
$this.wrap('<a href="' + href + '" class="external">');
8+
}
9+
});
10+
})

tools/php_api_ref/.phpdoc/template/layout.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@
6868
<script src="js/search_custom.js"></script>
6969
<script src="js/copy_to_clipboard.js"></script>
7070
<script src="js/version_switcher_custom.js"></script>
71+
<script src="js/external-links.js"></script>
7172
</body>
7273
</html>

tools/php_api_ref/.phpdoc/template/trait.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
{% block content %}
1010
{% include 'components/breadcrumbs.html.twig' %}
11-
{% include 'components/trait-title.html.twig' with { symfony_version: symfony_version } %}
11+
{% include 'components/trait-title.html.twig' %}
1212
{% include('components/element-header.html.twig') %}
1313
{% include 'components/constants.html.twig' %}
1414
{% include 'components/properties.html.twig' %}

0 commit comments

Comments
 (0)