docr.clean_fun: Build a clean and set-formatted function

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/docr_clean_fun.R

Description

docr.clean_fun

Usage

1
2
docr.clean_fun(fun_name = NULL, trim_blanks = FALSE, rm_comments = FALSE,
  do_cat = TRUE)

Arguments

fun_name

The name of the function to be rebuilt

trim_blanks

Should any carriage returns or empty lines be removed from the source code.

rm_comments

Should the comments in the source script of the function be removed.

do_cat

Should the output be printed to the console by calling cat.

Details

If a function is written at the command line, or in a file with no documentation, this function will take the function name, in a quoted variable state, and rebuild the function in the same-formatted structure as when it was initially written.

Value

The structured function.

Author(s)

Carl S.A. Boneri, carl@gmail.com

See Also

Other Documentation functions: docr.author, docr.defaults_prompt, docr.defaults, docr.describe_df, docr.example_df, docr.family, docr.fun, docr.has_defaults, docr.install_r_only, docr.make_license, docr.meta_private, docr.meta_public, docr.param

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# From the Base package \code{\link{grep}}

> docr.clean_fun('grep')
grep <- function (pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE,
                  fixed = FALSE, useBytes = FALSE, invert = FALSE)
{
  if (!is.character(x))
    x <- structure(as.character(x), names = names(x))
  .Internal(grep(as.character(pattern), x, ignore.case, value,
                 perl, fixed, useBytes, invert))
}

# From the command line..we create the following:
paste.html <- function(x){
   htmltools::HTML(paste0(x, collapse = "\n"))
}

# Notice the output is the same as the written style, to match the author's
# preference.

> docr.clean_fun('paste.html')
paste.html <- function(x){
 htmltools::HTML(paste0(x, collapse = "\n"))
}

CarlBoneri/roxydoc2 documentation built on Nov. 6, 2019, 8:01 a.m.