Allow libraries in a package to reference each other in odocs

This allows for circular dependencies for libraries in the same package

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-06-07 14:35:53 +07:00
parent c842c76036
commit 724acc8c7c
2 changed files with 13 additions and 10 deletions

View File

@ -353,21 +353,24 @@ module Gen (S : sig val sctx : SC.t end) = struct
| Ok lib -> SC.load_dir sctx ~dir:(Lib.src_dir lib)
end
| "_html" :: lib_unique_name_or_pkg :: _ ->
let setup_html_rules pkg =
setup_pkg_html_rules ~pkg ~libs:(
Lib.Set.to_list (load_all_odoc_rules_pkg ~pkg)
) in
(* TODO we can be a better with the error handling in the case where
lib_unique_name_or_pkg is neither a valid pkg or lnu *)
let lib, lib_db = SC.Scope_key.of_string sctx lib_unique_name_or_pkg in
let setup_pkg_html_rules pkg =
setup_pkg_html_rules ~pkg ~libs:(
Lib.Set.to_list (load_all_odoc_rules_pkg ~pkg)) in
begin match Lib.DB.find lib_db lib with
| Error _ -> ()
| Ok lib -> setup_lib_html_rules lib ~requires:(Lib.closure [lib])
| Ok lib ->
begin match Lib.package lib with
| None -> setup_lib_html_rules lib ~requires:(Lib.closure [lib])
| Some pkg -> setup_pkg_html_rules pkg
end
end;
Option.iter
(Package.Name.Map.find (SC.packages sctx)
(Package.Name.of_string lib_unique_name_or_pkg))
~f:(fun pkg -> setup_html_rules pkg.name)
~f:(fun pkg -> setup_pkg_html_rules pkg.name)
| _ -> ()
let setup_package_aliases (pkg : Package.t) =

View File

@ -6,6 +6,9 @@
odoc _doc/_odoc/pkg/bar/page-index.odoc
odoc _doc/_html/bar/index.html
odoc _doc/_html/odoc.css
ocamldep foo_byte.ml.d
ocamlc .foo_byte.objs/foo_byte.{cmi,cmo,cmt}
odoc _doc/_odoc/lib/foo.byte/foo_byte.odoc
ocamldep foo.ml.d
ocamlc .foo.objs/foo.{cmi,cmo,cmt}
odoc _doc/_odoc/lib/foo/foo.odoc
@ -13,12 +16,9 @@
ocamlc .foo.objs/foo2.{cmi,cmo,cmt}
odoc _doc/_odoc/lib/foo/foo2.odoc
odoc _doc/_html/foo/Foo/.jbuilder-keep,_doc/_html/foo/Foo/index.html
ocamldep foo_byte.ml.d
ocamlc .foo_byte.objs/foo_byte.{cmi,cmo,cmt}
odoc _doc/_odoc/lib/foo.byte/foo_byte.odoc
odoc _doc/_html/foo/Foo_byte/.jbuilder-keep,_doc/_html/foo/Foo_byte/index.html
odoc _doc/_odoc/pkg/foo/page-index.odoc
odoc _doc/_html/foo/index.html
odoc _doc/_html/foo/Foo_byte/.jbuilder-keep,_doc/_html/foo/Foo_byte/index.html
odoc _doc/_html/foo/Foo2/.jbuilder-keep,_doc/_html/foo/Foo2/index.html
$ dune runtest --display short
<!DOCTYPE html>