Merge pull request #670 from rgrinberg/fix-odoc-lazy-load

Fix odoc lazy load
This commit is contained in:
Rudi Grinberg 2018-04-03 00:09:41 +08:00 committed by GitHub
commit 271063891b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 11 deletions

View File

@ -501,17 +501,19 @@ module Gen (S : sig val sctx : SC.t end) = struct
in
SC.packages sctx
|> Package.Name.Map.iter ~f:(fun (pkg : Package.t) ->
SC.on_load_dir sctx
~dir:(Paths.odocs (Pkg pkg.name))
~f:(fun () ->
setup_package_odoc_rules
~pkg
~mlds:(
docs_by_package pkg
|> List.concat_map ~f:(fun (dir, doc) -> mlds_of_dir doc ~dir)
)
~entry_modules_by_lib:modules_by_lib
);
let rules = lazy (
setup_package_odoc_rules
~pkg
~mlds:(
docs_by_package pkg
|> List.concat_map ~f:(fun (dir, doc) -> mlds_of_dir doc ~dir)
)
~entry_modules_by_lib:modules_by_lib
) in
List.iter [ Paths.odocs (Pkg pkg.name)
; Paths.gen_mld_dir pkg ]
~f:(fun dir ->
SC.on_load_dir sctx ~dir ~f:(fun () -> Lazy.force rules));
(* setup @doc to build the correct html for the package *)
setup_package_aliases pkg;
);

View File

@ -16,3 +16,8 @@
((name runtest)
(deps (_doc/_html/index.html))
(action (echo "${read:_doc/_html/index.html}"))))
(alias
((name foo-mld)
(deps (_doc/_mlds/foo/index.mld))
(action (echo "${read:_doc/_mlds/foo/index.mld}"))))

View File

@ -31,3 +31,9 @@
</div>
</body>
</html>
$ $JBUILDER build @foo-mld -j1 --display short --root .
{1 Library foo}
This library exposes the following toplevel modules: {!modules:Foo}.
{1 Library foo.byte}
This library exposes the following toplevel modules: {!modules:Foo_byte}.