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 @@ + +
+

Confval directive

+
+
+
+
+
+
Type: "Hello World"
+
Required: true
+
Custom Info: custom
+ +
+
+ +

This is the confval demo content!

+ +

Another paragraph.

+ +
+
+
+
+ diff --git a/tests/Integration/tests/confval/confval-no-title/expected/logs/warning.log b/tests/Integration/tests/confval/confval-no-title/expected/logs/warning.log new file mode 100644 index 000000000..07042ff0d --- /dev/null +++ b/tests/Integration/tests/confval/confval-no-title/expected/logs/warning.log @@ -0,0 +1 @@ +app.WARNING: A directive must have a title diff --git a/tests/Integration/tests/confval/confval-no-title/input/index.rst b/tests/Integration/tests/confval/confval-no-title/input/index.rst new file mode 100644 index 000000000..97feb3863 --- /dev/null +++ b/tests/Integration/tests/confval/confval-no-title/input/index.rst @@ -0,0 +1,12 @@ +Confval directive +================= + +.. confval:: + :type: :php:`string` + :default: ``"Hello World"`` + :required: true + :Custom Info: **custom** + + This is the confval ``demo`` content! + + Another paragraph. diff --git a/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html b/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html index ac142e833..2f55a1bda 100644 --- a/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html +++ b/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html @@ -1,11 +1,11 @@ -
-

Uml Directive

-
Figure 1-1: Application flow
-
Figure 1-1: Application flow
-
+
+

Uml Directive

+
Figure 1-1: Application flow
+
Figure 1-1: Application flow
+