From 3722872e1d70b212ba4d7d0ae3f4b2e73b2b3b97 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 19 Mar 2021 17:32:40 +0100 Subject: [PATCH] Consider "versionadded" as an admonition and improve "seealso" admonition --- src/Directive/VersionAddedDirective.php | 7 +++++-- .../html/directives/admonition.html.twig | 4 ++++ .../expected/blocks/directives/seealso.html | 17 ++++++++++------- .../blocks/directives/versionadded.html | 13 ++++++++++--- tests/fixtures/expected/main/datetime.html | 14 +++++++++++--- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/Directive/VersionAddedDirective.php b/src/Directive/VersionAddedDirective.php index 1461148..f47fb28 100644 --- a/src/Directive/VersionAddedDirective.php +++ b/src/Directive/VersionAddedDirective.php @@ -23,12 +23,15 @@ public function getName(): string public function processSub(Parser $parser, ?Node $document, string $variable, string $data, array $options): ?Node { $wrapperDiv = $parser->renderTemplate( - 'directives/version-added.html.twig', + 'directives/admonition.html.twig', [ + 'name' => 'versionadded', + 'text' => sprintf('New in version %s', $data), + 'class' => $options['class'] ?? null, 'version' => $data, ] ); - return $parser->getNodeFactory()->createWrapperNode($document, $wrapperDiv, ''); + return $parser->getNodeFactory()->createWrapperNode($document, $wrapperDiv, ''); } } diff --git a/src/Templates/default/html/directives/admonition.html.twig b/src/Templates/default/html/directives/admonition.html.twig index 82e33a6..19b0d3d 100644 --- a/src/Templates/default/html/directives/admonition.html.twig +++ b/src/Templates/default/html/directives/admonition.html.twig @@ -9,6 +9,10 @@ {% elseif name in ['caution', 'danger', 'error'] %} + {% elseif name in ['versionadded'] %} + + {% elseif name in ['seealso'] %} + {% endif %} {{ text }}

diff --git a/tests/fixtures/expected/blocks/directives/seealso.html b/tests/fixtures/expected/blocks/directives/seealso.html index 30f8cfa..ae9f807 100644 --- a/tests/fixtures/expected/blocks/directives/seealso.html +++ b/tests/fixtures/expected/blocks/directives/seealso.html @@ -8,10 +8,13 @@
-

- See also -

Also check out the homepage

-
- - - \ No newline at end of file +

+ + + + See also +

+

Also check out the homepage

+ + + diff --git a/tests/fixtures/expected/blocks/directives/versionadded.html b/tests/fixtures/expected/blocks/directives/versionadded.html index 649ca33..663039e 100644 --- a/tests/fixtures/expected/blocks/directives/versionadded.html +++ b/tests/fixtures/expected/blocks/directives/versionadded.html @@ -7,8 +7,15 @@ -
New in version 4.1:

This option was introduced in Symfony 2.6 and replaces another option, which is available prior to 2.6.

-
+
+

+ + + + New in version 4.1 +

+

This option was introduced in Symfony 2.6 and replaces another option, which is available prior to 2.6.

+
- \ No newline at end of file + diff --git a/tests/fixtures/expected/main/datetime.html b/tests/fixtures/expected/main/datetime.html index 41a6b1e..8d11e35 100644 --- a/tests/fixtures/expected/main/datetime.html +++ b/tests/fixtures/expected/main/datetime.html @@ -85,10 +85,15 @@

placeholder

-
New in version 2.6:

The placeholder option was introduced in Symfony 2.6 and replaces +

+

+ + + +New in version 2.6

+

The placeholder option was introduced in Symfony 2.6 and replaces empty_value, which is available prior to 2.6. -FormType Documentation

-
+FormType Documentation

type: string | array

If your widget option is set to choice, then this field will be represented as a series of select boxes. When the placeholder value is a string, @@ -110,6 +115,9 @@

+ + + See also

Also check out the homepage - Some Test Docs!. FormType Documentation