diff --git a/CHANGES.md b/CHANGES.md index 1c09a7ebf6f..21f63e0122a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ Unreleased ---------- +- Fix handling of support files generated by odoc. (#6913, @jonludlam) - Fix parsing of OCaml errors that contain code excerpts with `...` in them. (#7008, @rgrinberg) diff --git a/src/dune_rules/odoc.ml b/src/dune_rules/odoc.ml index b2fbede28bd..9e4841b4927 100644 --- a/src/dune_rules/odoc.ml +++ b/src/dune_rules/odoc.ml @@ -85,6 +85,8 @@ let add_rule sctx = Super_context.add_rule sctx ~dir module Paths = struct + let odoc_support_dirname = "_odoc_support" + let root (context : Context.t) = Path.Build.relative context.Context.build_dir "_doc" @@ -111,9 +113,7 @@ module Paths = struct let gen_mld_dir ctx pkg = root ctx ++ "_mlds" ++ Package.Name.to_string pkg - let css_file ctx = html_root ctx ++ "odoc.css" - - let highlight_pack_js ctx = html_root ctx ++ "highlight.pack.js" + let odoc_support ctx = html_root ctx ++ odoc_support_dirname let toplevel_index ctx = html_root ctx ++ "index.html" end @@ -347,12 +347,21 @@ let setup_html sctx (odoc_file : odoc_artefact) = (odoc_file.html_dir, [ dummy ]) in let open Memo.O in + let odoc_support_path = Paths.odoc_support ctx in + let html_output = Paths.html_root ctx in + let support_relative = + Path.reach (Path.build odoc_support_path) ~from:(Path.build html_output) + in let* run_odoc = run_odoc sctx ~dir:(Path.build (Paths.html_root ctx)) "html-generate" ~flags_for:None [ A "-o" ; Path (Path.build (Paths.html_root ctx)) + ; A "--support-uri" + ; A support_relative + ; A "--theme-uri" + ; A support_relative ; Dep (Path.build odoc_file.odocl_file) ; Hidden_targets [ odoc_file.html_file ] ] @@ -371,13 +380,15 @@ let setup_html sctx (odoc_file : odoc_artefact) = let setup_css_rule sctx = let open Memo.O in let ctx = Super_context.context sctx in + let dir = Paths.odoc_support ctx in let* run_odoc = - run_odoc sctx ~dir:(Path.build ctx.build_dir) "support-files" - ~flags_for:None - [ A "-o" - ; Path (Path.build (Paths.html_root ctx)) - ; Hidden_targets [ Paths.css_file ctx; Paths.highlight_pack_js ctx ] - ] + let+ cmd = + run_odoc sctx ~dir:(Path.build ctx.build_dir) "support-files" + ~flags_for:None + [ A "-o"; Path (Path.build dir) ] + in + cmd + |> Action_builder.With_targets.add_directories ~directory_targets:[ dir ] in add_rule sctx run_odoc @@ -404,7 +415,7 @@ let setup_toplevel_index_rule sctx =