From b704fbaa2fbac15db1c4f6a96478615def6e3993 Mon Sep 17 00:00:00 2001 From: Jon Ludlam Date: Wed, 27 Mar 2024 15:38:32 +0000 Subject: [PATCH] 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 #10056 Signed-off-by: Jon Ludlam --- src/dune_rules/odoc_new.ml | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/dune_rules/odoc_new.ml b/src/dune_rules/odoc_new.ml index f740f693440..75b2e583881 100644 --- a/src/dune_rules/odoc_new.ml +++ b/src/dune_rules/odoc_new.ml @@ -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 =