Skip to content

Commit

Permalink
[FEATURE] Introduce noindex option for confvals
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Mar 23, 2024
1 parent fb690b3 commit 3252d05
Show file tree
Hide file tree
Showing 227 changed files with 5,838 additions and 5,299 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<dl class="confval">
<dt id="{{ node.id }}">
<dt {%- if node.isNoindex == false %} id="{{ node.id }}"{% endif %}>
<code class="sig-name descname"><span class="pre">{{ node.plainContent }}</span></code></dt>
<dd>
<div class="line-block">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use phpDocumentor\Guides\Nodes\InlineCompoundNode;
use phpDocumentor\Guides\Nodes\LinkTargetNode;
use phpDocumentor\Guides\Nodes\Node;
use phpDocumentor\Guides\Nodes\OptionalLinkTargetsNode;

/**
* The confval directive configuration values.
Expand All @@ -25,7 +26,7 @@
*
* @extends CompoundNode<Node>
*/
final class ConfvalNode extends CompoundNode implements LinkTargetNode
final class ConfvalNode extends CompoundNode implements LinkTargetNode, OptionalLinkTargetsNode
{
public const LINK_TYPE = 'std:confval';

Expand All @@ -41,6 +42,7 @@ public function __construct(
private readonly InlineCompoundNode|null $default = null,
private readonly array $additionalOptions = [],
array $value = [],
private readonly bool $noindex = false,
) {
parent::__construct($value);
}
Expand Down Expand Up @@ -85,4 +87,9 @@ public function getAdditionalOptions(): array
{
return $this->additionalOptions;
}

public function isNoindex(): bool
{
return $this->noindex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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\SectionNode;
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -94,6 +95,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());
Expand Down
26 changes: 26 additions & 0 deletions packages/guides/src/Nodes/OptionalLinkTargetsNode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://phpdoc.org
*/

namespace phpDocumentor\Guides\Nodes;

/**
* Makes the implementing node an optional link target. If Noindex is true
* no references are generated, there is no entry in the objects index and no
* warning about duplicate ids.
*
* Used for example in https://sphinx-toolbox.readthedocs.io/en/stable/extensions/confval.html#directive-option-confval-noindex
*/
interface OptionalLinkTargetsNode extends LinkTargetNode
{
public function isNoindex(): bool;
}
Original file line number Diff line number Diff line change
@@ -1,149 +1,149 @@
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<title>Another Page - Bootstrap Theme</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<header class="">

<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">

<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">

<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a href="#" class="nav-link current active" aria-current="page">
Another Page
</a>
</li><li class="nav-item">
<a href="somePage.html" class="nav-link">
Some Page
</a>
</li><li class="nav-item">
<a href="subpages/index.html" class="nav-link">
Subpages
</a>
</li>
<ul class="level-">
<li class="nav-item">
<a href="#"
class="nav-link current active" aria-current="page">Another Page</a>
</li>
<li class="nav-item">
<a href="somePage.html"
class="nav-link">Some Page</a>
</li>
<li class="nav-item">
<a href="subpages/index.html"
class="nav-link">Subpages</a>
</li>
</ul>
</ul>

<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a href="yetAnotherPage.html" class="nav-link">
Yet Another Page
</a>
</li></ul>
<head>
<title>Another Page - Bootstrap Theme</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<header class="">
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">

<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a href="#" class="nav-link current active" aria-current="page">
Another Page
</a>
</li><li class="nav-item">
<a href="somePage.html" class="nav-link">
Some Page
</a>
</li><li class="nav-item">
<a href="subpages/index.html" class="nav-link">
Subpages
</a>
</li>
<ul class="level-">
<li class="nav-item">
<a href="#"
class="nav-link current active" aria-current="page">Another Page</a>
</li>
<li class="nav-item">
<a href="somePage.html"
class="nav-link">Some Page</a>
</li>
<li class="nav-item">
<a href="subpages/index.html"
class="nav-link">Subpages</a>
</li>
</ul>
</ul>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a href="yetAnotherPage.html" class="nav-link">
Yet Another Page
</a>
</li></ul>

</div>
</div>
</nav>
</header>
<main id="main-content">
<div class="container">
<div class="container">
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="menu-level-main">
<li>
<a href="#"
class="nav-link current active" aria-current="page">Another Page</a>
</li>
<li>
<a href="somePage.html"
class="nav-link">Some Page</a>
</li>
<li>
<a href="subpages/index.html"
class="nav-link">Subpages</a>
<ul class="level-1">
<li>
<a href="subpages/subpage1.html"
class="nav-link">Subpages 1</a>
</li>
<li>
<a href="subpages/subpage2.html"
class="nav-link">Subpages 2</a>
</li>
</ul>

</li>
</ul>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="menu-level-main">
<li>
<a href="yetAnotherPage.html"
class="nav-link">Yet Another Page</a>
</li>
</ul>
</nav>

</div>
<div class="col-lg-9">

<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Document Title</a></li>
<li class="breadcrumb-item"><a href="#">Another Page</a></li>
</ol>
</nav>
<!-- content start -->
</div>
</nav>
</header>
<main id="main-content">
<div class="container">
<div class="container">
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="menu-level-main">
<li>
<a href="#"
class="nav-link current active" aria-current="page">Another Page</a>
</li>
<li>
<a href="somePage.html"
class="nav-link">Some Page</a>
</li>
<li>
<a href="subpages/index.html"
class="nav-link">Subpages</a>
<ul class="level-1">
<li>
<a href="subpages/subpage1.html"
class="nav-link">Subpages 1</a>
</li>
<li>
<a href="subpages/subpage2.html"
class="nav-link">Subpages 2</a>
</li>
</ul>

</li>
</ul>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="menu-level-main">
<li>
<a href="yetAnotherPage.html"
class="nav-link">Yet Another Page</a>
</li>
</ul>
</nav>

<div class="section" id="another-page">
<h1>Another Page</h1>

<p>Lorem Ipsum Dolor.</p>

</div>
<!-- content end -->
</div>
</div>
</div>
<div class="col-lg-9">

<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Document Title</a></li>
<li class="breadcrumb-item"><a href="#">Another Page</a></li>
</ol>
</nav>
<!-- content start -->

<div class="section" id="another-page">
<h1>Another Page</h1>

<p>Lorem Ipsum Dolor.</p>

</div>
<!-- content end -->
</div>
</div>
</main>
<footer class="bg-primary text-light">
</div>
</div>
</main>
<footer class="bg-primary text-light">
<div class="container">

<p>Generated by <a href="https://www.phpdoc.org/">phpDocumentor</a>.</p>

<p>Generated by <a href="https://www.phpdoc.org/">phpDocumentor</a>.</p>

</div>
</div>
</footer>

<!-- Optional JavaScript; choose one of the two! -->

<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity_no="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity_no="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
-->
</body>
</html>
<!-- Optional JavaScript; choose one of the two! -->

<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity_no="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity_no="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
-->
</body>
</html>
Loading

0 comments on commit 3252d05

Please sign in to comment.