Skip to content

Commit 7f88e56

Browse files
committed
Merge remote-tracking branch 'origin/master'
* origin/master: Consider "versionadded" as an admonition and improve "seealso" admonition
2 parents ef3d738 + 052ca46 commit 7f88e56

File tree

5 files changed

+40
-15
lines changed

5 files changed

+40
-15
lines changed

src/Directive/VersionAddedDirective.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/version-added.html.twig',
26+
'directives/admonition.html.twig',
2727
[
28+
'name' => 'versionadded',
29+
'text' => sprintf('New in version %s', $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/Templates/default/html/directives/admonition.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
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>
14+
{% elseif name in ['seealso'] %}
15+
<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>
1216
{% endif %}
1317
{{ text }}
1418
</p>

tests/fixtures/expected/blocks/directives/seealso.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
<body>
1010
<div class="admonition admonition-seealso ">
11-
<p class="admonition-title">
12-
See also
13-
</p><p>Also check out the homepage</p>
14-
</div>
15-
16-
</body>
17-
</html>
11+
<p class="admonition-title">
12+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
13+
<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" />
14+
</svg>
15+
See also
16+
</p>
17+
<p>Also check out the homepage</p>
18+
</div>
19+
</body>
20+
</html>

tests/fixtures/expected/blocks/directives/versionadded.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77
</head>
88

99
<body>
10-
<div class="versionadded"><div><span class="versionmodified">New in version 4.1: </span><p>This option was introduced in Symfony 2.6 and replaces another option, which is available prior to 2.6.</p>
11-
</div></div>
10+
<div class="admonition admonition-versionadded ">
11+
<p class="admonition-title">
12+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
13+
<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>
14+
</svg>
15+
New in version 4.1
16+
</p>
17+
<p>This option was introduced in Symfony 2.6 and replaces another option, which is available prior to 2.6.</p>
18+
</div>
1219

1320
</body>
14-
</html>
21+
</html>

tests/fixtures/expected/main/datetime.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,15 @@ <h3 id="date-widget"><a class="headerlink" href="#date-widget" title="Permalink
8585
</div>
8686
<div class="section">
8787
<h3 id="placeholder"><a class="headerlink" href="#placeholder" title="Permalink to this headline">placeholder</a></h3>
88-
<div class="versionadded"><div><span class="versionmodified">New in version 2.6: </span><p>The <code translate="no" class="notranslate">placeholder</code> option was introduced in Symfony 2.6 and replaces
88+
<div class="admonition admonition-versionadded ">
89+
<p class="admonition-title">
90+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
91+
<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>
92+
</svg>
93+
New in version 2.6</p>
94+
<p>The <code translate="no" class="notranslate">placeholder</code> option was introduced in Symfony 2.6 and replaces
8995
<code translate="no" class="notranslate">empty_value</code>, which is available prior to 2.6.
90-
<a href="form/form_type.html#internal-reference" class="reference internal">FormType Documentation</a></p>
91-
</div></div>
96+
<a href="form/form_type.html#internal-reference" class="reference internal">FormType Documentation</a></p></div>
9297
<p><strong>type</strong>: <code translate="no" class="notranslate">string</code> | <code translate="no" class="notranslate">array</code></p>
9398
<p>If your widget option is set to <code translate="no" class="notranslate">choice</code>, then this field will be represented
9499
as a series of <code translate="no" class="notranslate">select</code> boxes. When the placeholder value is a string,
@@ -110,6 +115,9 @@ <h3 id="placeholder"><a class="headerlink" href="#placeholder" title="Permalink
110115
</div>
111116
<div class="admonition admonition-seealso ">
112117
<p class="admonition-title">
118+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
119+
<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" />
120+
</svg>
113121
See also
114122
</p><p>Also check out the homepage - <a href="index.html" class="reference internal">Some Test Docs!</a>.
115123
<a href="form/form_type.html#internal-reference" class="reference internal">FormType Documentation</a></p>

0 commit comments

Comments
 (0)