Skip to content

Commit aac129e

Browse files
panglesdjonludlam
authored andcommitted
Driver: Fix hierarchical pages being given wrong parent id
Signed-off-by: Paul-Elliot <peada@free.fr>
1 parent f18d8b7 commit aac129e

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

src/driver/packages.ml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,32 @@ let of_libs libs =
297297
in
298298
ignore libname_of_archive;
299299
let mk_mlds pkg_name libraries odoc_pages =
300+
let prefix = Fpath.(v (Opam.prefix ()) / "doc" / pkg_name / "odoc-pages") in
300301
Fpath.Set.fold
301302
(fun mld_path acc ->
302-
let mld_parent_id = Printf.sprintf "%s/doc" pkg_name in
303-
let page_name = Fpath.(rem_ext mld_path |> filename) in
304-
let odoc_file =
305-
Fpath.(v mld_parent_id / ("page-" ^ page_name ^ ".odoc"))
306-
in
307-
let odocl_file = Fpath.(set_ext "odocl" odoc_file) in
308-
let mld_deps = List.map (fun l -> l.odoc_dir) libraries in
309-
{
310-
mld_odoc_file = odoc_file;
311-
mld_odocl_file = odocl_file;
312-
mld_parent_id;
313-
mld_path;
314-
mld_deps;
315-
}
316-
:: acc)
303+
let rel_path = Fpath.rem_prefix prefix mld_path in
304+
match rel_path with
305+
| None -> acc
306+
| Some rel_path ->
307+
let id = Fpath.(v pkg_name / "doc" // rel_path) in
308+
let mld_parent_id =
309+
Format.asprintf "%a" Fpath.pp
310+
(id |> Fpath.parent |> Fpath.rem_empty_seg)
311+
in
312+
let page_name = Fpath.(rem_ext mld_path |> filename) in
313+
let odoc_file =
314+
Fpath.(v mld_parent_id / ("page-" ^ page_name ^ ".odoc"))
315+
in
316+
let odocl_file = Fpath.(set_ext "odocl" odoc_file) in
317+
let mld_deps = List.map (fun l -> l.odoc_dir) libraries in
318+
{
319+
mld_odoc_file = odoc_file;
320+
mld_odocl_file = odocl_file;
321+
mld_parent_id;
322+
mld_path;
323+
mld_deps;
324+
}
325+
:: acc)
317326
odoc_pages []
318327
in
319328
let update_mlds mlds libraries =

0 commit comments

Comments
 (0)