Change @doc to only build public docs

Private docs can still be built using the new @doc-private alias
This commit is contained in:
Rudi Grinberg 2018-02-16 16:22:28 +07:00
parent 5669f57907
commit d28c6e4456
4 changed files with 25 additions and 17 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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