Skip to content

Commit 3096cd2

Browse files
committed
doc: Add the generate page 'API Reference'
This page lists the internal libraries and is generated by the driver.
1 parent 1eb8431 commit 3096cd2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

doc/driver.mld

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ let extra_docs = [
354354
"driver";
355355
"parent_child_spec";
356356
"features";
357-
"interface";
358357
"odoc_for_authors";
359358
"dune";
360359
"ocamldoc_differences";
360+
"api_reference";
361361
]
362362

363363
let parents =
@@ -571,12 +571,31 @@ let all_units =
571571
odoc_units @ lib_units |> List.flatten
572572
]}
573573

574+
Generate the {!api_reference} page to list Odoc's libraries:
575+
576+
{[
577+
let update_api_reference_page () =
578+
let libs =
579+
List.sort String.compare odoc_libraries
580+
|> List.map String.capitalize_ascii
581+
in
582+
OS.File.with_oc (Fpath.v "api_reference.mld") (fun oc () ->
583+
let pf = Printf.fprintf in
584+
pf oc "{0 API Reference}\n\n";
585+
List.iter (pf oc "- {!%s}\n") libs;
586+
Ok ()
587+
) ()
588+
|> get_ok
589+
|> get_ok
590+
]}
591+
574592
Now we'll compile all of the parent [.mld] files. To ensure that the parents are compiled before the children, we start with [odoc.mld], then [deps.mld], and so on. The result of this file is a list of the resulting [odoc] files.
575593

576594
{[
577595
let search_file = "index.js"
578596

579597
let compile_mlds () =
598+
update_api_reference_page ();
580599
let mkpage x = "page-\"" ^ x ^ "\"" in
581600
let mkmod x = "module-" ^ String.capitalize_ascii x in
582601
let mkmld x = Fpath.(add_ext "mld" (v x)) in
@@ -780,6 +799,7 @@ We can have a look at the produced hierarchy of files, which matches the desired
780799

781800
{@sh[
782801
$ ls html/odoc
802+
api_reference.html
783803
deps
784804
driver.html
785805
dune.html

doc/odoc.mld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ The main other pages of this site:
5454
- {!page-parent_child_spec} Parent/Child specification
5555
- {!page-interface} Interface guarantees
5656
- {!page-ocamlary} A demonstration of the rendering of most of the OCaml constructs
57-
57+
- {!page-api_reference} Odoc's library API

0 commit comments

Comments
 (0)