diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php index 5d8136f21..321622c9f 100644 --- a/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php +++ b/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php @@ -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. @@ -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); @@ -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); } diff --git a/tests/Integration/tests/confval/confval-no-title/expected/index.html b/tests/Integration/tests/confval/confval-no-title/expected/index.html new file mode 100644 index 000000000..3a92d7bed --- /dev/null +++ b/tests/Integration/tests/confval/confval-no-title/expected/index.html @@ -0,0 +1,24 @@ + +
"Hello World"
This is the confval demo
content!
Another paragraph.
+ +