summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorJake Leahy <jake@leahy.dev>2022-07-17 07:41:18 +1000
committerGitHub <noreply@github.com>2022-07-16 17:41:18 -0400
commitc43a377057c56d5213eb298feba883363f2b2a26 (patch)
tree54db4270070a74f4438f9d6c3fa2d15bee51224e /compiler
parent094d86f99783f1366394fa444277c417dcbd1af3 (diff)
downloadNim-c43a377057c56d5213eb298feba883363f2b2a26.tar.gz
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
Diffstat (limited to 'compiler')
-rw-r--r--compiler/docgen.nim17
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index ed5fe06ef..d728c535f 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -1474,10 +1474,21 @@ proc genSection(d: PDoc, kind: TSymKind, groupedToc = false) =
     for item in d.tocSimple[kind].sorted(cmp):
       d.toc2[kind].add item.content
 
-  d.toc[kind] = getConfigVar(d.conf, "doc.section.toc") % [
-      "sectionid", $ord(kind), "sectionTitle", title,
-      "sectionTitleID", $(ord(kind) + 50), "content", d.toc2[kind]]
+  let sectionValues = @[
+     "sectionID", $ord(kind), "sectionTitleID", $(ord(kind) + 50),
+     "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 =
   $relativeTo(outDir / linkto, destFile.splitFile().dir, '/')