From a5db29c113fed0447d0aa6b877255e75068b54eb Mon Sep 17 00:00:00 2001 From: Paul-Elliot Date: Thu, 3 Oct 2024 12:14:36 +0200 Subject: [PATCH] Children order: Remove common root using ID not URL segments --- src/document/sidebar.ml | 9 +-------- src/model/sidebar.ml | 5 ++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/document/sidebar.ml b/src/document/sidebar.ml index f35fffa61d..5122b0f90e 100644 --- a/src/document/sidebar.ml +++ b/src/document/sidebar.ml @@ -11,9 +11,6 @@ module Toc : sig val of_lang : Odoc_model.Sidebar.PageToc.t -> t - val remove_common_root : t -> t - (** Returns the deepest subdir containing all files. *) - val to_sidebar : ?fallback:string -> (Url.Path.t * Inline.one -> Block.one) -> t -> Block.t end = struct @@ -56,10 +53,6 @@ end = struct in of_lang ~parent_id:None dir - let rec remove_common_root = function - | Item (_, [ d ]) -> remove_common_root d - | x -> x - let rec to_sidebar ?(fallback = "root") convert (Item (name, content)) = let name = match name with @@ -83,7 +76,7 @@ type t = { pages : pages list; libraries : library list } let of_lang (v : Odoc_model.Sidebar.t) = let pages = let page_hierarchy { Odoc_model.Sidebar.hierarchy_name; pages } = - let hierarchy = Toc.of_lang pages |> Toc.remove_common_root in + let hierarchy = Toc.of_lang pages in Some { name = hierarchy_name; pages = hierarchy } in Odoc_utils.List.filter_map page_hierarchy v.pages diff --git a/src/model/sidebar.ml b/src/model/sidebar.ml index a52501d3a7..4780cb9ba1 100644 --- a/src/model/sidebar.ml +++ b/src/model/sidebar.ml @@ -182,10 +182,13 @@ module PageToc = struct let contents = ordered @ unordered in (contents, index) + let rec remove_common_root (v : t) = + match v with [ (_, Dir v) ], None -> remove_common_root v | _ -> v + let of_list l = let dir = empty_t None in List.iter (add dir) l; - t_of_in_progress dir + t_of_in_progress dir |> remove_common_root end type toc = PageToc.t