diff --git a/bin/ocaml/doc.ml b/bin/ocaml/doc.ml index 6dae72b6fdd..584438b2f99 100644 --- a/bin/ocaml/doc.ml +++ b/bin/ocaml/doc.ml @@ -23,7 +23,7 @@ let term = Alias.in_dir ~name:Dune_rules.Alias.doc ~recursive:true ~contexts:setup.contexts dir |> Alias.request in - let absolute_toplevel_index_path = + let relative_toplevel_index_path = let toplevel_index_path = let is_default ctx = ctx |> Context.name |> Dune_engine.Context_name.is_default in let doc_ctx = List.find_exn setup.contexts ~f:is_default in @@ -32,12 +32,12 @@ let term = Path.(toplevel_index_path |> build |> to_string_maybe_quoted) in Console.print - [ Pp.textf "Docs built. Index can be found here: %s" absolute_toplevel_index_path ]; + [ Pp.textf "Docs built. Index can be found here: %s" relative_toplevel_index_path ]; match let open Option.O in let* cmd_name, args = match Platform.OS.value with - | Darwin -> Some ("open", [ "-u" ]) + | Darwin -> Some ("open", []) | Other | FreeBSD | NetBSD | OpenBSD | Haiku | Linux -> Some ("xdg-open", []) | Windows -> None in @@ -47,8 +47,7 @@ let term = in ( open_command , (* First element of argv is the name of the command. *) - let url = "file://" ^ absolute_toplevel_index_path in - (cmd_name :: args) @ [ url ] ) + (cmd_name :: args) @ [ relative_toplevel_index_path ] ) with | Some (cmd, args) -> Proc.restore_cwd_and_execve (Path.to_absolute_filename cmd) args ~env:Env.initial diff --git a/doc/changes/10897.md b/doc/changes/10897.md new file mode 100644 index 00000000000..22ab2b5407d --- /dev/null +++ b/doc/changes/10897.md @@ -0,0 +1 @@ +- Fix the URL opened by the command `dune ocaml doc`. (#10897, @gridbugs) diff --git a/test/blackbox-tests/test-cases/odoc/doc-browser.t/run.t b/test/blackbox-tests/test-cases/odoc/doc-browser.t/run.t index 61be00a42d7..6d49e396779 100644 --- a/test/blackbox-tests/test-cases/odoc/doc-browser.t/run.t +++ b/test/blackbox-tests/test-cases/odoc/doc-browser.t/run.t @@ -2,7 +2,7 @@ This tests shows how to use the `dune ocaml doc` command to open the documentation index to a browser. $ if [ "$(uname)" = Darwin ]; then mv xdg-open open; fi $ export PATH=.:$PATH - $ dune ocaml doc | sed -e 's|^-u *||' + $ dune ocaml doc Docs built. Index can be found here: _build/default/_doc/_html/index.html open command received args: - file://_build/default/_doc/_html/index.html + _build/default/_doc/_html/index.html