From e8282764e0083569ec5ed59f93c01f778187b04b Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Wed, 20 Sep 2023 14:07:17 +0200 Subject: [PATCH] Export `dev_topic_index()` (#258) Closes #257 --- NAMESPACE | 1 + NEWS.md | 2 ++ R/dev-help.R | 9 +++++---- R/dev-topic.R | 6 +++++- man/dev_help.Rd | 14 ++++++++++---- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e7e540d0..cc2a17b5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ export(dev_example) export(dev_help) export(dev_meta) export(dev_topic_find) +export(dev_topic_index) export(dev_topic_index_reset) export(has_tests) export(imports_env) diff --git a/NEWS.md b/NEWS.md index a0c9fb3d..7ca9d26f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pkgload (development version) +* `dev_topic_index()` is now exported (#257). + * Fix handling of active bindings inside a package during unloading (#255, @klmr). diff --git a/R/dev-help.R b/R/dev-help.R index 648a7ba4..7d017a6c 100644 --- a/R/dev-help.R +++ b/R/dev-help.R @@ -1,9 +1,10 @@ #' In-development help for package loaded with devtools #' -#' `dev_help` searches for source documentation provided in -#' packages loaded by devtools. To improve performance, the `.Rd` files -#' are parsed to create to index once, then cached. Use -#' `dev_topic_index_reset` to clear that index. +#' `dev_help()` searches for source documentation provided in packages +#' loaded by devtools. To improve performance, the `.Rd` files are +#' parsed to create to index once, then cached. Use +#' `dev_topic_index_reset()` to clear that index. You can manually +#' retrieve the index for a local package with `dev_topic_index()`. #' #' @param topic name of help to search for. #' @param dev_packages A character vector of package names to search within. diff --git a/R/dev-topic.R b/R/dev-topic.R index 728f1eb7..f465be70 100644 --- a/R/dev-topic.R +++ b/R/dev-topic.R @@ -79,6 +79,10 @@ dev_topic_path <- function(topic, path = ".") { # Cache ------------------------------------------------------------------- dev_topic_indices <- new.env(parent = emptyenv()) + +#' @rdname dev_help +#' @param path Path to package. +#' @export dev_topic_index <- function(path = ".") { path <- pkg_path(path) package <- pkg_name(path) @@ -89,9 +93,9 @@ dev_topic_index <- function(path = ".") { dev_topic_indices[[package]] } -#' @export #' @rdname dev_help #' @param pkg_name Name of package. +#' @export dev_topic_index_reset <- function(pkg_name) { if (exists(pkg_name, dev_topic_indices)) { rm(list = pkg_name, envir = dev_topic_indices) diff --git a/man/dev_help.Rd b/man/dev_help.Rd index 201cdfdc..eb94fadd 100644 --- a/man/dev_help.Rd +++ b/man/dev_help.Rd @@ -3,6 +3,7 @@ \name{dev_help} \alias{dev_help} \alias{dev_topic_find} +\alias{dev_topic_index} \alias{dev_topic_index_reset} \title{In-development help for package loaded with devtools} \usage{ @@ -15,6 +16,8 @@ dev_help( dev_topic_find(topic, dev_packages = NULL) +dev_topic_index(path = ".") + dev_topic_index_reset(pkg_name) } \arguments{ @@ -30,13 +33,16 @@ If \code{NULL}, defaults to all packages loaded by devtools.} \item{type}{of html to produce: \code{"html"} or \code{"text"}. Defaults to your default documentation type.} +\item{path}{Path to package.} + \item{pkg_name}{Name of package.} } \description{ -\code{dev_help} searches for source documentation provided in -packages loaded by devtools. To improve performance, the \code{.Rd} files -are parsed to create to index once, then cached. Use -\code{dev_topic_index_reset} to clear that index. +\code{dev_help()} searches for source documentation provided in packages +loaded by devtools. To improve performance, the \code{.Rd} files are +parsed to create to index once, then cached. Use +\code{dev_topic_index_reset()} to clear that index. You can manually +retrieve the index for a local package with \code{dev_topic_index()}. } \examples{ \dontrun{