Skip to content

Commit ccb72c8

Browse files
committed
Update the style of versionadded and deprecated admonitions
1 parent d53d4b7 commit ccb72c8

File tree

10 files changed

+31
-15
lines changed

10 files changed

+31
-15
lines changed

src/Directive/DeprecatedDirective.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ public function getName(): string
2323
public function processSub(Parser $parser, ?Node $document, string $variable, string $data, array $options): ?Node
2424
{
2525
$wrapperDiv = $parser->renderTemplate(
26-
'directives/deprecated.html.twig',
26+
'directives/admonition.html.twig',
2727
[
28+
'name' => 'deprecated',
29+
'text' => $data,
30+
'class' => $options['class'] ?? null,
2831
'version' => $data,
2932
]
3033
);
3134

32-
return $parser->getNodeFactory()->createWrapperNode($document, $wrapperDiv, '</div></div>');
35+
return $parser->getNodeFactory()->createWrapperNode($document, $wrapperDiv, '</div>');
3336
}
3437
}

src/Directive/VersionAddedDirective.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function processSub(Parser $parser, ?Node $document, string $variable, st
2626
'directives/admonition.html.twig',
2727
[
2828
'name' => 'versionadded',
29-
'text' => sprintf('New in version %s', $data),
29+
'text' => $data,
3030
'class' => $options['class'] ?? null,
3131
'version' => $data,
3232
]

src/Templates/default/html/directives/admonition.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
1010
{% elseif name in ['caution', 'danger', 'error'] %}
1111
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
12-
{% elseif name in ['versionadded'] %}
13-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"></path></svg>
12+
{% elseif name in ['versionadded', 'deprecated'] %}
13+
{# don't show an icon for these directives #}
1414
{% elseif name in ['seealso'] %}
1515
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" /></svg>
1616
{% elseif name in ['screencast'] %}

src/Templates/default/html/directives/deprecated.html.twig

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/IntegrationTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ public function parserUnitBlockProvider()
180180
'blockName' => 'directives/best-practice',
181181
];
182182

183+
yield 'deprecated' => [
184+
'blockName' => 'directives/deprecated',
185+
];
186+
183187
yield 'versionadded' => [
184188
'blockName' => 'directives/versionadded',
185189
];
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="admonition admonition-deprecated ">
2+
<p class="admonition-title"><span>5.4</span></p>
3+
<p>The <code translate="no" class="notranslate">foobar</code> option is deprecated since Symfony 5.4. Use <code translate="no" class="notranslate">barfoo</code> instead.</p>
4+
</div>
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<div class="admonition admonition-versionadded ">
2-
<p class="admonition-title">
3-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewbox="0 0 24 24" stroke="currentColor">
4-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"></path>
5-
</svg>
6-
<span>New in version 4.1</span>
7-
8-
</p>
9-
<p>This option was introduced in Symfony 2.6 and replaces another option, which is available prior to 2.6.</p>
2+
<p class="admonition-title"><span>4.1</span></p>
3+
<p>The <code translate="no" class="notranslate">foobar</code> option was introduced in Symfony 4.1.</p>
4+
</div>

tests/fixtures/expected/blocks/nodes/tables.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</table>
2525
</div>
2626

27+
<div class="table-wrapper">
2728
<table>
2829
<thead>
2930
<tr>
@@ -42,7 +43,9 @@
4243
</tr>
4344
</tbody>
4445
</table>
46+
</div>
4547

48+
<div class="table-wrapper">
4649
<table>
4750
<thead>
4851
<tr>
@@ -61,6 +64,7 @@
6164
</tr>
6265
</tbody>
6366
</table>
67+
</div>
6468

6569
<p>Simple table headless:</p>
6670

@@ -81,6 +85,7 @@
8185
</table>
8286
</div>
8387

88+
<div class="table-wrapper">
8489
<table>
8590
<tbody>
8691
<tr>
@@ -93,6 +98,7 @@
9398
</tr>
9499
</tbody>
95100
</table>
101+
</div>
96102

97103
<p>Grid table:</p>
98104

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
.. deprecated:: 5.4
3+
4+
The ``foobar`` option is deprecated since Symfony 5.4. Use ``barfoo`` instead.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
.. versionadded:: 4.1
3-
This option was introduced in Symfony 2.6 and replaces another option, which is available prior to 2.6.
3+
4+
The ``foobar`` option was introduced in Symfony 4.1.

0 commit comments

Comments
 (0)