Skip to content

Commit

Permalink
doc-new: Omit docs for 'empty libraries'
Browse files Browse the repository at this point in the history
In fact this is likely not an empty library, but a package that either doesn't
contain libraries or only contains sublibraries. In either case, it's not
at all useful to say a library exists and has no modules!

Fixes ocaml#10056

Signed-off-by: Jon Ludlam <jon@recoil.org>
  • Loading branch information
jonludlam committed Mar 27, 2024
1 parent 6a62109 commit b704fba
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/dune_rules/odoc_new.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1619,21 +1619,24 @@ let standard_index_contents b entry_modules =
entry_modules
|> List.sort ~compare:(fun (x, _) (y, _) -> Lib_name.compare x y)
|> List.iter ~f:(fun (lib, modules) ->
Printf.bprintf b "{1 Library %s}\n" (Lib_name.to_string lib);
Buffer.add_string
b
(match modules with
| [ x ] ->
sprintf
"The entry point of this library is the module:\n{!%s}.\n"
(Artifact.reference x)
| _ ->
sprintf
"This library exposes the following toplevel modules:\n{!modules:%s}\n"
(modules
|> List.map ~f:Artifact.name
|> List.sort ~compare:String.compare
|> String.concat ~sep:" ")))
match modules with
| [] -> () (* No library here! *)
| _ ->
Printf.bprintf b "{1 Library %s}\n" (Lib_name.to_string lib);
Buffer.add_string
b
(match modules with
| [ x ] ->
sprintf
"The entry point of this library is the module:\n{!%s}.\n"
(Artifact.reference x)
| _ ->
sprintf
"This library exposes the following toplevel modules:\n{!modules:%s}\n"
(modules
|> List.map ~f:Artifact.name
|> List.sort ~compare:String.compare
|> String.concat ~sep:" ")))
;;

let fallback_index_contents b entry_modules artifacts =
Expand Down

0 comments on commit b704fba

Please sign in to comment.