Title: | Lint 'roxygen2'-Generated Documentation |
Version: | 0.1.0 |
Description: | Provides formatting linting to 'roxygen2' tags. Linters report 'roxygen2' tags that do not conform to a standard style. These linters can be a helpful check for building more consistent documentation and to provide reminders about best practices or checks for typos. Default linting suites are provided for common style guides such as the one followed by the 'tidyverse', though custom linters can be registered by other packages or be custom-tailored to a specific package. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
URL: | https://github.com/openpharma/roxylint, https://openpharma.github.io/roxylint/ |
BugReports: | https://github.com/openpharma/roxylint/issues |
Imports: | utils, cli, roxygen2 |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2024-02-16 22:59:41 UTC; root |
Author: | Doug Kelkhoff [aut, cre] |
Maintainer: | Doug Kelkhoff <doug.kelkhoff@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-02-19 16:40:02 UTC |
Add linters
Description
Add linters
Usage
add_linters(config, tag, linters, overwrite = FALSE)
Arguments
config |
A config object to add linters to. |
tag |
The name of the tag to which to add linters. |
linters |
New linters to add. |
overwrite |
A logical value indicating whether existing linters should be overwritten. |
Value
NULL
.
Apply 'roxygen2' linters
Description
Provided a list of linters for a given tag, iterate over linters to raise alerts during the documentation process.
Usage
check_linter(linters, tag, ...)
## Default S3 method:
check_linter(linters, tag, ...)
## S3 method for class 'list'
check_linter(linters, tag, ...)
## S3 method for class ''function''
check_linter(linters, tag, ...)
## S3 method for class 'character'
check_linter(linters, tag, message = NULL, ...)
Arguments
linters |
A linters specification, either a |
tag |
|
... |
Additional arguments unused. |
message |
An optional message to use for an alert. |
Value
TRUE
, invisibly. However, this function is primarily used for its
side-effect of raising alerts during documentation.
Methods (by class)
-
check_linter(default)
: By default, no linting is performed -
check_linter(list)
: Alist
offunction
s orcharacter
regular expressions.If a
character
value is named, the name is used as the message for a alert that is raised when the expression does not match. -
check_linter(`function`)
: Afunction
to evaluate for the given tagfunction
's are evaluated with the following arguments:The contents of the tag's
$val
, as named arguments
Because the number of arguments might not be readily apparent, any function should accept a trailing
...
argument.Provided
function
s may print lint output, or signal lint output with messages or warnings. Acli::cli_alert()
will reflect the severity of the function used to emit the output. -
check_linter(character)
: Acharacter
regular expressions.If a
character
value is found, its value is assumed to be a regular expression which must match a given tag'sraw
content (the text as it appears in theroxygen2
header).
Configuration
Description
Various functions for loading, caching and performing configured behaviors using a user-supplied configuration file.
Usage
.registered
config_load(path = getwd(), cache = TRUE)
config_find_from(path)
config_from_desc(path)
config_from_file(path)
Arguments
path |
A file path to use when searching for a config file. Either the
file path to a |
Format
An object of class environment
of length 0.
Functions
-
config_load()
: Load the contents of a config into an environment -
config_find_from()
: Load a configuration from a path -
config_from_desc()
: Load a configuration from a DESCRIPTION file -
config_from_file()
: Load a configuration from a dotfile
Check whether a given tag accepts new linters
Description
Linters can be configured to disallow new linter additions by providing a
trailing NULL
value to a list, or setting the value itself to NULL
.
Usage
config_tag_accepts_linters(config, tag)
Arguments
config |
A config object to add linters to. |
tag |
The name of the tag to which to add linters. |
Get that tag!
Description
Tools for inspecting roxygen2::roxy_tag()
s. This can be helpful for
exploring the intermediate tag objects. For example, you can use this
function to generate a tag and explore the named values in $val
.
Usage
demo_tag(str)
Arguments
str |
A 'roxygen2' tag string. |
Value
Examples
demo_tag("@param var abc")
Format a tag for alert context
Description
Format a tag for alert context
Usage
format_tag_prefix(x)
Arguments
x |
Value
A formatted string.
If-not-null-else
Description
If-not-null-else
Usage
lhs %||% rhs
Capture output and re-emit as a cli alert
Description
Capture output and re-emit as a cli alert
Usage
into_roxy_alert(tag, expr)
Arguments
tag |
A |
expr |
An expression to evaluate. |
Value
TRUE
, invisibly.
Assorted linters
Description
Preconfigured linters, either as a collective list of linters or individually. "tidy" linters implement guidelines from the tidyverse style guide.
Usage
lint_starts_lowercase(x, ...)
lint_full_stop(x, ...)
lint_no_full_stop(x, ...)
lint_sentence_case(x, ...)
lint_title_case(x, ...)
tidy_title(x, ...)
tidy_param(x, name, description, ...)
tidy_return(x, ...)
tidy_seealso(x, ...)
tidy
Arguments
x |
A |
... |
Additional arguments unused. |
name , description |
Used for |
Format
An object of class list
of length 4.
Details
Refer to the individual roxygen2::roxy_tag()
for the respective tag for
argument details.
Functions
-
lint_starts_lowercase()
: Lowercase start linting. (uses$raw
forroxygen2::roxy_tag()
s) -
lint_full_stop()
: Ends in a full stop. (uses$raw
forroxygen2::roxy_tag()
s) -
lint_no_full_stop()
: Does not end in a full stop. (uses$raw
forroxygen2::roxy_tag()
s) -
lint_sentence_case()
: Sentence case linting (uses$raw
forroxygen2::roxy_tag()
s) -
lint_title_case()
: Title case linting -
tidy_title()
: Tidy 'Sentence case' titles -
tidy_param()
: Tidy 'Sentence case'@param
definitions -
tidy_return()
: Tidy 'Sentence case'@return
definitions -
tidy_seealso()
: Tidy 'Sentence case'@seealso
definitions -
tidy
: A list of all tidyverse style guide inspired linters
Register linters for new tags
Description
A registration mechanism for other packages to provide linters, either for custom tags or to implement their own linting styles.
Usage
register_linters(..., linters = list(...), .overwrite = FALSE)
Arguments
... |
Linters to register, with parameter names used to identify the associated tag. |
linters |
Optionally, provide a named list of linters directly. |
.overwrite |
Whether existing linters should be overwritten. Intended to be used sparingly. For example, this could be used to implement an entire new style guide without inheriting defaults. |
Value
TRUE
, invisibly.
Roclet for 'roxygen2' style linting
Description
Roclets used to embed linters during documentation. To use, add the roclet in
your DESCRIPTION
file.
Usage
roxylint()
Details
Config/Needs/documentation: roxylint Roxygen: list( markdown = TRUE, roclets = c("namespace", "rd", "roxylint::roxylint") )
Value
A roxylint
roxygen2::roclet()
.