diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php
index 594562e51..5d8136f21 100644
--- a/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php
+++ b/packages/guides-restructured-text/src/RestructuredText/Directives/ConfvalDirective.php
@@ -83,6 +83,8 @@ protected function processSub(
$type = $this->inlineParser->parse($directive->getOption('default')->toString(), $blockContext);
}
+ $noindex = $directive->hasOption('noindex');
+
foreach ($directive->getOptions() as $option) {
if (in_array($option->getName(), ['type', 'required', 'default', 'noindex', 'name'], true)) {
continue;
@@ -91,6 +93,6 @@ protected function processSub(
$additionalOptions[$option->getName()] = $this->inlineParser->parse($option->toString(), $blockContext);
}
- return new ConfvalNode($id, $directive->getData(), $type, $required, $default, $additionalOptions, $collectionNode->getChildren());
+ return new ConfvalNode($id, $directive->getData(), $type, $required, $default, $additionalOptions, $collectionNode->getChildren(), $noindex);
}
}
diff --git a/packages/guides-restructured-text/src/RestructuredText/Nodes/ConfvalNode.php b/packages/guides-restructured-text/src/RestructuredText/Nodes/ConfvalNode.php
index 183e6ef36..75968d55d 100644
--- a/packages/guides-restructured-text/src/RestructuredText/Nodes/ConfvalNode.php
+++ b/packages/guides-restructured-text/src/RestructuredText/Nodes/ConfvalNode.php
@@ -15,7 +15,9 @@
use phpDocumentor\Guides\Nodes\CompoundNode;
use phpDocumentor\Guides\Nodes\InlineCompoundNode;
+use phpDocumentor\Guides\Nodes\LinkTargetNode;
use phpDocumentor\Guides\Nodes\Node;
+use phpDocumentor\Guides\Nodes\OptionalLinkTargetsNode;
use phpDocumentor\Guides\Nodes\PrefixedLinkTargetNode;
/**
@@ -25,7 +27,7 @@
*
* @extends CompoundNode
*/
-final class ConfvalNode extends CompoundNode implements PrefixedLinkTargetNode
+final class ConfvalNode extends CompoundNode implements LinkTargetNode, OptionalLinkTargetsNode, PrefixedLinkTargetNode
{
public const LINK_TYPE = 'std:confval';
public const LINK_PREFIX = 'confval-';
@@ -42,6 +44,7 @@ public function __construct(
private readonly InlineCompoundNode|null $default = null,
private readonly array $additionalOptions = [],
array $value = [],
+ private readonly bool $noindex = false,
) {
parent::__construct($value);
}
@@ -96,4 +99,9 @@ public function getPrefix(): string
{
return self::LINK_PREFIX;
}
+
+ public function isNoindex(): bool
+ {
+ return $this->noindex;
+ }
}
diff --git a/packages/guides/src/Compiler/NodeTransformers/CollectLinkTargetsTransformer.php b/packages/guides/src/Compiler/NodeTransformers/CollectLinkTargetsTransformer.php
index 1b48909d6..86781d49c 100644
--- a/packages/guides/src/Compiler/NodeTransformers/CollectLinkTargetsTransformer.php
+++ b/packages/guides/src/Compiler/NodeTransformers/CollectLinkTargetsTransformer.php
@@ -21,6 +21,7 @@
use phpDocumentor\Guides\Nodes\LinkTargetNode;
use phpDocumentor\Guides\Nodes\MultipleLinkTargetsNode;
use phpDocumentor\Guides\Nodes\Node;
+use phpDocumentor\Guides\Nodes\OptionalLinkTargetsNode;
use phpDocumentor\Guides\Nodes\PrefixedLinkTargetNode;
use phpDocumentor\Guides\Nodes\SectionNode;
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
@@ -95,6 +96,10 @@ public function enterNode(Node $node, CompilerContext $compilerContext): Node
}
if ($node instanceof LinkTargetNode) {
+ if ($node instanceof OptionalLinkTargetsNode && $node->isNoindex()) {
+ return $node;
+ }
+
$currentDocument = $this->documentStack->top();
Assert::notNull($currentDocument);
$anchor = $this->anchorReducer->reduceAnchor($node->getId());
diff --git a/packages/guides/src/Nodes/OptionalLinkTargetsNode.php b/packages/guides/src/Nodes/OptionalLinkTargetsNode.php
new file mode 100644
index 000000000..46453d573
--- /dev/null
+++ b/packages/guides/src/Nodes/OptionalLinkTargetsNode.php
@@ -0,0 +1,26 @@
+
+
+
Confval directive
+
+ -
+
demo
+ -
+
+
Type: "Hello World"
+
Required: true
+
Custom Info: custom
+
+
+
+
+
This is the confval demo
content!
+
+
Another paragraph.
+
+
+
+
+
+
See option demo.
+
+
+
diff --git a/tests/Integration/tests/confval/confval-noindex/expected/index.html b/tests/Integration/tests/confval/confval-noindex/expected/index.html
new file mode 100644
index 000000000..64ce88e77
--- /dev/null
+++ b/tests/Integration/tests/confval/confval-noindex/expected/index.html
@@ -0,0 +1,36 @@
+
+
+
Confval directive
+
+ -
+
demo
+ -
+
+
Type: "Hello World"
+
Required: true
+
Custom Info: custom
+
+
+
+
+
This is the confval demo
content!
+
+
Another paragraph.
+
+
+
+
+
+
See option demo.
+
+
+
+
+
+
diff --git a/tests/Integration/tests/confval/confval-noindex/expected/objects.inv.json b/tests/Integration/tests/confval/confval-noindex/expected/objects.inv.json
new file mode 100644
index 000000000..d3cc33c90
--- /dev/null
+++ b/tests/Integration/tests/confval/confval-noindex/expected/objects.inv.json
@@ -0,0 +1,32 @@
+{
+ "std:doc": {
+ "another": [
+ "-",
+ "-",
+ "another.html",
+ "Confval directive"
+ ],
+ "index": [
+ "-",
+ "-",
+ "index.html",
+ "Confval directive"
+ ]
+ },
+ "std:label": {
+ "confval-directive": [
+ "-",
+ "-",
+ "index.html#confval-directive",
+ "Confval directive"
+ ]
+ },
+ "std:confval": {
+ "demo": [
+ "-",
+ "-",
+ "index.html#demo",
+ "demo"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/tests/Integration/tests/confval/confval-noindex/input/another.rst b/tests/Integration/tests/confval/confval-noindex/input/another.rst
new file mode 100644
index 000000000..f1c28fcfd
--- /dev/null
+++ b/tests/Integration/tests/confval/confval-noindex/input/another.rst
@@ -0,0 +1,15 @@
+Confval directive
+=================
+
+.. confval:: demo
+ :type: :php:`string`
+ :default: ``"Hello World"``
+ :required: true
+ :Custom Info: **custom**
+ :noindex:
+
+ This is the confval ``demo`` content!
+
+ Another paragraph.
+
+See option :confval:`demo`.
\ No newline at end of file
diff --git a/tests/Integration/tests/confval/confval-noindex/input/index.rst b/tests/Integration/tests/confval/confval-noindex/input/index.rst
new file mode 100644
index 000000000..68c08f569
--- /dev/null
+++ b/tests/Integration/tests/confval/confval-noindex/input/index.rst
@@ -0,0 +1,19 @@
+Confval directive
+=================
+
+.. confval:: demo
+ :type: :php:`string`
+ :default: ``"Hello World"``
+ :required: true
+ :Custom Info: **custom**
+
+ This is the confval ``demo`` content!
+
+ Another paragraph.
+
+See option :confval:`demo`.
+
+.. toctree::
+ :glob:
+
+ *