formalize.package
for would-be packages that have an existing NAMESPACE file and that have been informally documented using flatdoc
. It tries to work out which packages should be imported, which functions are meant to be exported, and which should be registered as S3 methods.make.NAMESPACE( pos=1, path=attr( pos.to.env( pos), "path"))
formalize.package
will call make.NAMESPACE
for you if necessary. If make.NAMESPACE
is applied to proto-package "mypack", then it will produce a file called NAMESPACE in the "mypack/mypack" directory. The NAMESPACE file will consist of (maybe) a call to import
, (definitely) a call to export
with all the function names in quotes, and (maybe) a series of calls to S3Method
. There is no attempt to handle S4 methods.
The imported packages are those listed in the "Depends:" field of the DESCRIPTION file.
The exported functions are all those in find.documented(doctype="any")
, plus any functions that have a non-NULL export.me
attribute. The attribute mechanism is useful for a function such as evaluator
in the formalize.package
will incorporate any undocumented export.me
functions in the "mypack-internal.Rd" file, so that RCMD CHECK will be happy.
The S3 methods are all the functions whose names start "generic.", where "generic" is any element of the character vector .knownS3Generics
in package:base
-- except any functions with a non-NULL export.me
attribute. You can use the attribute mechanism to prevent "methodization" of functions that look like methods but aren't really, such as as.data.frame.I
in the S3Method
statements rather than export
, you must ensure that the generic name has been added to .knownS3Generics
.formalize.package
, flatdoc