Skip to content

Commit b153499

Browse files
committed
[Console] Update some contents of the Tree helper
1 parent 2ea31b0 commit b153499

File tree

1 file changed

+57
-20
lines changed

1 file changed

+57
-20
lines changed

β€Žcomponents/console/helpers/tree.rst

+57-20
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,30 @@ You can build a tree by creating a new instance of the
105105
use Symfony\Component\Console\Helper\TreeHelper;
106106
use Symfony\Component\Console\Helper\TreeNode;
107107

108-
$node = TreeNode::fromValues([
109-
'Command',
110-
'Controller' => [
111-
'DefaultController.php',
112-
],
113-
'Kernel.php',
114-
]);
115-
$node->addChild('templates');
116-
$node->addChild('tests');
117-
118-
$tree = TreeHelper::createTree($io, $node);
108+
$root = new TreeNode('my-project/');
109+
// you can pass a string directly or create a TreeNode object
110+
$root->addChild('src/');
111+
$root->addChild(new TreeNode('templates/'));
112+
113+
// create nested structures by adding child nodes to other nodes
114+
$testsNode = new TreeNode('tests/');
115+
$functionalTestsNode = new TreeNode('Functional/');
116+
$testsNode->addChild($functionalTestsNode);
117+
$root->addChild(testsNode);
118+
119+
$tree = TreeHelper::createTree($io, $root);
119120
$tree->render();
120121

122+
This example outputs:
123+
124+
.. code-block:: terminal
125+
126+
my-project/
127+
β”œβ”€β”€ src/
128+
β”œβ”€β”€ templates/
129+
└── tests/
130+
└── Functional/
131+
121132
Customizing the Tree Style
122133
--------------------------
123134

@@ -133,7 +144,11 @@ output of the tree::
133144
$tree = TreeHelper::createTree($io, $node, [], TreeStyle::compact());
134145
$tree->render();
135146

136-
``TreeHelper::createTree($io, $node, [], TreeStyle::default())`` (`details`_)
147+
**Default**::
148+
149+
TreeHelper::createTree($io, $node, [], TreeStyle::default());
150+
151+
This outputs:
137152

138153
.. code-block:: terminal
139154
@@ -150,7 +165,11 @@ output of the tree::
150165
└── templates
151166
└── base.html.twig
152167
153-
``TreeHelper::createTree($io, $node, [], TreeStyle::box())`` (`details`_)
168+
**Box**:
169+
170+
TreeHelper::createTree($io, $node, [], TreeStyle::box());
171+
172+
This outputs:
154173

155174
.. code-block:: terminal
156175
@@ -167,7 +186,11 @@ output of the tree::
167186
β”—β•Έ templates
168187
β”—β•Έ base.html.twig
169188
170-
``TreeHelper::createTree($io, $node, [], TreeStyle::doubleBox())`` (`details`_)
189+
**Double box**::
190+
191+
TreeHelper::createTree($io, $node, [], TreeStyle::doubleBox());
192+
193+
This outputs:
171194

172195
.. code-block:: terminal
173196
@@ -184,7 +207,11 @@ output of the tree::
184207
β•šβ• templates
185208
β•šβ• base.html.twig
186209
187-
``TreeHelper::createTree($io, $node, [], TreeStyle::compact())`` (`details`_)
210+
**Compact**::
211+
212+
TreeHelper::createTree($io, $node, [], TreeStyle::compact());
213+
214+
This outputs:
188215

189216
.. code-block:: terminal
190217
@@ -201,7 +228,11 @@ output of the tree::
201228
β”” templates
202229
β”” base.html.twig
203230
204-
``TreeHelper::createTree($io, $node, [], TreeStyle::light())`` (`details`_)
231+
**Light**::
232+
233+
TreeHelper::createTree($io, $node, [], TreeStyle::light());
234+
235+
This outputs:
205236

206237
.. code-block:: terminal
207238
@@ -218,7 +249,11 @@ output of the tree::
218249
`-- templates
219250
`-- base.html.twig
220251
221-
``TreeHelper::createTree($io, $node, [], TreeStyle::minimal())`` (`details`_)
252+
**Minimal**::
253+
254+
TreeHelper::createTree($io, $node, [], TreeStyle::minimal());
255+
256+
This outputs:
222257

223258
.. code-block:: terminal
224259
@@ -235,7 +270,11 @@ output of the tree::
235270
. templates
236271
. base.html.twig
237272
238-
``TreeHelper::createTree($io, $node, [], TreeStyle::rounded())`` (`details`_)
273+
**Rounded**:
274+
275+
TreeHelper::createTree($io, $node, [], TreeStyle::rounded());
276+
277+
This outputs:
239278

240279
.. code-block:: terminal
241280
@@ -291,5 +330,3 @@ The above code will output the following tree:
291330
πŸ”΅ 🟒 🟠 🟑 Kernel.php
292331
πŸ”΅ 🟠 🟑 templates
293332
πŸ”΅ πŸ”΄ 🟠 🟑 base.html.twig
294-
295-
.. _`details`: https://github.com/symfony/symfony/blob/7.3/src/Symfony/Component/Console/Helper/TreeStyle.php

0 commit comments

Comments
Β (0)