From 9d1697691af445b9fa45c1644fca5c694c66d970 Mon Sep 17 00:00:00 2001 From: Jon Ludlam Date: Fri, 22 Nov 2024 15:54:26 +0000 Subject: [PATCH] Driver: Put voodoo output under a doc directory --- src/driver/dune_style.ml | 1 + src/driver/odoc_unit.ml | 7 ++++--- src/driver/odoc_unit.mli | 3 ++- src/driver/odoc_units_of.ml | 4 ++-- src/driver/packages.ml | 3 +++ src/driver/packages.mli | 1 + src/driver/voodoo.ml | 5 ++++- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/driver/dune_style.ml b/src/driver/dune_style.ml index d1416cc3ef..d20b0f2026 100644 --- a/src/driver/dune_style.ml +++ b/src/driver/dune_style.ml @@ -125,6 +125,7 @@ let of_dune_build dir = selected = false; remaps = []; pkg_dir; + doc_dir = pkg_dir; other_docs = []; config = Global_config.empty; } ) diff --git a/src/driver/odoc_unit.ml b/src/driver/odoc_unit.ml index 894ad3a4e7..b46f528325 100644 --- a/src/driver/odoc_unit.ml +++ b/src/driver/odoc_unit.ml @@ -126,9 +126,10 @@ and pp : all_kinds unit Fmt.t = (Fmt.option pp_index) x.index pp_kind (x.kind :> all_kinds) -let doc_dir pkg = pkg.Packages.pkg_dir -let lib_dir pkg lib = Fpath.(pkg.Packages.pkg_dir / lib.Packages.lib_name) -let src_dir pkg = Fpath.(pkg.Packages.pkg_dir / "src") +let pkg_dir pkg = pkg.Packages.pkg_dir +let doc_dir pkg = pkg.Packages.doc_dir +let lib_dir pkg lib = Fpath.(doc_dir pkg / lib.Packages.lib_name) +let src_dir pkg = Fpath.(doc_dir pkg / "src") let src_lib_dir pkg lib = Fpath.(src_dir pkg / lib.Packages.lib_name) type dirs = { diff --git a/src/driver/odoc_unit.mli b/src/driver/odoc_unit.mli index 65b6b343a6..8141455b6e 100644 --- a/src/driver/odoc_unit.mli +++ b/src/driver/odoc_unit.mli @@ -55,10 +55,11 @@ type t = [ impl | intf | mld | asset | md ] unit val pp : t Fmt.t +val pkg_dir : Packages.t -> Fpath.t val lib_dir : Packages.t -> Packages.libty -> Fpath.t val doc_dir : Packages.t -> Fpath.t -val src_lib_dir : Packages.t -> Packages.libty -> Fpath.t val src_dir : Packages.t -> Fpath.t +val src_lib_dir : Packages.t -> Packages.libty -> Fpath.t type dirs = { odoc_dir : Fpath.t; diff --git a/src/driver/odoc_units_of.ml b/src/driver/odoc_units_of.ml index 947b88c974..1aed960c46 100644 --- a/src/driver/odoc_units_of.ml +++ b/src/driver/odoc_units_of.ml @@ -90,7 +90,7 @@ let packages ~dirs ~extra_paths ~remap ~gen_indices (pkgs : Packages.t list) : roots; output_file; json = false; - search_dir = pkg.pkg_dir; + search_dir = doc_dir pkg; sidebar = Some sidebar; } in @@ -225,7 +225,7 @@ let packages ~dirs ~extra_paths ~remap ~gen_indices (pkgs : Packages.t list) : let ext = Fpath.get_ext md in match ext with | ".md" -> - let rel_dir = doc_dir pkg in + let rel_dir = pkg_dir pkg in let kind = `Md in let name = md |> Fpath.rem_ext |> Fpath.basename |> ( ^ ) "page-" in let lib_deps = Util.StringSet.empty in diff --git a/src/driver/packages.ml b/src/driver/packages.ml index 160a816f42..57a17bf08e 100644 --- a/src/driver/packages.ml +++ b/src/driver/packages.ml @@ -91,6 +91,7 @@ type t = { remaps : (string * string) list; other_docs : Fpath.t list; pkg_dir : Fpath.t; + doc_dir : Fpath.t; config : Global_config.t; } @@ -407,6 +408,7 @@ let of_libs ~packages_dir libs = remaps = []; other_docs = []; pkg_dir; + doc_dir = pkg_dir; config; }) acc) @@ -490,6 +492,7 @@ let of_packages ~packages_dir packages = remaps; other_docs = []; pkg_dir; + doc_dir = pkg_dir; config; } acc) diff --git a/src/driver/packages.mli b/src/driver/packages.mli index 02176bbb72..f6a2d5e0e8 100644 --- a/src/driver/packages.mli +++ b/src/driver/packages.mli @@ -77,6 +77,7 @@ type t = { remaps : (string * string) list; other_docs : Fpath.t list; pkg_dir : Fpath.t; + doc_dir : Fpath.t; config : Global_config.t; } diff --git a/src/driver/voodoo.ml b/src/driver/voodoo.ml index dd2dc63e19..515cc3e786 100644 --- a/src/driver/voodoo.ml +++ b/src/driver/voodoo.ml @@ -179,6 +179,8 @@ let process_package pkg = |> List.flatten in let libraries = meta_libraries @ non_meta_libraries in + let pkg_dir = top_dir pkg in + let doc_dir = Fpath.(pkg_dir / "doc") in let result = { Packages.name = pkg.name; @@ -189,7 +191,8 @@ let process_package pkg = selected = true; remaps = []; other_docs; - pkg_dir = top_dir pkg; + pkg_dir; + doc_dir; config; } in