Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix url opened by "dune ocaml doc" #10897

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions bin/ocaml/doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/changes/10897.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix the URL opened by the command `dune ocaml doc`. (#10897, @gridbugs)
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/odoc/doc-browser.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading