Learn R Programming

cnd (version 0.1.1)

cnd_document: Document your conditions

Description

Documents your conditions() and conditions()

Usage

cnd_document(
  package = get_package(),
  registry = package,
  file = file.path("R", paste0(package, "-cnd-conditions.R")),
  cleanup = TRUE
)

cnd_section(fun)

Value

  • cnd_document() Conditional on the file argument:

    • when file is a connection, the connection object

    • when file is a path, the path

    • when file is NULL, a character vector of the documentation

    • if no conditions are found, a warning is thrown and NULL is returned

  • cnd_section() A character vector of the documentation

Arguments

package

The package to document

registry

The name of the registry

file

The file to save the documentation. This can be a file path, a connection object, or NULL. When file is a path, the directory of the path is searched for files containing # % Generated by cnd: do not edit by hand. These are removed if they are not the same as the generated documentation.

cleanup

If FALSE will not remove files containing # % Generated by cnd: do not edit by hand

fun

The name of a function

conditions

Conditions are generated through the {cnd} package. The following conditions are associated with this function:

cnd:cnd_document_conditions/warning

Documentation will fail when no conditions are found. You may be executing cnd_document() too early, before conditions have been registered. You can try to find your conditions with conditions().

cnd:cnd_document_file/error

The file argument to cnd_document() must be a file path, a connection object, or NULL to return the documentation as a character vector. The default value should be suitable for standard use cases.

cnd:cnd_document_pkg_reg/error

Both package and registry must be set to document conditions.You can set a registry by adding cnd_create_registry() calls to your package code.

cnd:cnd_generated_cleanup/message

Some files created during the documentation process may become obsolete while updating your conditions.

cnd:cnd_generated_write/condition

This condition is signaled when cnd_document() needs to write new documentation files.

For more conditions, see: cnd-cnd-conditions

Examples

Run this code
file <- file()
cnd_document("cnd", file = file)
readLines(file)

cnd_section("cnd")

Run the code above in your browser using DataLab