Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Yaml] prefix examples with # #54326

Merged
merged 1 commit into from Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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