Package 'roxylint'

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

Help Index


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)

  • check_linter(default): By default, no linting is performed

  • check_linter(list): A list of functions 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:

    1. The roxygen2::roxy_tag()

    2. 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 functions 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).


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")

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

  • 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


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