diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 1c295257..d8e6fd6e 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -1013,7 +1013,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 86ee5e8e..30f5783e 100644 --- a/src/odoc.ml +++ b/src/odoc.ml @@ -409,18 +409,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 4140c0a4..5d4d79cf 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 --display short {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 --display short {1 Library bar} - This library exposes the following toplevel modules: - {!modules:Bar} + The entry point of this library is the module: + {!module-Bar}.