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}.