Skip to content

Commit 1689ab2

Browse files
author
maechler
committed
help.start(lib.loc = .); also verbose; options(html_lib.loc = *)
git-svn-id: https://svn.r-project.org/R/trunk@88167 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 42faf47 commit 1689ab2

File tree

6 files changed

+55
-27
lines changed

6 files changed

+55
-27
lines changed

doc/NEWS.Rd

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
\item \code{terms(<formula>, specials = *)} now treats non-syntactic
2020
specials more gracefully, thanks to \I{Mikael Jagan}'s \PR{18568}.
21+
22+
\item \code{help.start()} gets a \code{lib.loc} option and its
23+
default for \code{make.packages.html()} is enhanced to allow, e.g.,
24+
fast access to \code{.Library} when that contains only base and
25+
recommended packages.
2126
}
2227
}
2328
@@ -41,7 +46,6 @@
4146
4247
\subsection{UTILITIES}{
4348
\itemize{
44-
% this will not be ported to R 4.5.0.
4549
\item \command{R CMD check} now reports further \command{clang} warnings
4650
including \code{-Wkeyword-macro}. This is most commonly seen for
4751
the C23 keywords \code{bool}, \code{true} and \code{false}, but is

src/library/utils/R/help.start.R

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
@@ -18,19 +18,24 @@
1818

1919
help.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
}

src/library/utils/R/linkhtml.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/utils/R/linkhtml.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
@@ -18,7 +18,8 @@
1818

1919

2020
make.packages.html <-
21-
function(lib.loc = .libPaths(), temp = FALSE, verbose = TRUE,
21+
function(lib.loc = getOption("html_lib.loc", default = .libPaths()),
22+
temp = FALSE, verbose = TRUE,
2223
docdir = R.home("doc"))
2324
{
2425
add_lib_index <- function(libs)

src/library/utils/man/browseURL.Rd

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% File src/library/utils/man/browseURL.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 1995-2022 R Core Team
3+
% Copyright 1995-2025 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{browseURL}
@@ -11,7 +11,8 @@
1111
}
1212
\usage{
1313
browseURL(url, browser = getOption("browser"),
14-
encodeIfNeeded = FALSE)
14+
encodeIfNeeded = FALSE,
15+
verbose = getOption("verbose"))
1516
}
1617
\arguments{
1718
\item{url}{a non-empty character string giving the URL to be loaded.
@@ -31,6 +32,8 @@ browseURL(url, browser = getOption("browser"),
3132
itself does encoding, and can be harmful for \samp{file://} URLs on some
3233
systems and for \samp{http://} URLs passed to some CGI applications.
3334
Fortunately, most URLs do not need encoding.}
35+
\item{verbose}{logical indicating if information about the system
36+
interface should be printed to the console.}
3437
}
3538
\details{
3639
\describe{
@@ -41,12 +44,12 @@ browseURL(url, browser = getOption("browser"),
4144
made manually or automatically when \R was configured. (See
4245
\code{\link{Startup}} for where to override that default value.)
4346
To suppress showing URLs altogether, use the value \code{"false"}.
44-
47+
4548
On many platforms it is best to set option \code{"browser"} to a
4649
generic program/script and let that invoke the user's choice of
4750
browser. For example, on macOS use \command{open} and on many other
4851
Unix-alikes use \command{xdg-open}.
49-
52+
5053
If \code{browser} supports remote control and \R knows how to perform
5154
it, the URL is opened in any already-running browser or a new one if
5255
necessary. This mechanism currently is available for browsers which
@@ -67,7 +70,7 @@ browseURL(url, browser = getOption("browser"),
6770
(see \code{\link{URLencode}}).
6871

6972
To suppress showing URLs altogether, set \code{browser = "false"}.
70-
73+
7174
The behaviour for arguments \code{url} which are not URLs is
7275
platform-dependent. Some platforms accept absolute file paths; fewer
7376
accept relative file paths.
@@ -106,7 +109,7 @@ browseURL("file://d:/R/R-2.5.1/doc/html/index.html",
106109
\samp{mailto:} may or may not (and if it does may not use the user's
107110
preferred email client). However, modern browsers are unlikely to handle
108111
\samp{ftp://}.
109-
112+
110113
For the \samp{file://} scheme the format accepted (if any) can depend on
111114
both browser and OS.
112115
}

src/library/utils/man/help.start.Rd

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% File src/library/utils/man/help.start.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 1995-2024 R Core Team
3+
% Copyright 1995-2025 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{help.start}
@@ -12,20 +12,26 @@
1212
}
1313
\usage{
1414
help.start(update = FALSE, gui = "irrelevant",
15-
browser = getOption("browser"), remote = NULL)
15+
lib.loc = .libPaths(),
16+
browser = getOption("browser"), remote = NULL,
17+
verbose = getOption("verbose"))
1618
}
1719
\arguments{
1820
\item{update}{logical: should this attempt to update the package index to
1921
reflect the currently available packages. (Not attempted if
2022
\code{remote} is non-\code{NULL}.)}
2123
\item{gui}{just for compatibility with S-PLUS.}
24+
\item{lib.loc}{character vector, listing the package libraries to be included.}
2225
\item{browser}{the name of the program to be used as hypertext
2326
browser. It should be in the \env{PATH}, or a full path specified.
2427
Alternatively, it can be an \R function which will be called with a
2528
URL as its only argument. This option is normally unset on Windows,
2629
when the file-association mechanism will be used.}
27-
\item{remote}{A character string giving a valid URL for the
28-
\file{\var{\link{R_HOME}}} directory on a remote location.}
30+
\item{remote}{a character string giving a valid URL for the
31+
\file{\var{\link{R_HOME}}} directory on a \dQuote{remote} location;
32+
may be \code{"file://<Rhome>"} pointing to a path on your local platform.}
33+
\item{verbose}{logical indicating if information about the system
34+
interface should be printed to the console.}
2935
}
3036
\details{
3137
Unless \code{remote} is specified this requires the HTTP server to be
@@ -50,6 +56,7 @@ help.start(update = FALSE, gui = "irrelevant",
5056
\seealso{
5157
\code{\link{help}()} for on- and off-line help in other formats.
5258
59+
\code{\link{make.packages.html}} for how the \file{*.html} pages are created.
5360
\code{\link{browseURL}} for how the help file is displayed.
5461
5562
\code{\link{RSiteSearch}} to access an on-line search of \R resources.

src/library/utils/man/make.packages.html.Rd

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
% File src/library/utils/man/unix/make.packages.html.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 1995-2011 R Core Team
3+
% Copyright 1995-2025 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{make.packages.html}
77
\alias{make.packages.html}
88
\title{Update HTML Package List}
99
\usage{
10-
make.packages.html(lib.loc = .libPaths(), temp = FALSE,
11-
verbose = TRUE, docdir = R.home("doc"))
10+
make.packages.html(lib.loc = getOption("html_lib.loc", default = .libPaths()),
11+
temp = FALSE, verbose = TRUE, docdir = R.home("doc"))
1212
}
1313
\description{
1414
Re-create the HTML list of packages.
1515
}
1616
\arguments{
17-
\item{lib.loc}{character vector. List of libraries to be included.}
17+
\item{lib.loc}{character vector of package libraries to be
18+
included. Default typically set from \code{\link{help.start}(lib.loc = *)}.}
1819
\item{temp}{logical: should the package indices be created in a
1920
temporary location for use by the HTTP server?}
2021
\item{verbose}{logical. If true, print out a message.
@@ -54,6 +55,8 @@ make.packages.html(lib.loc = .libPaths(), temp = FALSE,
5455
\examples{\dontrun{
5556
make.packages.html()
5657
# this can be slow for large numbers of installed packages.
57-
}}
58-
58+
}
59+
if(interactive()) # typically fast and quiet
60+
make.packages.html(lib.loc = .Library, verbose=FALSE)
61+
}
5962
\keyword{utilities}

0 commit comments

Comments
 (0)