From 48d9be2d00a4773848d0a8054aec96e0f4621def Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Wed, 11 Oct 2017 09:39:46 -0500 Subject: [PATCH] Docs: list all libraries in top-level index This commit changes the top-level index of the docs generated by Jbuilder so that the index lists all installed libraries (Findlib library packages generated by Jbuilder), rather than only opam packages. For example, current Markup.ml installs libraries markup markup.lwt markup.lwt.unix With this change, all these libraries are listed in the index. Before this change, only markup was listed, because it happened to coincide with the name of the opam package that contains all three libraries. Not listing the extra libraries makes them undiscoverable, as they can only be reached by direct URL. --- src/odoc.ml | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/odoc.ml b/src/odoc.ml index 7e4ef035..5da8c1b5 100644 --- a/src/odoc.ml +++ b/src/odoc.ml @@ -183,18 +183,27 @@ let setup_css_rule sctx = let sp = Printf.sprintf let setup_toplevel_index_rule sctx = - let packages = - String_map.fold ~f:(fun ~key ~data pkgs -> - let name = sp {|%s|} key key in - let pkg = match data.Package.version_from_opam_file with - | None -> name - | Some v -> sp {|%s %s|} name v - in - sp "
  • %s
  • " pkg :: pkgs - ) ~init:[] (SC.packages sctx) - |> List.rev + let list_items = + Super_context.stanzas_to_consider_for_install sctx + |> List.filter_map ~f:(fun (_path, stanza) -> + match stanza with + | Stanza.Library + {Library.kind = Library.Kind.Normal; public = Some public_info; _} -> + let name = public_info.name in + let link = sp {|%s|} name name in + let version_suffix = + match public_info.package.Package.version_from_opam_file with + | None -> + "" + | Some v -> + sp {| %s|} v + in + Some (sp "
  • %s%s
  • " link version_suffix) + + | _ -> + None) in - let packages = String.concat ~sep:"\n " packages in + let list_items = String.concat ~sep:"\n " list_items in let html = sp {| @@ -212,7 +221,7 @@ let setup_toplevel_index_rule sctx = -|} packages +|} list_items in let context = SC.context sctx in let doc_dir = doc_dir ~context in