Skip to content

How to use custom options in DESCRIPTION for custom roxygen2 roclets? #1716

@coatless

Description

@coatless

What is the recommended approach for passing custom options to custom roclets?

Problem

I'm developing a custom roxygen2 roclet and need to pass custom configuration options via the Roxygen field in the DESCRIPTION file. However, load_options() throws a warning for any options not in the predefined list of supported options.

Current Setup

DESCRIPTION file:

Roxygen: list(markdown = TRUE, load = "installed", custom_option = "my_value")

Issue:

When load_options() is called, it generates a warning:

Unknown Roxygen options custom_option.
Supported options: roclets, packages, load, old_usage, markdown, r6, current_package, rd_family_title, knitr_chunk_options, restrict_image_formats

Code Reference

The warning originates from load_options() which explicitly checks for unknown options:

unknown_opts <- setdiff(names(opts), names(defaults))
if (length(unknown_opts) > 0) {
  warn(paste0(
    "Unknown Roxygen options ", paste(unknown_opts, collapse = ", "), ".\n",
    "Supported options: ", paste(names(defaults), collapse = ", ")
  ))
}

Expected Behavior

Ideally, custom roclets should be able to access their configuration options via roxy_meta_get() without triggering warnings for legitimate custom options.

Environment

  • roxygen2 version: 7.3.2
  • R version: 4.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions