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.
This commit is contained in:
Anton Bachin 2017-10-11 09:39:46 -05:00
parent 08050696fb
commit 48d9be2d00
1 changed files with 21 additions and 12 deletions

View File

@ -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 {|<a href="%s/index.html">%s</a>|} key key in
let pkg = match data.Package.version_from_opam_file with
| None -> name
| Some v -> sp {|%s <span class="version">%s</span>|} name v
in
sp "<li>%s</li>" 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 {|<a href="%s/index.html">%s</a>|} name name in
let version_suffix =
match public_info.package.Package.version_from_opam_file with
| None ->
""
| Some v ->
sp {| <span class="version">%s</span>|} v
in
Some (sp "<li>%s%s</li>" 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 {|<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
@ -212,7 +221,7 @@ let setup_toplevel_index_rule sctx =
</ol>
</body>
</html>
|} packages
|} list_items
in
let context = SC.context sctx in
let doc_dir = doc_dir ~context in