From 34f90745b19be50ed0109c56ad95014bb8f957cf Mon Sep 17 00:00:00 2001 From: Jakub Nowicki Date: Tue, 20 Aug 2024 14:56:18 +0200 Subject: [PATCH] docs: Add function examples. --- R/box_lsp.R | 7 ++++++- R/utils.R | 5 +++++ man/box_use_parser.Rd | 8 +++++++- man/use_box_lsp.Rd | 6 ++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/R/box_lsp.R b/R/box_lsp.R index 5a58cb8..8cbe1b6 100644 --- a/R/box_lsp.R +++ b/R/box_lsp.R @@ -38,7 +38,7 @@ process_module <- function(sym_name, signature, action) { action$parse(func_sig[[3L]]) } -#' Box::use Document Parser +#' 'box::use' Document Parser #' #' Custom \{languageserver\} parser hook for \{box\} modules. #' @@ -46,6 +46,11 @@ process_module <- function(sym_name, signature, action) { #' @param action A list of action functions from `languageserver:::parse_expr()`. #' @returns Used for side-effects provided by the `action` list of functions. #' +#' @examples +#' \dontrun{ +#' box_use_parser(expr = expression(box::use(fs)), action = new.env()) +#' } +#' #' @export box_use_parser <- function(expr, action) { call <- match.call(box::use, expr) diff --git a/R/utils.R b/R/utils.R index f4d2fde..c9ef5ce 100644 --- a/R/utils.R +++ b/R/utils.R @@ -3,6 +3,11 @@ #' @param file_path File name to append `{box.lsp}` configuration lines. #' @returns Writes configuration lines to `file_path`. #' +#' @examples +#' \dontrun{ +#' use_box_lsp() +#' } +#' #' @export use_box_lsp <- function(file_path = ".Rprofile") { rprofile <- fs::path_package("box.lsp", "Rprofile.R") diff --git a/man/box_use_parser.Rd b/man/box_use_parser.Rd index 0bf1229..469673b 100644 --- a/man/box_use_parser.Rd +++ b/man/box_use_parser.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/box_lsp.R \name{box_use_parser} \alias{box_use_parser} -\title{Box::use Document Parser} +\title{'box::use' Document Parser} \usage{ box_use_parser(expr, action) } @@ -17,3 +17,9 @@ Used for side-effects provided by the \code{action} list of functions. \description{ Custom \{languageserver\} parser hook for \{box\} modules. } +\examples{ +\dontrun{ + box_use_parser(expr = expression(box::use(fs)), action = new.env()) +} + +} diff --git a/man/use_box_lsp.Rd b/man/use_box_lsp.Rd index 42dcc65..4ab241a 100644 --- a/man/use_box_lsp.Rd +++ b/man/use_box_lsp.Rd @@ -15,3 +15,9 @@ Writes configuration lines to \code{file_path}. \description{ Configures a project to use \{box.lsp\} } +\examples{ +\dontrun{ + use_box_lsp() +} + +}