From 0a57a02819ea9482d26eff62ccfd0b28165ceb86 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 1 Mar 2018 13:03:06 +0700 Subject: [PATCH] Add documentation stanza --- src/gen_rules.ml | 2 +- src/jbuild.ml | 21 +++++++++++++++++++++ src/jbuild.mli | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/gen_rules.ml b/src/gen_rules.ml index f5d3a151..acca6087 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -246,7 +246,7 @@ module Gen(P : Install_rules.Params) = struct match (dep : Jbuild.Lib_dep.t) with | Direct _ -> None | Select s -> Some s.result_fn) - | Alias _ | Provides _ | Install _ -> []) + | Documentation _ | Alias _ | Provides _ | Install _ -> []) |> String_set.of_list in String_set.union generated_files diff --git a/src/jbuild.ml b/src/jbuild.ml index 3afc2053..303acd78 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -1160,6 +1160,24 @@ module Copy_files = struct let v1 = String_with_vars.t end +module Documentation = struct + type t = + { package: Package.t + ; mld_files: Ordered_set_lang.t + } + + let v1 pkgs = + record + (Scope_info.package_field pkgs >>= fun package -> + field "mld_files" Ordered_set_lang.t ~default:Ordered_set_lang.standard + >>= fun mld_files -> + return + { package + ; mld_files + } + ) +end + module Stanza = struct type t = | Library of Library.t @@ -1170,6 +1188,7 @@ module Stanza = struct | Alias of Alias_conf.t | Copy_files of Copy_files.t | Menhir of Menhir.t + | Documentation of Documentation.t end module Stanzas = struct @@ -1219,6 +1238,8 @@ module Stanzas = struct raise (Include_loop (file, include_stack)); let sexps = Sexp.load ~fname:(Path.to_string file) ~mode:Many in parse pkgs sexps ~default_version:Jbuild_version.V1 ~file ~include_stack) + ; cstr "documentation" (Documentation.v1 pkgs @> nil) + (fun d -> [Documentation d]) ] and select diff --git a/src/jbuild.mli b/src/jbuild.mli index 05a989b2..82c5a64c 100644 --- a/src/jbuild.mli +++ b/src/jbuild.mli @@ -358,6 +358,13 @@ module Copy_files : sig } end +module Documentation : sig + type t = + { package : Package.t + ; mld_files : Ordered_set_lang.t + } +end + module Stanza : sig type t = | Library of Library.t @@ -368,6 +375,7 @@ module Stanza : sig | Alias of Alias_conf.t | Copy_files of Copy_files.t | Menhir of Menhir.t + | Documentation of Documentation.t end module Stanzas : sig