Title: | Lint 'roxygen2'-Generated Documentation |
---|---|
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. |
Authors: | Doug Kelkhoff [aut, cre] |
Maintainer: | Doug Kelkhoff <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-16 03:18:36 UTC |
Source: | https://github.com/openpharma/roxylint |
Provided a list of linters for a given tag, iterate over linters to raise alerts during the documentation process.
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, ...)
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, ...)
linters |
A linters specification, either a |
tag |
|
... |
Additional arguments unused. |
message |
An optional message to use for an alert. |
TRUE
, invisibly. However, this function is primarily used for its
side-effect of raising alerts during documentation.
check_linter(default)
: By default, no linting is performed
check_linter(list)
: A list
of function
s or character
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`)
: A function
to evaluate for the given tag
function
'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. A cli::cli_alert()
will reflect the severity of the
function used to emit the output.
check_linter(character)
: A character
regular expressions.
If a character
value is found, its value is assumed to be a regular
expression which must match a given tag's raw
content (the text as it
appears in the roxygen2
header).
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
.
demo_tag(str)
demo_tag(str)
str |
A 'roxygen2' tag string. |
demo_tag("@param var abc")
demo_tag("@param var abc")
Preconfigured linters, either as a collective list of linters or individually. "tidy" linters implement guidelines from the tidyverse style guide.
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
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
x |
A |
... |
Additional arguments unused. |
name , description
|
Used for |
An object of class list
of length 4.
Refer to the individual roxygen2::roxy_tag()
for the respective tag for
argument details.
lint_starts_lowercase()
: Lowercase start linting. (uses $raw
for roxygen2::roxy_tag()
s)
lint_full_stop()
: Ends in a full stop. (uses $raw
for roxygen2::roxy_tag()
s)
lint_no_full_stop()
: Does not end in a full stop. (uses $raw
for roxygen2::roxy_tag()
s)
lint_sentence_case()
: Sentence case linting (uses $raw
for roxygen2::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
A registration mechanism for other packages to provide linters, either for custom tags or to implement their own linting styles.
register_linters(..., linters = list(...), .overwrite = FALSE)
register_linters(..., linters = list(...), .overwrite = FALSE)
... |
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. |
TRUE
, invisibly.
Roclets used to embed linters during documentation. To use, add the roclet in
your DESCRIPTION
file.
roxylint()
roxylint()
Config/Needs/documentation: roxylint Roxygen: list( markdown = TRUE, roclets = c("namespace", "rd", "roxylint::roxylint") )
A roxylint
roxygen2::roclet()
.