11# File src/library/utils/R/help.start.R
22# Part of the R package, https://www.R-project.org
33#
4- # Copyright (C) 1995-2022 The R Core Team
4+ # Copyright (C) 1995-2025 The R Core Team
55#
66# This program is free software; you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
1818
1919help.start <-
2020 function (update = FALSE , gui = " irrelevant" ,
21- browser = getOption(" browser" ), remote = NULL )
21+ lib.loc = .libPaths(),
22+ browser = getOption(" browser" ), remote = NULL ,
23+ verbose = getOption(" verbose" ))
2224{
2325 WINDOWS <- .Platform $ OS.type == " windows"
2426 if (! WINDOWS ) {
2527 # # should always be set, but might be empty
2628 if (! is.function(browser ) &&
2729 (length(browser ) != 1L || ! is.character(browser ) || ! nzchar(browser )))
30+
2831 stop(" invalid browser name, check options(\" browser\" )." )
2932 }
33+ if (! missing(lib.loc )) # --> default for make.packages.html(lib.loc = *), as called from httpd()
34+ options(html_lib.loc = lib.loc )
3035 home <- if (is.null(remote )) {
3136 port <- tools :: startDynamicHelp(NA )
3237 if (port > 0L ) {
33- if (update ) make.packages.html(temp = TRUE )
38+ if (update ) make.packages.html(lib.loc = lib.loc , temp = TRUE )
3439 paste0(" http://127.0.0.1:" , port )
3540 } else stop(" help.start() requires the HTTP server to be running" ,
3641 call. = FALSE )
@@ -46,11 +51,12 @@ help.start <-
4651 exdent = 4L ))
4752 writeLines(gettext(" Otherwise, be patient ..." ))
4853 }
49- browseURL(url , browser = browser )
54+ browseURL(url , browser = browser , verbose = verbose )
5055 invisible ()
5156}
5257
53- browseURL <- function (url , browser = getOption(" browser" ), encodeIfNeeded = FALSE )
58+ browseURL <- function (url , browser = getOption(" browser" ), encodeIfNeeded = FALSE ,
59+ verbose = getOption(" verbose" ))
5460{
5561 WINDOWS <- .Platform $ OS.type == " windows"
5662
@@ -78,7 +84,9 @@ browseURL <- function(url, browser = getOption("browser"), encodeIfNeeded=FALSE)
7884 isLocal <- TRUE
7985 else
8086 isLocal <- FALSE
81-
87+ if (verbose )
88+ cat(sprintf(" browseURL() on unix-alike: browser='%s', isLocal=%s:\n " ,
89+ browser , as.character(isLocal )))
8290 # # escape characters. ' can occur in URLs, so we must use " to
8391 # # delimit the URL. We need to escape $, but "`\ do not occur in
8492 # # valid URLs (RFC 2396, on the W3C site).
@@ -96,6 +104,8 @@ browseURL <- function(url, browser = getOption("browser"), encodeIfNeeded=FALSE)
96104 gsub(" ([,)$])" , " %\\ 1" , url ), " )\" " )
97105 }, quotedUrl )
98106 else quotedUrl
99- system(paste(browser , remoteCmd , " > /dev/null 2>&1 ||" ,
100- browser , quotedUrl , " &" ))
107+ cmd <- paste(browser , remoteCmd , " > /dev/null 2>&1 ||" ,
108+ browser , quotedUrl , " &" )
109+ if (verbose ) cat(sprintf(" system(<cmd>), <cmd> := '%s'" , cmd ))
110+ system(cmd )
101111}
0 commit comments