Skip to content

Commit 9a38a7c

Browse files
committed
Use examplesIf, r-lib/roxygen2#993
1 parent 8cbcffd commit 9a38a7c

File tree

10 files changed

+61
-103
lines changed

10 files changed

+61
-103
lines changed

R/dm-from-src.R

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,19 @@
2626
#' @return A `dm` object.
2727
#'
2828
#' @export
29-
#' @examples
30-
#' dm_from_src_demo <- function() {
31-
#' if (!rlang::is_installed("DBI")) {
32-
#' message("Install the DBI package to run this example.")
33-
#' }
29+
#' @examplesIf rlang::is_installed("RMariaDB")
30+
#' \dontrun{
31+
#' con <- DBI::dbConnect(
32+
#' RMariaDB::MariaDB(),
33+
#' username = "guest",
34+
#' password = "relational",
35+
#' dbname = "Financial_ijs",
36+
#' host = "relational.fit.cvut.cz"
37+
#' )
3438
#'
35-
#' con <- DBI::dbConnect(
36-
#' RMariaDB::MariaDB(),
37-
#' username = "guest",
38-
#' password = "relational",
39-
#' dbname = "Financial_ijs",
40-
#' host = "relational.fit.cvut.cz"
41-
#' )
42-
#' on.exit(DBI::dbDisconnect(con))
39+
#' dm_from_src(con)
4340
#'
44-
#' dm_from_src(con)
45-
#' }
46-
#' \dontrun{
47-
#' dm_from_src_demo()
41+
#' DBI::dbDisconnect(con)
4842
#' }
4943
dm_from_src <- function(src = NULL, table_names = NULL, learn_keys = NULL,
5044
...) {

R/financial.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
#' @return A `dm` object.
1212
#'
1313
#' @export
14-
#' @examples
14+
#' @examplesIf rlang::is_installed("RMariaDB")
1515
#' \dontrun{
16-
#' if (rlang::is_installed("RMariaDB")) {
17-
#' dm_financial() %>%
18-
#' dm_draw()
19-
#' }
16+
#' dm_financial() %>%
17+
#' dm_draw()
2018
#' }
2119
dm_financial <- function() {
2220
stopifnot(rlang::is_installed("RMariaDB"))

R/foreign-keys.R

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,11 @@
3232
#' @return For `dm_add_fk()`: An updated `dm` with an additional foreign key relation.
3333
#'
3434
#' @export
35-
#' @examples
36-
#' if (rlang::is_installed("nycflights13")) {
37-
#' nycflights_dm <- dm(
38-
#' planes = nycflights13::planes,
39-
#' flights = nycflights13::flights
40-
#' )
41-
#' } else {
42-
#' message("Using mock-up data, install the nycflights13 package to fix.")
43-
#' nycflights_dm <- dm(
44-
#' planes = tibble(tailnum = character()),
45-
#' flights = tibble(tailnum = character())
46-
#' )
47-
#' }
35+
#' @examplesIf rlang::is_installed("nycflights13")
36+
#' nycflights_dm <- dm(
37+
#' planes = nycflights13::planes,
38+
#' flights = nycflights13::flights
39+
#' )
4840
#'
4941
#' nycflights_dm %>%
5042
#' dm_draw()

R/nycflights13.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
#' @return A `dm` object consisting of {nycflights13} tables, complete with primary and foreign keys and optionally colored.
2121
#'
2222
#' @export
23-
#' @examples
24-
#' if (rlang::is_installed("nycflights13")) {
25-
#' dm_nycflights13() %>%
26-
#' dm_draw()
27-
#' }
23+
#' @examplesIf rlang::is_installed("nycflights13") && rlang::is_installed("DiagrammeR")
24+
#' dm_nycflights13() %>%
25+
#' dm_draw()
2826
dm_nycflights13 <- function(cycle = FALSE, color = TRUE, subset = TRUE) {
2927
airlines <- nycflights13::airlines
3028
airports <- nycflights13::airports

R/primary-keys.R

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,11 @@
2929
#' @return For `dm_add_pk()`: An updated `dm` with an additional primary key.
3030
#'
3131
#' @export
32-
#' @examples
33-
#' if (rlang::is_installed("nycflights13")) {
34-
#' nycflights_dm <- dm(
35-
#' planes = nycflights13::planes,
36-
#' airports = nycflights13::airports
37-
#' )
38-
#' } else {
39-
#' message("Using mock-up data, install the nycflights13 package to fix.")
40-
#' nycflights_dm <- dm(
41-
#' planes = tibble(tailnum = letters[1:2], manufacturer = "Acme"),
42-
#' airports = tibble(faa = character())
43-
#' )
44-
#' }
32+
#' @examplesIf rlang::is_installed("nycflights13")
33+
#' nycflights_dm <- dm(
34+
#' planes = nycflights13::planes,
35+
#' airports = nycflights13::airports
36+
#' )
4537
#'
4638
#' nycflights_dm %>%
4739
#' dm_draw()
@@ -52,7 +44,7 @@
5244
#' dm_add_pk(airports, faa, check = TRUE) %>%
5345
#' dm_draw()
5446
#'
55-
#' # the following does not work (throws an error)
47+
#' # the following throws an error:
5648
#' try(
5749
#' nycflights_dm %>%
5850
#' dm_add_pk(planes, manufacturer, check = TRUE)

man/dm_add_fk.Rd

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dm_add_pk.Rd

Lines changed: 7 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dm_financial.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dm_from_src.Rd

Lines changed: 12 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dm_nycflights13.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)