From 77c717b9afd1d19a5e6067187cef3105f3f70703 Mon Sep 17 00:00:00 2001 From: Thomas Refis Date: Fri, 23 Mar 2018 17:14:55 +0000 Subject: [PATCH] Cosmetic changes for default package entry point. --- src/gen_rules.ml | 4 +++- src/odoc.ml | 27 ++++++++++++++--------- test/blackbox-tests/test-cases/odoc/run.t | 10 ++++----- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 82c12406..773b132d 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -1018,7 +1018,9 @@ module Gen(P : Install_rules.Params) = struct Odoc.init ~modules_by_lib:(fun ~dir lib -> let m = modules_by_lib ~dir lib in match m.alias_module with - | Some m -> [m] + | Some alias_mod -> + [Option.value ~default:alias_mod + (Module.Name.Map.find m.modules m.main_module_name)] | None -> Module.Name.Map.values m.modules ) ~mlds_of_dir end diff --git a/src/odoc.ml b/src/odoc.ml index f3de11c4..555ba563 100644 --- a/src/odoc.ml +++ b/src/odoc.ml @@ -408,18 +408,23 @@ module Gen (S : sig val sctx : SC.t end) = struct |> List.sort ~compare:(fun (x, _) (y, _) -> String.compare (Lib.name x) (Lib.name y)) |> List.iter ~f:(fun (lib, modules) -> + Printf.bprintf b "{1 Library %s}\n" (Lib.name lib); Buffer.add_string b ( - sprintf - "{1 Library %s}\n\ - This library exposes the following toplevel modules:\n\ - {!modules:%s}\n" - (Lib.name lib) - (modules - |> List.sort ~compare:(fun x y -> - Module.Name.compare (Module.name x) (Module.name y)) - |> List.map ~f:(fun m -> Module.Name.to_string (Module.name m)) - |> String.concat ~sep:" ") - ) + match modules with + | [ x ] -> + sprintf + "The entry point of this library is the module:\n{!module-%s}.\n" + (Module.Name.to_string (Module.name x)) + | _ -> + sprintf + "This library exposes the following toplevel modules:\n\ + {!modules:%s}.\n" + (modules + |> List.sort ~compare:(fun x y -> + Module.Name.compare (Module.name x) (Module.name y)) + |> List.map ~f:(fun m -> Module.Name.to_string (Module.name m)) + |> String.concat ~sep:" ") + ); ); Buffer.contents b diff --git a/test/blackbox-tests/test-cases/odoc/run.t b/test/blackbox-tests/test-cases/odoc/run.t index 95e5c646..3d9e9df8 100644 --- a/test/blackbox-tests/test-cases/odoc/run.t +++ b/test/blackbox-tests/test-cases/odoc/run.t @@ -43,12 +43,12 @@ $ $JBUILDER build @foo-mld -j1 --display short --root . {1 Library foo} This library exposes the following toplevel modules: - {!modules:Foo Foo2} + {!modules:Foo Foo2}. {1 Library foo.byte} - This library exposes the following toplevel modules: - {!modules:Foo_byte} + The entry point of this library is the module: + {!module-Foo_byte}. $ $JBUILDER build @bar-mld -j1 --display short --root . {1 Library bar} - This library exposes the following toplevel modules: - {!modules:Bar} + The entry point of this library is the module: + {!module-Bar}.