Skip to content

Commit d909db1

Browse files
committed
Remove links from global classes and interfaces
1 parent 8932c04 commit d909db1

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

tests/Functional/expected/classes/PhpDocumentorMarkdown/Example/Pizza.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A pizza \| pie.
88
* Parent class: [`\PhpDocumentorMarkdown\Example\AbstractProduct`](./AbstractProduct.md)
99
* This class implements:
1010
[`\PhpDocumentorMarkdown\Example\ProductInterface`](./ProductInterface.md),
11-
`\JsonSerializable`
11+
`JsonSerializable`
1212

1313
## Properties
1414

tests/Unit/Twig/Macro/MacroTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,43 @@ public function testMdTable(string $expected, array $args): void
213213
$result = $this->renderTemplate('mdTable', $args);
214214
self::assertEquals(trim($expected), trim($result));
215215
}
216+
217+
public static function dataProviderTestMdNestingLevel(): array
218+
{
219+
return [
220+
[
221+
'expected' => 0,
222+
'args' => [''],
223+
],
224+
[
225+
'expected' => 0,
226+
'args' => ['/foo'],
227+
],
228+
[
229+
'expected' => 1,
230+
'args' => ['foo/bar'],
231+
],
232+
[
233+
'expected' => 2,
234+
'args' => ['foo/bar/baz'],
235+
],
236+
[
237+
'expected' => 3,
238+
'args' => ['foo/bar/baz/qux'],
239+
],
240+
[
241+
'expected' => 3,
242+
'args' => ['foo/bar/baz/qux/'],
243+
],
244+
];
245+
}
246+
247+
/**
248+
* @dataProvider dataProviderTestMdNestingLevel
249+
*/
250+
public function testMdNestingLevel(int $expected, array $args): void
251+
{
252+
$result = $this->renderTemplate('mdNestingLevel', $args);
253+
self::assertEquals($expected, $result);
254+
}
216255
}

tests/Unit/Twig/templates/macros.test.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@
2626
{% if key == 'mdTable' %}
2727
{{- macros.mdTable(args[0], args[1]) -}}
2828
{% endif %}
29+
{% if key == 'mdNestingLevel' %}
30+
{{- macros.mdNestingLevel(args[0]) -}}
31+
{% endif %}

themes/markdown/include/macros.twig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,12 @@
156156
{{ '|' ~ "\n" }}
157157
{%- endfor %}
158158
{% endmacro %}
159+
160+
{#
161+
# Calculate the nesting level of a given path
162+
# @param path string The path to analyze
163+
#}
164+
{% macro mdNestingLevel(path) %}
165+
{%- set normalized = path | replace({'\\': '/'}) | trim('/') -%}
166+
{{- normalized ? (normalized | split('/') | length - 1) : 0 -}}
167+
{% endmacro %}

themes/markdown/partials/inheritance.md.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
{%- else -%}
66
{{- ' ' -}}
77
{%- endif -%}
8-
{{- macros.mdLink(otherNode, macros.mdClassPath(node), otherNode.FullyQualifiedStructuralElementName, 'class') -}}
8+
{%- if '0' == macros.mdNestingLevel(otherNode.FullyQualifiedStructuralElementName) -%}
9+
{{- '`' ~ otherNode.FullyQualifiedStructuralElementName | default(otherNode.name) ~ '`' -}}
10+
{%- else -%}
11+
{{- macros.mdLink(otherNode, macros.mdClassPath(node), otherNode.FullyQualifiedStructuralElementName, 'class') -}}
12+
{%- endif -%}
913
{%- endfor -%}

0 commit comments

Comments
 (0)