From 33452b34c21a4a37c27c1385a0cc71534d8436b2 Mon Sep 17 00:00:00 2001 From: Jon Ludlam Date: Fri, 29 Mar 2024 19:57:48 +0000 Subject: [PATCH] doc-new: Omit docs for 'empty libraries' (#10319) * 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 * Add changes Signed-off-by: Jon Ludlam --------- Signed-off-by: Jon Ludlam --- doc/changes/10319.md | 2 ++ src/dune_rules/odoc_new.ml | 33 ++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 doc/changes/10319.md diff --git a/doc/changes/10319.md b/doc/changes/10319.md new file mode 100644 index 00000000000..2cb2348551c --- /dev/null +++ b/doc/changes/10319.md @@ -0,0 +1,2 @@ +- Don't try to document non-existent libraries in doc-new target (#10319, + fixes #10056, @jonludlam) 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 =