My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix sidebar: flatten wrapper nodes before grouping, copy sidebar.json to _site

The sidebar JS now flattens single-child wrapper nodes (e.g. "OCaml package
documentation" > "reference") before applying package grouping, so it works
correctly with both 2-level and 3-level sidebar structures. Also copies
sidebar.json to _site/ in the deploy script, and removes unused
groupSidebarData function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+10 -17
+2
deploy-site.sh
··· 61 61 cp -rf "$DUNE_DOC/reference/"* "$SITE/reference/" 62 62 mkdir -p "$SITE/odoc.support/" 63 63 cp -rf "$DUNE_DOC/odoc.support/"* "$SITE/odoc.support/" 64 + # sidebar.json is fetched at runtime by the sidebar JS 65 + cp -f "$DUNE_DOC/sidebar.json" "$SITE/sidebar.json" 64 66 echo " assembled into $SITE/" 65 67 66 68 echo ""
+8 -17
odoc-jons-plugins/src/odoc_jons_plugins_js.ml
··· 69 69 return result.concat(ungrouped); 70 70 } 71 71 72 - // Apply grouping to the sidebar data tree. 73 - // The structure is: [root] -> [reference] -> [packages...] 74 - // We group the packages level. 75 - function groupSidebarData(data) { 76 - return data.map(function(entry) { 77 - var children = entry.children || []; 78 - return { 79 - node: entry.node, 80 - children: groupPackages(children) 81 - }; 82 - }); 83 - } 84 - 85 72 // Sidebar rendering 86 73 function renderEntry(entry) { 87 74 var node = entry.node; ··· 122 109 function initSidebar(data) { 123 110 var container = document.getElementById('sidebar-content'); 124 111 if (!container) return; 125 - var grouped = groupSidebarData(data); 126 - // Flatten the top-level wrapper (e.g. "OCaml package documentation") 127 - // since everything lives under it — render its children directly. 128 - var entries = grouped.length === 1 ? grouped[0].children : grouped; 112 + // Flatten single-child wrapper nodes (e.g. "OCaml package documentation" > 113 + // "reference") — they add nesting without value. 114 + var entries = data; 115 + while (entries.length === 1 && entries[0].children && entries[0].children.length > 0) { 116 + entries = entries[0].children; 117 + } 118 + // Group the packages into sections 119 + entries = groupPackages(entries); 129 120 var html = '<ul>' + entries.map(renderEntry).join('') + '</ul>'; 130 121 container.innerHTML = html; 131 122