Skip to content

Commit

Permalink
[Yaml] prefix examples with #
Browse files Browse the repository at this point in the history
  • Loading branch information
tacman authored and fabpot committed Mar 22, 2024
1 parent 968d80c commit fd95a8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Expand Up @@ -170,7 +170,7 @@ private function writeNode(NodeInterface $node, ?NodeInterface $parentNode = nul

$this->writeLine('# '.$message.':', $depth * 4 + 4);

$this->writeArray(array_map(Inline::dump(...), $example), $depth + 1);
$this->writeArray(array_map(Inline::dump(...), $example), $depth + 1, true);
}

if ($children) {
Expand All @@ -191,7 +191,7 @@ private function writeLine(string $text, int $indent = 0): void
$this->reference .= sprintf($format, $text)."\n";
}

private function writeArray(array $array, int $depth): void
private function writeArray(array $array, int $depth, bool $asComment = false): void
{
$isIndexed = array_is_list($array);

Expand All @@ -201,11 +201,12 @@ private function writeArray(array $array, int $depth): void
} else {
$val = $value;
}
$prefix = $asComment ? '# ' : '';

if ($isIndexed) {
$this->writeLine('- '.$val, $depth * 4);
$this->writeLine($prefix.'- '.$val, $depth * 4);
} else {
$this->writeLine(sprintf('%-20s %s', $key.':', $val), $depth * 4);
$this->writeLine($prefix.sprintf('%-20s %s', $key.':', $val), $depth * 4);
}

if (\is_array($value)) {
Expand Down
Expand Up @@ -117,8 +117,8 @@ enum: ~ # One of "this"; "that"; Symfony\Component\Config\Tests\
variable:
# Examples:
- foo
- bar
# - foo
# - bar
parameters:
# Prototype: Parameter name
Expand Down

0 comments on commit fd95a8f

Please sign in to comment.