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 in
SC.packages sctx SC.packages sctx
|> Package.Name.Map.iter ~f:(fun (pkg : Package.t) -> |> Package.Name.Map.iter ~f:(fun (pkg : Package.t) ->
SC.on_load_dir sctx let rules = lazy (
~dir:(Paths.odocs (Pkg pkg.name)) setup_package_odoc_rules
~f:(fun () -> ~pkg
setup_package_odoc_rules ~mlds:(
~pkg docs_by_package pkg
~mlds:( |> List.concat_map ~f:(fun (dir, doc) -> mlds_of_dir doc ~dir)
docs_by_package pkg )
|> List.concat_map ~f:(fun (dir, doc) -> mlds_of_dir doc ~dir) ~entry_modules_by_lib:modules_by_lib
) ) in
~entry_modules_by_lib:modules_by_lib 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 @doc to build the correct html for the package *)
setup_package_aliases pkg; setup_package_aliases pkg;
); );

View File

@ -16,3 +16,8 @@
((name runtest) ((name runtest)
(deps (_doc/_html/index.html)) (deps (_doc/_html/index.html))
(action (echo "${read:_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> </div>
</body> </body>
</html> </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}.