Make imports/exports not be a dropdown in sidebar (#19907)
* Don't make a section be a dropdown if it has no child links * - Cleaned up code - Updated tests * Document what the 'if' is checking
This commit is contained in:
parent
094d86f997
commit
c43a377057
3 changed files with 23 additions and 9 deletions
|
|
@ -1474,9 +1474,20 @@ proc genSection(d: PDoc, kind: TSymKind, groupedToc = false) =
|
||||||
for item in d.tocSimple[kind].sorted(cmp):
|
for item in d.tocSimple[kind].sorted(cmp):
|
||||||
d.toc2[kind].add item.content
|
d.toc2[kind].add item.content
|
||||||
|
|
||||||
d.toc[kind] = getConfigVar(d.conf, "doc.section.toc") % [
|
let sectionValues = @[
|
||||||
"sectionid", $ord(kind), "sectionTitle", title,
|
"sectionID", $ord(kind), "sectionTitleID", $(ord(kind) + 50),
|
||||||
"sectionTitleID", $(ord(kind) + 50), "content", d.toc2[kind]]
|
"sectionTitle", title
|
||||||
|
]
|
||||||
|
|
||||||
|
# Check if the toc has any children
|
||||||
|
if d.toc2[kind] != "":
|
||||||
|
# Use the dropdown version instead and store the children in the dropdown
|
||||||
|
d.toc[kind] = getConfigVar(d.conf, "doc.section.toc") % (sectionValues & @[
|
||||||
|
"content", d.toc2[kind]
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
# Just have the link
|
||||||
|
d.toc[kind] = getConfigVar(d.conf, "doc.section.toc_item") % sectionValues
|
||||||
|
|
||||||
proc relLink(outDir: AbsoluteDir, destFile: AbsoluteFile, linkto: RelativeFile): string =
|
proc relLink(outDir: AbsoluteDir, destFile: AbsoluteFile, linkto: RelativeFile): string =
|
||||||
$relativeTo(outDir / linkto, destFile.splitFile().dir, '/')
|
$relativeTo(outDir / linkto, destFile.splitFile().dir, '/')
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,14 @@ doc.section = """
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Just a single item in the TOC (e.g. imports, exports)
|
||||||
|
doc.section.toc_item = """
|
||||||
|
<li>
|
||||||
|
<a class="reference reference-toplevel" href="#$sectionID" id="$sectionTitleID">$sectionTitle</a>
|
||||||
|
</li>
|
||||||
|
"""
|
||||||
|
|
||||||
|
# This is a section (e.g. procs, types) in the TOC which gets turned into a drop down
|
||||||
doc.section.toc = """
|
doc.section.toc = """
|
||||||
<li>
|
<li>
|
||||||
<details open>
|
<details open>
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,7 @@
|
||||||
</div>
|
</div>
|
||||||
<ul class="simple simple-toc" id="toc-list">
|
<ul class="simple simple-toc" id="toc-list">
|
||||||
<li>
|
<li>
|
||||||
<details open>
|
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||||
<summary><a class="reference reference-toplevel" href="#6" id="56">Imports</a></summary>
|
|
||||||
<ul class="simple simple-toc-section">
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<details open>
|
<details open>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue