Skip to content

Commit a349a80

Browse files
authored
Merge pull request #90 from ropensci-review-tools/readme
pre-render readme to avoid ctags install for #55
2 parents fd11b31 + eae5c8f commit a349a80

File tree

6 files changed

+248
-103
lines changed

6 files changed

+248
-103
lines changed

‎DESCRIPTION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: pkgstats
22
Title: Metrics of R Packages
3-
Version: 0.2.0.091
3+
Version: 0.2.0.093
44
Authors@R:
55
c(person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265")),

‎R/ctags-install.R‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ctags_make <- function (ctags_dir, bin_dir = NULL, sudo = TRUE) {
8989
#' @family tags
9090
#' @examples
9191
#' \dontrun{
92-
#' ctags_install (bin_dir = "/usr/local") # default
92+
#' ctags_install (bin_dir = "/usr/local") # default Linux location.
9393
#' }
9494
#' @export
9595
ctags_install <- function (bin_dir = NULL, sudo = TRUE) {

‎README.Rmd‎

Lines changed: 105 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ output:
1616
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/pkgstats?color=orange)](https://cran.r-project.org/package=pkgstats)
1717
<!-- badges: end -->
1818

19-
```{r, include = FALSE, echo = FALSE}
19+
```{r, include = FALSE, echo = FALSE, eval = FALSE}
2020
if (identical (Sys.getenv ("IN_PKGDOWN"), "true")) {
2121
pkgstats::ctags_install ()
2222
}
@@ -69,22 +69,69 @@ using an internally bundled `.tar.gz` "tarball" of this package. The
6969
`system.time` call demonstrates that the static code analyses of `pkgstats` are
7070
generally very fast.
7171

72-
```{r demo}
72+
```{r demo, eval = FALSE}
7373
library (pkgstats)
7474
tarball <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
7575
system.time (
7676
p <- pkgstats (tarball)
7777
)
78+
```
79+
```{r demo-tarball, echo = FALSE}
80+
library (pkgstats)
81+
tarball <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
82+
path <- extract_tarball (tarball)
83+
```
84+
85+
86+
87+
```{r demo-output-systime, echo = FALSE, eval = TRUE}
88+
c (user = 1.701, system = 0.124, elapsed = 1.802)
89+
```
90+
91+
```{r demo-names, eval = FALSE}
7892
names (p)
7993
```
8094

95+
```{r demo-output, echo = FALSE, eval = TRUE}
96+
c (
97+
"loc", "vignettes", "data_stats", "desc", "translations",
98+
"objects", "network", "external_calls"
99+
)
100+
```
101+
102+
81103
The result is a list of various data extracted from the code. All except for
82104
`objects` and `network` represent summary data:
83105

84-
```{r}
106+
```{r pout, eval = FALSE, echo = TRUE}
85107
p [!names (p) %in% c ("objects", "network", "external_calls")]
86108
```
87109

110+
```{r pout-fakey, eval = TRUE, echo = FALSE}
111+
p <- list (
112+
loc = tibble::tibble (
113+
langage = c ("C++", "R", "R", "R"),
114+
dir = c ("src", "R", "tests", "tests/testthat"),
115+
nfiles = as.integer (c (3, 19, 2, 5)),
116+
nlines = as.integer (c (365, 3741, 146, 202)),
117+
ncode = as.integer (c (277, 2698, 121, 145)),
118+
ndoc = as.integer (c (21, 536, 1, 9)),
119+
nempty = as.integer (c (67, 507, 24, 48)),
120+
nspaces = as.integer (c (933, 27575, 395, 375)),
121+
nchars = as.integer (c (7002, 94022, 2423, 3738)),
122+
nexpr = rep (1, 4),
123+
ntabs = rep (0L, 4),
124+
indentation = rep (4L, 4)
125+
),
126+
vignettes = c (vignettes = 0L, demos = 0L),
127+
data_stats = c (n = 0L, total_size = 0L, median_size = 0L),
128+
desc = desc_stats (path),
129+
translations = NA
130+
)
131+
p
132+
```
133+
134+
88135
The various components of these results are described in further detail in the
89136
[main package
90137
vignette](https://docs.ropensci.org/pkgstats/articles/pkgstats.html).
@@ -96,21 +143,27 @@ A summary of the `pkgstats` data can be obtained by submitting the object
96143
returned from `pkgstats()` to the [`pkgstats_summary()`
97144
function](https://docs.ropensci.org/pkgstats/reference/pkgstats_summary.html):
98145

99-
```{r summary, echo = TRUE}
146+
```{r summary, echo = TRUE, eval = FALSE}
100147
s <- pkgstats_summary (p)
101148
```
102149

150+
```{r summary-ncols, echo = FALSE, eval = TRUE}
151+
ncol_s <- 95L
152+
```
153+
154+
155+
103156
This function reduces the result of the [`pkgstats()`
104157
function](https://docs.ropensci.org/pkgstats/reference/pkgstats_summary.html)
105-
to a single line with `r ncol (s)` entries, represented as a `data.frame` with
158+
to a single line with `r ncol_s` entries, represented as a `data.frame` with
106159
one row and that number of columns. This format is intended to enable summary
107160
statistics from multiple packages to be aggregated by simply binding rows
108-
together. While `r ncol (s)` statistics might seem like a lot, the
161+
together. While `r ncol_s` statistics might seem like a lot, the
109162
[`pkgstats_summary()`
110163
function](https://docs.ropensci.org/pkgstats/reference/pkgstats_summary.html)
111164
aims to return as many usable raw statistics as possible in order to flexibly
112165
allow higher-level statistics to be derived through combination and
113-
aggregation. These `r ncol (s)` statistics can be roughly grouped into the
166+
aggregation. These `r ncol_s` statistics can be roughly grouped into the
114167
following categories (not shown in the order in which they actually appear),
115168
with variable names in parentheses after each description. Some statistics are
116169
summarised as comma-delimited character strings, such as translations into
@@ -145,12 +198,27 @@ of all package dependencies, as demonstrated immediately below.
145198
Numbers of entries in each the of the last two kinds of items can be obtained
146199
from by a simple `strsplit` call, like this:
147200

148-
```{r strsplit}
201+
```{r strsplit, echo = TRUE, eval = FALSE}
149202
deps <- strsplit (s$suggests, ", ") [[1]]
150203
length (deps)
151204
print (deps)
152205
```
153206

207+
```{r strsplit-out1, echo = FALSE, eval = TRUE}
208+
9L
209+
```
210+
211+
```{r strsplit-deps, echo = TRUE, eval = FALSE}
212+
print (deps)
213+
```
214+
215+
```{r strsplit-out2, echo = FALSE, eval = TRUE}
216+
c (
217+
"hms", "knitr", "pbapply", "pkgbuild", "Rcpp",
218+
"rmarkdown", "roxygen2", "testthat", "visNetwork"
219+
)
220+
```
221+
154222
**Numbers of files and associated data**
155223

156224
- Number of vignettes (`num_vignettes`)
@@ -238,14 +306,23 @@ of function calls, and total numbers of unique function calls. Data for each
238306
package are separated by a comma, while data within each package are separated
239307
by a colon.
240308

241-
```{r summary-external-calls}
309+
```{r summary-external-calls, echo = TRUE, eval = FALSE}
242310
s$external_calls
243311
```
312+
```{r external-calls-out, echo = FALSE, eval = TRUE}
313+
paste0 (
314+
"base:447:78,brio:7:1,dplyr:7:4,fs:4:2,graphics:10:2,",
315+
"hms:1:1,igraph:3:3,pbapply:1:1,pkgstats:99:60,readr:8:5,",
316+
"stats:16:2,sys:13:1,tools:2:2,utils:10:7,visNetwork:3:2,withr:5:1"
317+
)
318+
```
319+
320+
244321

245322
This structure allows numbers of calls to all packages to be readily extracted
246323
with code like the following:
247324

248-
```{r summary-exteranl-calls-transform}
325+
```{r summary-external-calls-transform, echo = TRUE, eval = FALSE}
249326
calls <- do.call (
250327
rbind,
251328
strsplit (strsplit (s$external_call, ",") [[1]], ":")
@@ -258,6 +335,24 @@ calls <- data.frame (
258335
print (calls)
259336
```
260337

338+
```{r summary-external-calls-out, echo = FALSE, eval = TRUE}
339+
data.frame (
340+
package = c (
341+
"base", "brio", "dplyr", "fs", "graphics", "hms", "igraph", "pbapply",
342+
"pkgstats", "readr", "stats", "sys", "tools", "utils", "visNetwork",
343+
"withr"
344+
),
345+
n_total = as.integer (c (
346+
447, 7, 7, 4, 10, 1, 3, 1, 99, 8, 16, 13, 2, 10, 3, 5
347+
)),
348+
n_unique = as.integer (c (
349+
78, 1, 4, 2, 2, 1, 3, 1, 60, 5, 2, 1, 2, 7, 2, 1
350+
))
351+
)
352+
```
353+
354+
355+
261356
The two numeric columns respectively show the total number of calls made to
262357
each package, and the total number of unique functions used within those
263358
packages. These results provide detailed information on numbers of calls made

0 commit comments

Comments
 (0)