Skip to content

Commit

Permalink
Merge pull request #1925 from rgrinberg/fix-odoc-errors
Browse files Browse the repository at this point in the history
Promote odoc errors in dune
  • Loading branch information
rgrinberg authored Mar 10, 2019
2 parents bc77e6d + cc7505c commit 14b570b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ OPAMYES="true"; export OPAMYES

OPAM_VERSION="2.0.3"

ODOC="odoc.1.4.0"

TARGET="$1"; shift

case "$TARGET" in
Expand Down Expand Up @@ -50,7 +52,7 @@ case "$TARGET" in
opam init --disable-sandboxing
eval $(opam config env)
_boot/install/default/bin/dune runtest && \
opam install ocamlfind utop ppxlib odoc menhir ocaml-migrate-parsetree js_of_ocaml-ppx js_of_ocaml-compiler
opam install ocamlfind utop ppxlib $ODOC menhir ocaml-migrate-parsetree js_of_ocaml-ppx js_of_ocaml-compiler
opam remove dune jbuilder \
`opam list --depends-on jbuilder --installed --short` \
`opam list --depends-on dune --installed --short`
Expand Down Expand Up @@ -89,7 +91,7 @@ case "$TARGET" in
./_boot/install/default/bin/dune build @runtest-no-deps &> $RUNTEST_NO_DEPS
opam list
opam pin add dune . --no-action
opam install ocamlfind utop ppxlib odoc ocaml-migrate-parsetree js_of_ocaml-ppx js_of_ocaml-compiler
opam install ocamlfind utop ppxlib $ODOC ocaml-migrate-parsetree js_of_ocaml-ppx js_of_ocaml-compiler
echo -en "travis_fold:end:opam.deps\r"
fi
echo -en "travis_fold:end:dune.boot\r"
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.8.2 (10/03/2019)
------------------

- Fix auto-generated `index.mld`. Use correct headings for the listing. (#1925,
@rgrinberg, @aantron)

1.8.1 (08/03/2019)
------------------

Expand Down
8 changes: 5 additions & 3 deletions src/odoc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,15 @@ module Gen (S : sig val sctx : SC.t end) = struct
))
|> Lib.Map.of_list_exn

let default_index entry_modules =
let default_index ~(pkg : Package.t) entry_modules =
let b = Buffer.create 512 in
Printf.bprintf b "{0 %s index}\n"
(Package.Name.to_string pkg.name);
Lib.Map.to_list entry_modules
|> List.sort ~compare:(fun (x, _) (y, _) ->
Lib_name.compare (Lib.name x) (Lib.name y))
|> List.iter ~f:(fun (lib, modules) ->
Printf.bprintf b "{2 Library %s}\n" (Lib_name.to_string (Lib.name lib));
Printf.bprintf b "{1 Library %s}\n" (Lib_name.to_string (Lib.name lib));
Buffer.add_string b (
match modules with
| [ x ] ->
Expand Down Expand Up @@ -462,7 +464,7 @@ module Gen (S : sig val sctx : SC.t end) = struct
else
let entry_modules = entry_modules ~pkg in
let gen_mld = Paths.gen_mld_dir pkg ++ "index.mld" in
add_rule (Build.write_file gen_mld (default_index entry_modules));
add_rule (Build.write_file gen_mld (default_index ~pkg entry_modules));
String.Map.add mlds "index" gen_mld in
let odocs = List.map (String.Map.values mlds) ~f:(fun mld ->
compile_mld
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test index.
{0 Test index}
8 changes: 5 additions & 3 deletions test/blackbox-tests/test-cases/odoc/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@
</html>

$ dune build @foo-mld --display short
{2 Library foo}
{0 foo index}
{1 Library foo}
This library exposes the following toplevel modules:
{!modules:Foo Foo2}
{2 Library foo.byte}
{1 Library foo.byte}
The entry point of this library is the module:
{!module-Foo_byte}.

$ dune build @bar-mld --display short
{2 Library bar}
{0 bar index}
{1 Library bar}
The entry point of this library is the module:
{!module-Bar}.

0 comments on commit 14b570b

Please sign in to comment.