From 2f4a23468cb2b4e0b2acfda7ae44d3ead45ff25c Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Sun, 8 Jun 2025 08:16:50 -0700 Subject: [PATCH 1/2] Even simpler README --- README.Rmd | 18 +++--------------- README.md | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/README.Rmd b/README.Rmd index 614433b..82fa36d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -72,10 +72,9 @@ using [pkgdown](https://pkgdown.r-lib.org/). ## Example * `document_universe()` creates a data frame with documentation metadata of one or -more packages. -* `url_template` can take different templates for the manual and vignettes. -* `knitr::kable()` turns the URLs into clickable links. `DT::datatabe()` also -provides a search box. +more packages, i.e. the universe. +* You can then turn the URLs into clickable links with e.g. `knitr::kable()` or +`DT::datatabe()` (which also provides a search box). ```{r} library(dverse) @@ -88,17 +87,6 @@ template <- "https://{package}.tidyverse.org/reference/{topic}.html" docs <- document_universe(packages, template) docs -``` - -```{r} -#| eval: !r on_ci -#| echo: !r on_ci -DT::datatable(docs, escape = FALSE) -``` -```{r} -#| eval: !r on_ci -#| echo: !r on_ci knitr::kable(tail(docs)) ``` - diff --git a/README.md b/README.md index b5ecb74..591cf6b 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,10 @@ website, for example using [pkgdown](https://pkgdown.r-lib.org/). ## Example - `document_universe()` creates a data frame with documentation metadata - of one or more packages. -- `url_template` can take different templates for the manual and - vignettes. -- `knitr::kable()` turns the URLs into clickable links. `DT::datatabe()` - also provides a search box. + of one or more packages, i.e. the universe. +- You can then turn the URLs into clickable links with + e.g. `knitr::kable()` or `DT::datatabe()` (which also provides a + search box). ``` r library(dverse) @@ -97,4 +96,15 @@ docs #> 9 vign… glue #> 10 vign… tibble #> # ℹ 36 more rows + +knitr::kable(tail(docs)) ``` + +| topic | alias | title | concept | type | keyword | package | +|:---|:---|:---|:---|:---|:---|:---| +| tribble | tribble | Row-wise tibble creation | NA | help | NA | tibble | +| trim | trim | Trim a character vector | NA | help | NA | glue | +| trunc_mat | trunc_mat | Legacy printing | NA | help | internal | tibble | +| types | types | Column types | NA | vignette | NA | tibble | +| view | view | View an object | NA | help | NA | tibble | +| wrappers | wrappers | How to write a function that wraps glue | NA | vignette | NA | glue | From 6676b3d51c54079077cad70e9015933f61c30add Mon Sep 17 00:00:00 2001 From: Mauro Lepore Date: Fri, 18 Jul 2025 11:13:02 -0600 Subject: [PATCH 2/2] Remove explicit namespacing in R code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove explicit namespace calls (e.g., dplyr::filter() → filter()) - Add missing imports to R/dverse-package.R for all unnamespaced functions - All tests pass and R CMD check succeeds 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- NAMESPACE | 9 +++++++++ R/document_universe.R | 18 +++++++++--------- R/dverse-package.R | 9 +++++++++ R/is_online.R | 2 +- R/s3_strip_class.R | 4 ++-- R/search_documentation.R | 2 +- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 838d16b..2a70463 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,12 +2,21 @@ export(document_universe) export(is_online) +importFrom(cli,cli_abort) +importFrom(cli,cli_warn) +importFrom(curl,curl_fetch_memory) +importFrom(curl,new_handle) importFrom(dplyr,arrange) +importFrom(dplyr,case_when) importFrom(dplyr,filter) +importFrom(dplyr,full_join) importFrom(dplyr,mutate) importFrom(dplyr,select) importFrom(glue,glue) importFrom(rlang,.data) +importFrom(rlang,is_attached) importFrom(rlang,set_names) importFrom(rlang,warn) importFrom(tibble,as_tibble) +importFrom(utils,hsearch_db) +importFrom(utils,isS3method) diff --git a/R/document_universe.R b/R/document_universe.R index e508e0e..5cf55f0 100644 --- a/R/document_universe.R +++ b/R/document_universe.R @@ -15,20 +15,20 @@ document_universe_impl <- function(x, url_template = NULL) { } if (length(url_template) > 2L) { longer <- length(url_template) - cli::cli_abort("`url_template` must be of length 1 or 2, not {longer}.") + cli_abort("`url_template` must be of length 1 or 2, not {longer}.") } out <- mutate( out, - topic = dplyr::case_when( + topic = case_when( .data$type == "help" ~ to_href( .data$topic, - template = glue::glue(manual) + template = glue(manual) ), .data$type == "vignette" ~ to_href( .data$topic, - template = glue::glue(vignettes_template(vignettes)) + template = glue(vignettes_template(vignettes)) ), .default = .data$topic ) @@ -109,13 +109,13 @@ vignettes_template <- function(template) { #' document_universe(universe, template) document_universe <- function(x, url_template = NULL) { out <- document_universe_impl(x = x, url_template = url_template) - tibble::as_tibble(out) + as_tibble(out) } warn_unnattached <- function(x, doc = "package") { if (!all(attached(x))) { unattached <- x[!attached(x)] # nolint - cli::cli_warn(c( + cli_warn(c( "All packages should be attached to work properly.", x = "Not attached: {unattached}" )) @@ -143,7 +143,7 @@ tidy_reference <- function(data, strip_s3class) { } attached <- function(x) { - unlist(lapply(glue("package:{x}"), rlang::is_attached)) + unlist(lapply(glue("package:{x}"), is_attached)) } abort_unavailable_package <- function(data, x) { @@ -153,13 +153,13 @@ abort_unavailable_package <- function(data, x) { } is_unavailable <- x[!is_available] # nolint - cli::cli_abort("No pacakge matches '{is_unavailable}'.") + cli_abort("No pacakge matches '{is_unavailable}'.") } collapse_alias <- function(data, strip_s3class = FALSE) { out <- mutate( data, - alias = dplyr::case_when( + alias = case_when( !strip_s3class ~ may_strip_s3class(.data$alias, .f = identity), strip_s3class ~ may_strip_s3class(.data$alias, .f = s3_strip_class), ), diff --git a/R/dverse-package.R b/R/dverse-package.R index b1176ed..88c32fa 100644 --- a/R/dverse-package.R +++ b/R/dverse-package.R @@ -2,14 +2,23 @@ "_PACKAGE" ## usethis namespace: start +#' @importFrom cli cli_abort +#' @importFrom cli cli_warn +#' @importFrom curl curl_fetch_memory +#' @importFrom curl new_handle #' @importFrom dplyr arrange +#' @importFrom dplyr case_when #' @importFrom dplyr filter +#' @importFrom dplyr full_join #' @importFrom dplyr mutate #' @importFrom dplyr select #' @importFrom glue glue #' @importFrom rlang .data +#' @importFrom rlang is_attached #' @importFrom rlang set_names #' @importFrom rlang warn #' @importFrom tibble as_tibble +#' @importFrom utils hsearch_db +#' @importFrom utils isS3method ## usethis namespace: end NULL diff --git a/R/is_online.R b/R/is_online.R index 1e586fa..14465ed 100644 --- a/R/is_online.R +++ b/R/is_online.R @@ -21,7 +21,7 @@ is_online <- function(x) { is_online_once <- function(url) { tryCatch(error = function(e) FALSE, { - response <- curl::curl_fetch_memory(url, handle = curl::new_handle()) + response <- curl_fetch_memory(url, handle = new_handle()) identical(response$status_code, 200L) }) } diff --git a/R/s3_strip_class.R b/R/s3_strip_class.R index e16a6b4..abcdd2b 100644 --- a/R/s3_strip_class.R +++ b/R/s3_strip_class.R @@ -16,7 +16,7 @@ s3_strip_class_impl <- function(x) { ok <- logical(nfc) for (j in 2:nfc) { - ok[[j]] <- utils::isS3method( + ok[[j]] <- isS3method( f = paste(f_c[1:(j - 1)], collapse = "."), class = paste(f_c[j:nfc], collapse = ".") ) @@ -31,5 +31,5 @@ s3_strip_class_impl <- function(x) { } is_s3_method <- function(x) { - ifelse(startsWith(x, "."), FALSE, utils::isS3method(x)) + ifelse(startsWith(x, "."), FALSE, isS3method(x)) } diff --git a/R/search_documentation.R b/R/search_documentation.R index d92ec77..d49e542 100644 --- a/R/search_documentation.R +++ b/R/search_documentation.R @@ -1,6 +1,6 @@ search_documentation <- function() { docs <- suppressMessages( - Reduce(dplyr::full_join, utils::hsearch_db()) + Reduce(full_join, hsearch_db()) ) out <- set_names(docs, tolower)