Skip to content

Commit

Permalink
[BUGFIX] Warn when a directive has not title
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Apr 18, 2024
1 parent 91299e9 commit a157fb7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/RestructuredText/Directives/ConfvalDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
use phpDocumentor\Guides\RestructuredText\Parser\InlineParser;
use phpDocumentor\Guides\RestructuredText\Parser\Productions\Rule;
use phpDocumentor\Guides\RestructuredText\TextRoles\GenericLinkProvider;
use Psr\Log\LoggerInterface;

use function boolval;
use function in_array;
use function trim;

/**
* The confval directive configuration values.
Expand All @@ -41,6 +43,7 @@ public function __construct(
GenericLinkProvider $genericLinkProvider,
private readonly AnchorNormalizer $anchorReducer,
private readonly InlineParser $inlineParser,
private readonly LoggerInterface|null $logger = null,
) {
parent::__construct($startingRule);

Expand Down Expand Up @@ -71,6 +74,12 @@ protected function processSub(
$required = false;
$default = null;
$additionalOptions = [];
if (trim($directive->getData()) === '') {
if ($this->logger !== null) {
$this->logger->warning('A directive must have a title: .. confval:: [some_title]', $blockContext->getLoggerInformation());
}
}

if ($directive->hasOption('type')) {
$type = $this->inlineParser->parse($directive->getOption('type')->toString(), $blockContext);
}
Expand Down

0 comments on commit a157fb7

Please sign in to comment.