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 symbolsexportPattern("^[^.]")— export symbols matching a regeximport(pkg1, pkg2, ...)— import all exports from packagesimportFrom(pkg, sym1, sym2, ...)— import specific symbols from a packageS3method(generic, class)orS3method(generic, class, method)— register S3 methodsuseDynLib(pkg, ...)— load a shared libraryexportClasses(cls1, cls2, ...)— export S4 classesexportMethods(meth1, meth2, ...)— export S4 methodsimportClassesFrom(pkg, cls1, cls2, ...)— import S4 classes from a packageimportMethodsFrom(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§
- DynLib
Directive - A
useDynLibdirective. - Package
Namespace - A parsed R package NAMESPACE file.
- S3Method
Registration - An S3 method registration from the NAMESPACE file.
Enums§
- Namespace
Error - 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 = TRUEare preserved as single tokens. - strip_
comment 🔒 - Strip a
#comment from a line, respecting quoted strings. - unquote 🔒
- Remove surrounding quotes from a string.