From d28c6e4456bf4d4950c215a94483f94361e03213 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 16 Feb 2018 16:22:28 +0700 Subject: [PATCH] Change @doc to only build public docs Private docs can still be built using the new @doc-private alias --- src/build_system.ml | 13 +++++++------ src/build_system.mli | 11 ++++++----- src/odoc.ml | 16 +++++++++++----- .../test-cases/multiple-private-libs/run.t | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/build_system.ml b/src/build_system.ml index cb69ad36..7edfc2f1 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -225,7 +225,7 @@ module Alias0 = struct let dep t = Build.path (stamp_file t) let is_standard = function - | "runtest" | "install" | "doc" | "lint" -> true + | "runtest" | "install" | "doc" | "doc-private" | "lint" -> true | _ -> false open Build.O @@ -272,11 +272,12 @@ module Alias0 = struct It is not defined in %s or any of its descendants." name (Path.to_string_maybe_quoted src_dir) - let default = make "DEFAULT" - let runtest = make "runtest" - let install = make "install" - let doc = make "doc" - let lint = make "lint" + let default = make "DEFAULT" + let runtest = make "runtest" + let install = make "install" + let doc = make "doc" + let private_doc = make "doc-private" + let lint = make "lint" end module Dir_status = struct diff --git a/src/build_system.mli b/src/build_system.mli index 58cd8b8b..974dfebf 100644 --- a/src/build_system.mli +++ b/src/build_system.mli @@ -100,11 +100,12 @@ module Alias : sig val fully_qualified_name : t -> Path.t - val default : dir:Path.t -> t - val runtest : dir:Path.t -> t - val install : dir:Path.t -> t - val doc : dir:Path.t -> t - val lint : dir:Path.t -> t + val default : dir:Path.t -> t + val runtest : dir:Path.t -> t + val install : dir:Path.t -> t + val doc : dir:Path.t -> t + val private_doc : dir:Path.t -> t + val lint : dir:Path.t -> t (** Return the underlying stamp file *) val stamp_file : t -> Path.t diff --git a/src/odoc.ml b/src/odoc.ml index 4d6008de..6fe0c1b5 100644 --- a/src/odoc.ml +++ b/src/odoc.ml @@ -200,7 +200,11 @@ let setup_library_rules sctx (lib : Library.t) ~dir ~modules ~mld_files to_html sctx m odoc_file ~doc_dir ~odoc ~dir ~includes ~lib) in let doc_root = SC.Doc.root sctx in - SC.add_alias_deps sctx (Build_system.Alias.doc ~dir) + let alias = + match lib.public with + | None -> Build_system.Alias.private_doc ~dir + | Some _ -> Build_system.Alias.doc ~dir in + SC.add_alias_deps sctx alias (css_file ~doc_dir:doc_root :: toplevel_index ~doc_dir:doc_root :: html_files) @@ -268,15 +272,17 @@ let gen_rules sctx ~dir:_ rest = setup_toplevel_index_rule sctx | lib :: _ -> let libs = SC.libs sctx in - let (lib, scope) = + let (lib, scope, alias) = match String.rsplit2 lib ~on:'@' with - | None -> (lib, Lib_db.external_scope libs) - | Some (lib, name) -> (lib, Lib_db.find_scope_by_name_exn libs ~name) + | None -> + (lib, Lib_db.external_scope libs, "doc") + | Some (lib, name) -> + (lib, Lib_db.find_scope_by_name_exn libs ~name, "doc-private") in let scope = { With_required_by. data = scope - ; required_by = [Alias (Path.of_string "doc")] + ; required_by = [Alias (Path.of_string alias)] } in let open Option.Infix in Option.iter (Lib_db.Scope.find scope lib >>= Lib.src_dir) diff --git a/test/blackbox-tests/test-cases/multiple-private-libs/run.t b/test/blackbox-tests/test-cases/multiple-private-libs/run.t index d63b4e07..448e8e44 100644 --- a/test/blackbox-tests/test-cases/multiple-private-libs/run.t +++ b/test/blackbox-tests/test-cases/multiple-private-libs/run.t @@ -1,6 +1,6 @@ This test checks that there is no clash when two private libraries have the same name - $ $JBUILDER build -j1 --display short --root . @doc + $ $JBUILDER build -j1 --display short --root . @doc-private odoc _doc/odoc.css odoc _doc/test@a/page-index.odoc ocamldep a/test.ml.d