MyNixOS website logo
Description

Lint 'roxygen2'-Generated Documentation.

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.

roxylint

R-CMD-check

Lint 'roxygen2'-generated documentation

Quick Start

Modify your package's description file to add required package for your roxygen2 documentation

DESCRIPTION

Config/Needs/documentation: roxylint
Roxygen: list(markdown = TRUE, roclets = c("namespace", "rd", "roxylint::roxylint"))

By default, this will add linters for the tidyverse style guide. If you'd like to be explicit, you can declare this style yourself:

DESCRIPTION

Config/roxylint: list(linters = roxylint::tidy)

Now, the next time you document your package, you might see some messages about your formatting!

Tune your Linting

You can add in your own linters easily. Simply modify the linters field in the configuration list. Of course, if you feel that your linter would be more widely useful, feel free to open up a pull request to introduce it.

However, since structuring code in the DESCRIPTION file is not very pleasant, you can instead store your configurations in man/roxylint/meta.R.

For example, it might look something like this:

man/roxytypes/meta.R

list(
  linters = list(
    # pick and choose your tidy lints
    return = roxylint::lint_sentence_case,

    # use regular expressions to set simple rules
    title = "!!!$",

    # add custom messages with named lists
    details = list(
      "should be in 'ALL CAPS'" = "^[[:upper:] ]*$"
    ),

    # use functions for fine-grained control
    param = function(x, name, description, ...) {
      n_caps <- nchar(gsub("[^[:upper:]]", "", description))
      if (n_caps < nchar(description) / 2)
        warning("descriptions should be at least 50% CaPiTALiZeD")
    },

    # use multiple rules in a list
    section = list(
      "should not have frowny faces" = ":\\(",
      function(x, ...) if (grepl(":\\)", x$raw)) message("nice! very happy :)")
    ),

    # prevent other packages from registering rules with a `NULL`
    yell = NULL,

    # or prevent aditional rules by ending a list with a `NULL`
    return = list(
      "^Returns ",
      NULL
    )
  )
)

With these in place, you'll start getting alerts when you're deviating from your style.

ℹ [check_linter.R:1] @title raw value does not match '!!!$'
ℹ [check_linter.R:6] @param descriptions should be at least 50% CaPiTALiZeD
ℹ [check_linter.R:13] @return descriptions should be 'Sentence case' and end in a period

Register Linters

If you're building a package that provides its own roxygen2 tags, you can also register default linters.

DESCRIPTION

Enhances:
    roxylint
.onLoad <- function(libname, pkgname) {
  if (requireNamespace("roxylint", quietly = TRUE)) {
    roxylint::register_linters(
      yell = "^[[:upper:] ]*$"
    )
  }
}
Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows