Skip to content

Commit

Permalink
Fix rendering of sidebar in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jonludlam committed Nov 18, 2024
1 parent 8152b86 commit 10cdc58
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/document/sidebar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ end = struct
in
let f name =
match name with
| Some url, _ when prune && is_prefix (parent url) current_url -> None
| Some url, _ when prune && not (is_prefix (parent url) current_url) ->
None
| v -> Some (convert v)
in
let root_entry = convert tree.Tree.node in
Expand Down
23 changes: 11 additions & 12 deletions test/roots_and_hierarchy/sidebar.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,22 @@
</ul>
</nav>

$ cat html/pkg/libname/Unit/index.html | grep odoc-global-toc -A 15
$ cat html/pkg/libname/Unit/X/index.html | grep odoc-global-toc -A 15
<nav class="odoc-toc odoc-global-toc">
<ul class="odoc-modules">
<li><b>Library <code>libname</code></b>
<ul><li><a href="#" class="current_unit">Unit</a></li></ul>
</li>
</ul><b>Documentation</b>
<ul class="odoc-pages">
<li><a href="../../index.html">Package <code>pkg</code></a>
<ul>
<li><a href="../../dir1/index.html">A directory</a>
<ul><li><a href="../../dir1/my_page.html">My page</a></li></ul>
</li><li><a href="../../file.html">File</a></li>
<li><a href="../index.html">Unit</a>
<ul>
<li><a href="#" class="current_unit">X</a>
<ul><li><a href="Y/index.html">Y</a></li>
<li><a href="#module-Z">Z</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</ul><b>Documentation</b>

$ odoc support-files -o html
$ cp -r html /tmp/html
12 changes: 12 additions & 0 deletions test/roots_and_hierarchy/sidebar.t/unit.ml
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
let x = 1

module X = struct

module Y = struct

type t = int

end

module Z = Y
end

0 comments on commit 10cdc58

Please sign in to comment.