Skip to content

Commit 4dc6901

Browse files
committed
Reuse example
1 parent 5d84897 commit 4dc6901

File tree

4 files changed

+60
-78
lines changed

4 files changed

+60
-78
lines changed

R/document_universe.R

+9-4
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,21 @@ vignettes_template <- function(template) {
7474
#' library(glue)
7575
#' library(tibble)
7676
#'
77-
#' packages <- c("glue", "tibble")
78-
#' document_universe(packages)
77+
#' universe <- c("glue", "tibble")
78+
#' document_universe(universe)
7979
#'
8080
#' # Assuming vignettes can be found at */articles/* rather than */reference/*
8181
#' manual <- "https://{package}.tidyverse.org/reference/{topic}.html"
82-
#' document_universe(packages, url_template = manual)
82+
#' document_universe(universe, url_template = manual)
8383
#'
8484
#' # Adding an explicit template for vignettes
8585
#' vignettes <- "https://{package}.tidyverse.org/articles/{topic}.html"
86-
#' document_universe(packages, url_template = c(manual, vignettes))
86+
#' document_universe(universe, c(manual, vignettes))
87+
#'
88+
#' # Works beyond GitHub Pages, e.g. on r-universe
89+
#' manual <- "https://tidyverse.r-universe.dev/{package}/doc/manual.html#{topic}"
90+
#' vignettes <- "https://tidyverse.r-universe.dev/articles/{package}/{topic}.html"
91+
#' document_universe(universe, c(manual, vignettes))
8792
document_universe <- function(x, url_template = NULL) {
8893
out <- document_universe_impl(x = x, url_template = url_template)
8994
tibble::as_tibble(out)

README.Rmd

+13-22
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,28 @@ using [pkgdown](https://pkgdown.r-lib.org/).
6969

7070
## Example
7171

72-
`document_universe()` creates a data frame with documentation metadata of one or
72+
* `document_universe()` creates a data frame with documentation metadata of one or
7373
more packages.
74+
* `url_template` can take different templates for the manual and vignettes.
75+
* `knitr::kable()` turns the URLs into clickable links. `DT::datatabe()` also
76+
provides a search box.
7477

7578
```{r}
7679
library(dverse)
77-
# demoverse
80+
7881
library(glue)
7982
library(tibble)
8083
81-
demoverse <- c("glue", "tibble")
82-
# Example: "https://tibble.tidyverse.org/reference/as_tibble.html"
84+
universe <- c("glue", "tibble")
85+
document_universe(universe)
86+
87+
# Assuming vignettes can be found at */articles/* rather than */reference/*
8388
manual <- "https://{package}.tidyverse.org/reference/{topic}.html"
84-
docs <- document_universe(demoverse, url_template = manual)
85-
docs
86-
```
89+
document_universe(universe, url_template = manual)
8790
88-
`knitr::kable()` turns the URLs into clickable links.
91+
# Adding an explicit template for vignettes
92+
vignettes <- "https://{package}.tidyverse.org/articles/{topic}.html"
93+
docs <- document_universe(universe, url_template = c(manual, vignettes))
8994
90-
```{r}
9195
knitr::kable(tail(docs))
9296
```
93-
94-
`url_template` can take different templates for the manual and vignettes.
95-
96-
```{r}
97-
manual <- "https://tidyverse.r-universe.dev/{package}/doc/manual.html#{topic}"
98-
vignettes <- "https://tidyverse.r-universe.dev/articles/{package}/{topic}.html"
99-
docs_runiverse <- document_universe(demoverse, url_template = c(manual, vignettes))
100-
docs_runiverse
101-
102-
knitr::kable(tail(docs_runiverse))
103-
```
104-
105-
`DT::datatabe()` also provides a search box. See [Get started](https://maurolepore.github.io/dverse/articles/dverse.html).

README.md

+29-48
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,39 @@ website, for example using [pkgdown](https://pkgdown.r-lib.org/).
6565

6666
## Example
6767

68-
`document_universe()` creates a data frame with documentation metadata
69-
of one or more packages.
68+
- `document_universe()` creates a data frame with documentation metadata
69+
of one or more packages.
70+
- `url_template` can take different templates for the manual and
71+
vignettes.
72+
- `knitr::kable()` turns the URLs into clickable links. `DT::datatabe()`
73+
also provides a search box.
7074

7175
``` r
7276
library(dverse)
73-
# demoverse
77+
7478
library(glue)
7579
library(tibble)
7680

77-
demoverse <- c("glue", "tibble")
78-
# Example: "https://tibble.tidyverse.org/reference/as_tibble.html"
81+
universe <- c("glue", "tibble")
82+
document_universe(universe)
83+
#> # A tibble: 46 × 7
84+
#> topic alias title concept type keyword package
85+
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
86+
#> 1 add_column add_column Add … additi… help <NA> tibble
87+
#> 2 add_row add_row, add_case Add … additi… help <NA> tibble
88+
#> 3 as_glue as_glue Coer… <NA> help <NA> glue
89+
#> 4 as_tibble as_tibble, as_tibble_row, as_… Coer… <NA> help <NA> tibble
90+
#> 5 char char, set_char_opts Form… vector… help <NA> tibble
91+
#> 6 deprecated deprecated, data_frame, tibbl… Depr… <NA> help intern… tibble
92+
#> 7 digits digits Comp… <NA> vign… <NA> tibble
93+
#> 8 enframe enframe, deframe Conv… <NA> help <NA> tibble
94+
#> 9 engines engines Cust… <NA> vign… <NA> glue
95+
#> 10 extending extending Exte… <NA> vign… <NA> tibble
96+
#> # ℹ 36 more rows
97+
98+
# Assuming vignettes can be found at */articles/* rather than */reference/*
7999
manual <- "https://{package}.tidyverse.org/reference/{topic}.html"
80-
docs <- document_universe(demoverse, url_template = manual)
81-
docs
100+
document_universe(universe, url_template = manual)
82101
#> # A tibble: 46 × 7
83102
#> topic alias title concept type keyword package
84103
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
@@ -93,11 +112,11 @@ docs
93112
#> 9 <a href=https://glue.tidyverse.org… engi… Cust… <NA> vign… <NA> glue
94113
#> 10 <a href=https://tibble.tidyverse.o… exte… Exte… <NA> vign… <NA> tibble
95114
#> # ℹ 36 more rows
96-
```
97115

98-
`knitr::kable()` turns the URLs into clickable links.
116+
# Adding an explicit template for vignettes
117+
vignettes <- "https://{package}.tidyverse.org/articles/{topic}.html"
118+
docs <- document_universe(universe, url_template = c(manual, vignettes))
99119

100-
``` r
101120
knitr::kable(tail(docs))
102121
```
103122

@@ -109,41 +128,3 @@ knitr::kable(tail(docs))
109128
| <a href=https://tibble.tidyverse.org/articles/types.html>types</a> | types | Column types | NA | vignette | NA | tibble |
110129
| <a href=https://tibble.tidyverse.org/reference/view.html>view</a> | view | View an object | NA | help | NA | tibble |
111130
| <a href=https://glue.tidyverse.org/articles/wrappers.html>wrappers</a> | wrappers | How to write a function that wraps glue | NA | vignette | NA | glue |
112-
113-
`url_template` can take different templates for the manual and
114-
vignettes.
115-
116-
``` r
117-
manual <- "https://tidyverse.r-universe.dev/{package}/doc/manual.html#{topic}"
118-
vignettes <- "https://tidyverse.r-universe.dev/articles/{package}/{topic}.html"
119-
docs_runiverse <- document_universe(demoverse, url_template = c(manual, vignettes))
120-
docs_runiverse
121-
#> # A tibble: 46 × 7
122-
#> topic alias title concept type keyword package
123-
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
124-
#> 1 <a href=https://tidyverse.r-univer… add_… Add … additi… help <NA> tibble
125-
#> 2 <a href=https://tidyverse.r-univer… add_… Add … additi… help <NA> tibble
126-
#> 3 <a href=https://tidyverse.r-univer… as_g… Coer… <NA> help <NA> glue
127-
#> 4 <a href=https://tidyverse.r-univer… as_t… Coer… <NA> help <NA> tibble
128-
#> 5 <a href=https://tidyverse.r-univer… char… Form… vector… help <NA> tibble
129-
#> 6 <a href=https://tidyverse.r-univer… depr… Depr… <NA> help intern… tibble
130-
#> 7 <a href=https://tidyverse.r-univer… digi… Comp… <NA> vign… <NA> tibble
131-
#> 8 <a href=https://tidyverse.r-univer… enfr… Conv… <NA> help <NA> tibble
132-
#> 9 <a href=https://tidyverse.r-univer… engi… Cust… <NA> vign… <NA> glue
133-
#> 10 <a href=https://tidyverse.r-univer… exte… Exte… <NA> vign… <NA> tibble
134-
#> # ℹ 36 more rows
135-
136-
knitr::kable(tail(docs_runiverse))
137-
```
138-
139-
| topic | alias | title | concept | type | keyword | package |
140-
|:---|:---|:---|:---|:---|:---|:---|
141-
| <a href=https://tidyverse.r-universe.dev/tibble/doc/manual.html#tribble>tribble</a> | tribble | Row-wise tibble creation | NA | help | NA | tibble |
142-
| <a href=https://tidyverse.r-universe.dev/glue/doc/manual.html#trim>trim</a> | trim | Trim a character vector | NA | help | NA | glue |
143-
| <a href=https://tidyverse.r-universe.dev/tibble/doc/manual.html#trunc_mat>trunc_mat</a> | trunc_mat | Legacy printing | NA | help | internal | tibble |
144-
| <a href=https://tidyverse.r-universe.dev/articles/tibble/types.html>types</a> | types | Column types | NA | vignette | NA | tibble |
145-
| <a href=https://tidyverse.r-universe.dev/tibble/doc/manual.html#view>view</a> | view | View an object | NA | help | NA | tibble |
146-
| <a href=https://tidyverse.r-universe.dev/articles/glue/wrappers.html>wrappers</a> | wrappers | How to write a function that wraps glue | NA | vignette | NA | glue |
147-
148-
`DT::datatabe()` also provides a search box. See [Get
149-
started](https://maurolepore.github.io/dverse/articles/dverse.html).

man/document_universe.Rd

+9-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)