From fbc087edc17632d396de03e40bb93841db145549 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 9 Mar 2019 16:52:19 +0700 Subject: [PATCH 1/4] Fix odoc errors in dune tests Signed-off-by: Rudi Grinberg --- test/blackbox-tests/test-cases/github717-odoc-index/index.mld | 2 +- test/blackbox-tests/test-cases/odoc-unique-mlds/run.t | 2 ++ test/blackbox-tests/test-cases/odoc/run.t | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/blackbox-tests/test-cases/github717-odoc-index/index.mld b/test/blackbox-tests/test-cases/github717-odoc-index/index.mld index cf74479e4ca..9b3fbd3db35 100644 --- a/test/blackbox-tests/test-cases/github717-odoc-index/index.mld +++ b/test/blackbox-tests/test-cases/github717-odoc-index/index.mld @@ -1 +1 @@ -Test index. \ No newline at end of file +{1 Test index} \ No newline at end of file diff --git a/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t b/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t index e4daef4efa8..9ec72d23e4b 100644 --- a/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t +++ b/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t @@ -8,6 +8,8 @@ Duplicate mld's in the same scope odoc _doc/_odoc/lib/root.lib2/root_lib2.odoc odoc _doc/_html/root/Root_lib2/.dune-keep,_doc/_html/root/Root_lib2/index.html odoc _doc/_odoc/pkg/root/page-index.odoc + File "../../../_mlds/root/index.mld", line 3, characters 0-21: + '{2': heading level should be lower than top heading level '2'. odoc _doc/_html/root/index.html odoc _doc/_html/root/Root_lib1/.dune-keep,_doc/_html/root/Root_lib1/index.html diff --git a/test/blackbox-tests/test-cases/odoc/run.t b/test/blackbox-tests/test-cases/odoc/run.t index 42537a3200d..a0f3f9cab8a 100644 --- a/test/blackbox-tests/test-cases/odoc/run.t +++ b/test/blackbox-tests/test-cases/odoc/run.t @@ -17,6 +17,8 @@ odoc _doc/_odoc/lib/foo/foo2.odoc odoc _doc/_html/foo/Foo2/.dune-keep,_doc/_html/foo/Foo2/index.html odoc _doc/_odoc/pkg/foo/page-index.odoc + File "../../../_mlds/foo/index.mld", line 3, characters 0-20: + '{2': heading level should be lower than top heading level '2'. odoc _doc/_html/foo/index.html odoc _doc/_html/foo/Foo_byte/.dune-keep,_doc/_html/foo/Foo_byte/index.html odoc _doc/_html/foo/Foo/.dune-keep,_doc/_html/foo/Foo/index.html From 0e4278bd5c37d10cb677980309cdd5e7f13a50f8 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 9 Mar 2019 16:55:58 +0700 Subject: [PATCH 2/4] Force the latest version of odoc in travis Signed-off-by: Rudi Grinberg --- .travis-ci.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index e23d568a07b..aaee9010ddb 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -5,6 +5,8 @@ OPAMYES="true"; export OPAMYES OPAM_VERSION="2.0.3" +ODOC="odoc.1.4.0" + TARGET="$1"; shift case "$TARGET" in @@ -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` @@ -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" From 5d3cb4fe72dd82a06e56a64d0204fd88a3fd9f7d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 9 Mar 2019 22:54:54 +0700 Subject: [PATCH 3/4] Change title heading to 0 Signed-off-by: Rudi Grinberg --- test/blackbox-tests/test-cases/github717-odoc-index/index.mld | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blackbox-tests/test-cases/github717-odoc-index/index.mld b/test/blackbox-tests/test-cases/github717-odoc-index/index.mld index 9b3fbd3db35..958c6fc90fa 100644 --- a/test/blackbox-tests/test-cases/github717-odoc-index/index.mld +++ b/test/blackbox-tests/test-cases/github717-odoc-index/index.mld @@ -1 +1 @@ -{1 Test index} \ No newline at end of file +{0 Test index} \ No newline at end of file From cc7505cf3ba18a38753876816478de66af400d05 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 9 Mar 2019 22:54:09 +0700 Subject: [PATCH 4/4] Fix generated index.mld Use 0 heading for first line and 1 for subsequent lines Signed-off-by: Rudi Grinberg --- CHANGES.md | 6 ++++++ src/odoc.ml | 8 +++++--- test/blackbox-tests/test-cases/odoc-unique-mlds/run.t | 2 -- test/blackbox-tests/test-cases/odoc/run.t | 10 +++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ff924c8d51c..d3aea5f56cd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) ------------------ diff --git a/src/odoc.ml b/src/odoc.ml index cecb37efcc2..668a82a350b 100644 --- a/src/odoc.ml +++ b/src/odoc.ml @@ -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 ] -> @@ -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 diff --git a/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t b/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t index 9ec72d23e4b..e4daef4efa8 100644 --- a/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t +++ b/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t @@ -8,8 +8,6 @@ Duplicate mld's in the same scope odoc _doc/_odoc/lib/root.lib2/root_lib2.odoc odoc _doc/_html/root/Root_lib2/.dune-keep,_doc/_html/root/Root_lib2/index.html odoc _doc/_odoc/pkg/root/page-index.odoc - File "../../../_mlds/root/index.mld", line 3, characters 0-21: - '{2': heading level should be lower than top heading level '2'. odoc _doc/_html/root/index.html odoc _doc/_html/root/Root_lib1/.dune-keep,_doc/_html/root/Root_lib1/index.html diff --git a/test/blackbox-tests/test-cases/odoc/run.t b/test/blackbox-tests/test-cases/odoc/run.t index a0f3f9cab8a..ef9a5a50a4d 100644 --- a/test/blackbox-tests/test-cases/odoc/run.t +++ b/test/blackbox-tests/test-cases/odoc/run.t @@ -17,8 +17,6 @@ odoc _doc/_odoc/lib/foo/foo2.odoc odoc _doc/_html/foo/Foo2/.dune-keep,_doc/_html/foo/Foo2/index.html odoc _doc/_odoc/pkg/foo/page-index.odoc - File "../../../_mlds/foo/index.mld", line 3, characters 0-20: - '{2': heading level should be lower than top heading level '2'. odoc _doc/_html/foo/index.html odoc _doc/_html/foo/Foo_byte/.dune-keep,_doc/_html/foo/Foo_byte/index.html odoc _doc/_html/foo/Foo/.dune-keep,_doc/_html/foo/Foo/index.html @@ -45,14 +43,16 @@ $ 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}.