Skip to main content

Module namespace

Module namespace 

Source
Expand description

Parser for R package NAMESPACE files.

NAMESPACE files use a simple directive-based DSL with function-call syntax. Each directive is one of:

  • export(name1, name2, ...) — export symbols
  • exportPattern("^[^.]") — export symbols matching a regex
  • import(pkg1, pkg2, ...) — import all exports from packages
  • importFrom(pkg, sym1, sym2, ...) — import specific symbols from a package
  • S3method(generic, class) or S3method(generic, class, method) — register S3 methods
  • useDynLib(pkg, ...) — load a shared library
  • exportClasses(cls1, cls2, ...) — export S4 classes
  • exportMethods(meth1, meth2, ...) — export S4 methods
  • importClassesFrom(pkg, cls1, cls2, ...) — import S4 classes from a package
  • importMethodsFrom(pkg, meth1, meth2, ...) — import S4 methods from a package

Lines starting with # are comments. Directives can span multiple lines (the parser collects text until balanced parentheses).

Structs§

DynLibDirective
A useDynLib directive.
PackageNamespace
A parsed R package NAMESPACE file.
S3MethodRegistration
An S3 method registration from the NAMESPACE file.

Enums§

NamespaceError
Errors that can occur when parsing a NAMESPACE file.

Functions§

collect_directives 🔒
Collect complete directives from a NAMESPACE file.
find_directive_after_if 🔒
Parse the argument content of a directive into individual string tokens.
parse_args 🔒
Arguments are comma-separated. Surrounding quotes (single or double) are stripped. Named arguments like .registration = TRUE are preserved as single tokens.
strip_comment 🔒
Strip a # comment from a line, respecting quoted strings.
unquote 🔒
Remove surrounding quotes from a string.