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

R: ? for topics in packages you have run load_all() on open an external browser instead of using the Help pane #1025

Closed
Tracked by #1542
DavisVaughan opened this issue Aug 10, 2023 · 9 comments
Assignees
Labels
area: help Issues related to Help category. area: kernels Issues related to Jupyter kernels and LSP servers lang: r

Comments

@DavisVaughan
Copy link
Contributor

  • Open vctrs
  • Run devtools::load_all()
  • Run ?vec_order
  • It should open in the browser rather than opening in the Help pane

pkgload has special behavior for the ? shim it adds if you are in RStudio, and we probably need a similar thing for Positron

> pkgload:::print.dev_topic
function (x, ...) 
{
    cli::cli_inform(c(i = "Rendering development documentation for {.val {x$topic}}"))
    type <- arg_match0(x$type %||% "text", c("text", "html"))
    if (type == "html" && is_rstudio() && is_installed("rstudioapi")) {
        version_needed <- if (has_rd_macros(dirname(dirname(x$path)))) 
            "2022.12.0.256"
        if (rstudioapi::hasFun("previewRd", version_needed = version_needed)) {
            return(rstudioapi::callFun("previewRd", x$path))
        }
    }
    file <- fs::path_ext_set(fs::path_file(x$path), type)
    doc_path <- fs::path("doc", "html", file)
    path <- fs::path(tempdir(), ".R", doc_path)
    fs::dir_create(fs::path_dir(path), recurse = TRUE)
    if (type == "text") {
        topic_write_text(x, path)
        title <- paste(x$pkg, basename(x$path), sep = ":")
        file.show(path, title = title)
    }
    else if (type == "html") {
        topic_write_html(x, path)
        if (is_rstudio()) {
            port <- httpdPort()
            url <- sprintf("http://localhost:%i/%s", port, doc_path)
        }
        else {
            url <- path
        }
        utils::browseURL(url)
    }
}
@DavisVaughan DavisVaughan added this to the Internal Preview milestone Aug 10, 2023
@jmcphers
Copy link
Collaborator

This should work once we implement the viewer option

@DavisVaughan
Copy link
Contributor Author

Oh or did you mean browser? i.e. https://stat.ethz.ch/R-manual/R-devel/library/utils/html/browseURL.html?

@hadley
Copy link

hadley commented Oct 4, 2023

Likely we'll need some logic tweaking in pkgload too since the initial if statement uses is_rstudio() which checks is_string(.Platform$GUI, "RStudio"). But I think we can safely drop that is_rstudio() and then assume rstudioapi provides the appropriate shims.

@juliasilge
Copy link
Contributor

Related to #1312. Once we have rstudioapi shims, we can adjust devtools to use those only.

@jennybc
Copy link
Member

jennybc commented Feb 23, 2024

I just verified that this is still a problem, assuming this is a sentence-o, i.e. the problem is exactly the other way around:

It should open in the browser rather than opening in the Help pane

I'm seeing dev help (so, post load_all()) open in an external browser, whereas I'd expect and want it to open in Positron's help pane.

@wesm wesm added the lang: r label Feb 29, 2024
@jennybc jennybc added the area: help Issues related to Help category. label Mar 7, 2024
@juliasilge
Copy link
Contributor

More details on how this comes up from our private beta: https://github.com/posit-dev/positron-beta/issues/33

@jennybc jennybc self-assigned this Mar 28, 2024
@jennybc

This comment was marked as outdated.

@jennybc

This comment was marked as outdated.

@lionel- lionel- added the area: kernels Issues related to Jupyter kernels and LSP servers label May 16, 2024
@juliasilge
Copy link
Contributor

In Positron 2024.05.0 (Universal) build 1307, this works as expected, including links within the package and to other packages:

Image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: help Issues related to Help category. area: kernels Issues related to Jupyter kernels and LSP servers lang: r
Projects
None yet
Development

No branches or pull requests

7 participants