Skip to content

Commit

Permalink
doc-new: Omit docs for 'empty libraries' (ocaml#10319)
Browse files Browse the repository at this point in the history
* doc-new: Omit docs for 'empty libraries'

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>

* Add changes

Signed-off-by: Jon Ludlam <jon@recoil.org>

---------

Signed-off-by: Jon Ludlam <jon@recoil.org>
  • Loading branch information
jonludlam authored and Philip White committed Apr 2, 2024
1 parent ed42fce commit 6fe12f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions doc/changes/10319.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Don't try to document non-existent libraries in doc-new target (#10319,
fixes #10056, @jonludlam)
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 6fe12f4

Please sign in to comment.