1
1
# File src/library/utils/R/help.start.R
2
2
# Part of the R package, https://www.R-project.org
3
3
#
4
- # Copyright (C) 1995-2022 The R Core Team
4
+ # Copyright (C) 1995-2025 The R Core Team
5
5
#
6
6
# This program is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
18
18
19
19
help.start <-
20
20
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" ))
22
24
{
23
25
WINDOWS <- .Platform $ OS.type == " windows"
24
26
if (! WINDOWS ) {
25
27
# # should always be set, but might be empty
26
28
if (! is.function(browser ) &&
27
29
(length(browser ) != 1L || ! is.character(browser ) || ! nzchar(browser )))
30
+
28
31
stop(" invalid browser name, check options(\" browser\" )." )
29
32
}
33
+ if (! missing(lib.loc )) # --> default for make.packages.html(lib.loc = *), as called from httpd()
34
+ options(html_lib.loc = lib.loc )
30
35
home <- if (is.null(remote )) {
31
36
port <- tools :: startDynamicHelp(NA )
32
37
if (port > 0L ) {
33
- if (update ) make.packages.html(temp = TRUE )
38
+ if (update ) make.packages.html(lib.loc = lib.loc , temp = TRUE )
34
39
paste0(" http://127.0.0.1:" , port )
35
40
} else stop(" help.start() requires the HTTP server to be running" ,
36
41
call. = FALSE )
@@ -46,11 +51,12 @@ help.start <-
46
51
exdent = 4L ))
47
52
writeLines(gettext(" Otherwise, be patient ..." ))
48
53
}
49
- browseURL(url , browser = browser )
54
+ browseURL(url , browser = browser , verbose = verbose )
50
55
invisible ()
51
56
}
52
57
53
- browseURL <- function (url , browser = getOption(" browser" ), encodeIfNeeded = FALSE )
58
+ browseURL <- function (url , browser = getOption(" browser" ), encodeIfNeeded = FALSE ,
59
+ verbose = getOption(" verbose" ))
54
60
{
55
61
WINDOWS <- .Platform $ OS.type == " windows"
56
62
@@ -78,7 +84,9 @@ browseURL <- function(url, browser = getOption("browser"), encodeIfNeeded=FALSE)
78
84
isLocal <- TRUE
79
85
else
80
86
isLocal <- FALSE
81
-
87
+ if (verbose )
88
+ cat(sprintf(" browseURL() on unix-alike: browser='%s', isLocal=%s:\n " ,
89
+ browser , as.character(isLocal )))
82
90
# # escape characters. ' can occur in URLs, so we must use " to
83
91
# # delimit the URL. We need to escape $, but "`\ do not occur in
84
92
# # valid URLs (RFC 2396, on the W3C site).
@@ -96,6 +104,8 @@ browseURL <- function(url, browser = getOption("browser"), encodeIfNeeded=FALSE)
96
104
gsub(" ([,)$])" , " %\\ 1" , url ), " )\" " )
97
105
}, quotedUrl )
98
106
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 )
101
111
}
0 commit comments