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 function or character regular expression that should be matched, or a list of either. See details for more information.

tag

A roxygen2::roxy_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)


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 DESCRIPTION or the root path of a package, depending on the context of the function.

Format

An object of class environment of length 0.

Functions


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

A roxygen2::roxy_tag().

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

A roxygen2::roxy_tag().

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 roxygen2::roxy_tag() to use as context for the alert.

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 roxygen2::roxy_tag() that is the subject of linting.

...

Additional arguments unused.

name, description

Used for roxygen2::roxy_tag()-specific linters.

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


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().