Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function process(
);

return (new ContentMenuNode([$absoluteUrl]))
->withOptions($this->optionsToArray($options));
->withOptions($this->optionsToArray($options))
->withCaption($directive->getDataNode());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{% apply spaceless %}
<div class="contents">
{% if node.caption %}
<p class="topic-title">{{ renderNode(node.caption) }}</p>
{% endif %}
{% include "body/menu/menu-level.html.twig" %}
</div>
{% endapply %}
17 changes: 17 additions & 0 deletions packages/guides/src/Nodes/Menu/ContentMenuNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@

namespace phpDocumentor\Guides\Nodes\Menu;

use phpDocumentor\Guides\Nodes\InlineCompoundNode;

use function is_scalar;

/** @link https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#table-of-contents */
class ContentMenuNode extends MenuNode
{
private InlineCompoundNode|null $caption;

public function getDepth(): int
{
if ($this->hasOption('depth') && is_scalar($this->getOption('depth'))) {
Expand All @@ -31,4 +35,17 @@ public function isPageLevelOnly(): bool
{
return false;
}

public function getCaption(): InlineCompoundNode|null
{
return $this->caption;
}

public function withCaption(InlineCompoundNode|null $caption): ContentMenuNode
{
$that = clone $this;
$that->caption = $caption;

return $that;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="section" id="title">
<h1>Title</h1>

<div class="contents"><ul class="menu-level"><li class="toc-item"><a href="/contents-with-title.html#depth-level-1">Depth Level 1</a><ul class="section-level-1"><li class="toc-item"><a href="/contents-with-title.html#depth-level-2">Depth Level 2</a><ul class="section-level-1"><li class="toc-item"><a href="/contents-with-title.html#depth-level-3">Depth Level 3</a><ul class="section-level-2"><li class="toc-item"><a href="/contents-with-title.html#depth-level-4">Depth Level 4</a></li></ul></li></ul></li></ul></li></ul></div>
<div class="contents"><p class="topic-title"><strong>Table of Content</strong></p><ul class="menu-level"><li class="toc-item"><a href="/contents-with-title.html#depth-level-1">Depth Level 1</a><ul class="section-level-1"><li class="toc-item"><a href="/contents-with-title.html#depth-level-2">Depth Level 2</a><ul class="section-level-1"><li class="toc-item"><a href="/contents-with-title.html#depth-level-3">Depth Level 3</a><ul class="section-level-2"><li class="toc-item"><a href="/contents-with-title.html#depth-level-4">Depth Level 4</a></li></ul></li></ul></li></ul></li></ul></div>
<div class="section" id="depth-level-1">
<h2>Depth Level 1</h2>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Title
=====

.. contents:: Table of Content
.. contents:: **Table of Content**

Depth Level 1
-------------
Expand Down