Title: | Convert Inline Comments to Documentation |
---|---|
Description: | Generates Rd files from R source code with comments. The main features of the default syntax are that (1) docs are defined in comments near the relevant code, (2) function argument names are not repeated in comments, and (3) examples are defined in R code, not comments. It is also easy to define a new syntax. |
Authors: | Toby Dylan Hocking [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph] |
Maintainer: | Toby Dylan Hocking <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 2023.9.4 |
Built: | 2024-11-10 05:45:08 UTC |
Source: | https://github.com/tdhock/inlinedocs |
Parse code
to r objs, then run all the parsers
and return the
documentation list.
apply.parsers(code, parsers = default.parsers, verbose = FALSE, ...)
apply.parsers(code, parsers = default.parsers, verbose = FALSE, ...)
code |
Character vector of |
parsers |
List of Parser Functions. |
verbose |
Echo names of Parser Functions? |
... |
Additional arguments to pass to Parser Functions. |
A list of extracted documentation from code
.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
List of classic parsers which were default before 2018.
"classic.parsers"
"classic.parsers"
combine lists or character strings
combine(x, y)
combine(x, y)
x |
x |
y |
y |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
combine
character strings by pasting them together
## S3 method for class 'character' combine(x, y)
## S3 method for class 'character' combine(x, y)
x |
x |
y |
y |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
combine
lists by adding elements or adding to existing elements
## S3 method for class 'list' combine(x, y)
## S3 method for class 'list' combine(x, y)
x |
x |
y |
y |
A list, same type as x
, but with added elements from y
.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
combine
NULL objects.
## S3 method for class 'NULL' combine(x, y)
## S3 method for class 'NULL' combine(x, y)
x |
x |
y |
y |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Remove comment prefix
and join lines of code to form a
documentation string.
decomment(comments)
decomment(comments)
comments |
Character vector of prefixed comment lines. |
String without prefixes or newlines.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
List of parsers to use by default with package.skeleton.dx
.
"default.parsers"
"default.parsers"
Names of Parser Functions that operate on the desc arg.
"descfile.names"
"descfile.names"
Make a Parser Function used to indicate that certain Rd files should not be generated.
do.not.generate(...)
do.not.generate(...)
... |
Character strings indicating Rd files without the .Rd suffix. |
A Parser Function that will delete items from the outer Documentation List.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
silly.pkg <- system.file("silly",package="inlinedocs") owd <- setwd(tempdir()) file.copy(silly.pkg,".",recursive=TRUE) ## define a custom Parser Function that will not generate some Rd ## files custom <- do.not.generate("SillyTest-class") parsers <- c(default.parsers,list(exclude=custom)) ## At first, no Rd files in the man subdirectory. man.dir <- file.path("silly","man") dir(man.dir) ## Running package.skeleton.dx will generate bare-bones files for ## those specified in do.not.generate, if they do not exist. package.skeleton.dx("silly",parsers) Rd.files <- c("SillyTest-class.Rd","silly.example.Rd") Rd.paths <- file.path(man.dir,Rd.files) stopifnot(all(file.exists(Rd.paths))) ## Save the modification times of the Rd files old <- file.info(Rd.paths)$mtime ## make sure there is at least 2 seconds elapsed, which is the ## resolution for recording times on windows file systems. Sys.sleep(4) ## However, it will NOT generate Rd for files specified in ## do.not.generate, if they DO exist already. package.skeleton.dx("silly",parsers) mtimes <- data.frame(old,new=file.info(Rd.paths)$mtime) rownames(mtimes) <- Rd.files mtimes$changed <- mtimes$old != mtimes$new print(mtimes) stopifnot(mtimes["SillyTest-class.Rd","changed"]==FALSE) stopifnot(mtimes["silly.example.Rd","changed"]==TRUE) unlink("silly",recursive=TRUE) setwd(owd)
silly.pkg <- system.file("silly",package="inlinedocs") owd <- setwd(tempdir()) file.copy(silly.pkg,".",recursive=TRUE) ## define a custom Parser Function that will not generate some Rd ## files custom <- do.not.generate("SillyTest-class") parsers <- c(default.parsers,list(exclude=custom)) ## At first, no Rd files in the man subdirectory. man.dir <- file.path("silly","man") dir(man.dir) ## Running package.skeleton.dx will generate bare-bones files for ## those specified in do.not.generate, if they do not exist. package.skeleton.dx("silly",parsers) Rd.files <- c("SillyTest-class.Rd","silly.example.Rd") Rd.paths <- file.path(man.dir,Rd.files) stopifnot(all(file.exists(Rd.paths))) ## Save the modification times of the Rd files old <- file.info(Rd.paths)$mtime ## make sure there is at least 2 seconds elapsed, which is the ## resolution for recording times on windows file systems. Sys.sleep(4) ## However, it will NOT generate Rd for files specified in ## do.not.generate, if they DO exist already. package.skeleton.dx("silly",parsers) mtimes <- data.frame(old,new=file.info(Rd.paths)$mtime) rownames(mtimes) <- Rd.files mtimes$changed <- mtimes$old != mtimes$new print(mtimes) stopifnot(mtimes["SillyTest-class.Rd","changed"]==FALSE) stopifnot(mtimes["silly.example.Rd","changed"]==TRUE) unlink("silly",recursive=TRUE) setwd(owd)
The .DocLink
class provides the basis for hooking together
documentation of related classes/functions/objects. The aim is that
documentation sections missing from the child are inherited from
the parent class.
Objects can be created by calls of the form new(DocLink ...)
name
:(character
) name of object
created
:(character
) how created
parent
:(character
) parent class or NA
code
:(character
) actual source lines
description
:(character
) preceding description block
No methods defined with class "DocLink" in the signature.
Convert ... to \dots
escape_dots(arg)
escape_dots(arg)
arg |
arg |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Parse R code
to extract inline documentation from comments around
each function. These are not able to be retreived simply by
looking at the "source" attribute. This is a Parser Function that
can be used in the parser list of package.skeleton.dx(). TODO:
Modularize this into separate Parsers Functions for S4 classes,
prefixes, ##<<blocks, etc. Right now it is not very clean!
extra.code.docs(code, objs, ...)
extra.code.docs(code, objs, ...)
code |
Code lines in a character vector containing multiple R objects to parse for documentation. |
objs |
The objects defined in the |
... |
ignored |
named list of lists, one for each object to document.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Apply all parsers
relevant to extract info from just 1 code file.
extract.docs.file(f, parsers = NULL, ...)
extract.docs.file(f, parsers = NULL, ...)
f |
File name of R code to read and parse. |
parsers |
Parser Functions to use to parse the code and extract documentation. |
... |
Other arguments to pass to Parser Functions. |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
f <- system.file("silly","R","silly.R",package="inlinedocs") extract.docs.file(f)
f <- system.file("silly","R","silly.R",package="inlinedocs") extract.docs.file(f)
Using the same conventions as for functions, definitions of S4 classes
in the form setClass("classname",...)
are also located and
scanned for inline comments.
extract.docs.setClass(doc.link)
extract.docs.setClass(doc.link)
doc.link |
DocLink object as created by |
Extraction of S4 class documentation is currently limited to expressions
within the source code which have first line starting with
setClass("classname"
. These are located from the source file
(allowing also for white space around the setClass
and (
).
Note that "classname"
must be a quoted character string;
expressions returning such a string are not matched.
For class definitions, the slots (elements of the
representation
list) fill the role of function
arguments, so may be documented by ##<<
comments on
the same line or ###
comments at the beginning of the
following line.
If there is no explicit title on the first line of setClass, then one is made up from the class name.
The class definition skeleton includes an Objects from the Class
section, to which any ##details<<
documentation chunks are
written. It is given a vanilla content if there are no specific
##details<<
documentation chunks.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Using the base parse
function, analyse the file to link
preceding "prefix" comments to each active chunk. Those comments form
the default description for that chunk. The analysis also looks for
S4 class "setClass" calls and R.oo setConstructorS3 and setMethodS3
calls in order to link the documentation of those properly.
extract.file.parse(code)
extract.file.parse(code)
code |
Lines of R source |
If the definition chunk does not contain a description, any immediately preceding sequence consecutive "prefix" lines will be used instead.
Class and method definitions can take several forms, determined by expression type:
Ordinary assignment of value/function;
Definition of S4 class;
Definition of S3 class using R.oo package;
Definition of method for S3 class using R.oo package.
Additionally, the value may be a name of a function defined elsewhere, in which case the documentation should be copied from that other definition. This is handled using the concept of documentation links.
The R.methodsS3::setMethodS3
calls introduce additional
complexity: they will define an additional S3 generic (which
needs documentation to avoid warnings at package build time)
unless one already exists. This also is handled by "linking"
documentation. A previously unseen generic is linked to the
first defining instances, subsequent definitions of that generic
also link back to the first defining instance.
Returns an invisible list of .DocLink objects.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Given source code of a function, return a list describing inline documentation in that source code.
extract.xxx.chunks(src, name.fun = "(unnamed function)", ...)
extract.xxx.chunks(src, name.fun = "(unnamed function)", ...)
src |
The source lines of the function to examine, as a character vector. |
name.fun |
The name of the function/chunk to use in warning messages. |
... |
ignored. |
For simple functions/arguments, the argument may also be
documented by appending ##<<
comments on the same line as the
argument name. Mixing this mechanism with ###
comment lines for
the same argument is likely to lead to confusion, as the ###
lines are processed first.
Additionally, consecutive sections of ##
comment
lines beginning with ##
xxx<<
(where
xxx is one of the fields: alias
, details
,
keyword
, references
, author
, note
,
seealso
, value
, title
or description
)
are accumulated and inserted in the relevant part of the .Rd
file.
For value
, title
, description
and function
arguments, these append to any text from "prefix"
(^###
) comment lines, irrespective of the order in the
source.
When documenting S4 classes, documentation from details
sections will appear under a section Objects from the Class
. That
section typically includes information about construction methods
as well as other description of class objects (but note that the
class Slots are documented in a separate section).
Each separate extra section appears as a new paragraph except that:
empty sections (no matter how many lines) are ignored;
alias
and
keyword
sections have special rules;
description
should be brief, so all such sections
are concatenated as one paragraph;
title
should
be one line, so any extra title
sections are
concatenated as a single line with spaces separating the
sections.
As a special case, the construct ##describe<<
causes
similar processing to the main function arguments to be
applied in order to construct a describe block within the
documentation, for example to describe the members of a
list. All subsequent "same line" ##<<
comments go into that
block until terminated by a subsequent ##
xxx<<
line.
Such regions may be nested, but not in such a way
that the first element in a describe
is another
describe
. Thus there must be at least one
##<<
comment between each pair of
##describe<<
comments.
When nested describe
blocks are used, a comment-only
line with ##end<<
terminates the current level only; any
other valid ##
xxx<<
line terminates
all open describe blocks.
Named list of character strings extracted from comments. For each
name N we will look for N{...} in the Rd file and replace it
with the string in this list (implemented in modify.Rd.file
).
alias
extras are automatically split at new lines.
keyword
extras are automatically split at white space,
as all the valid keywords are single words.
The "value" section of a .Rd file is implicitly a describe
block and ##
value
<<
acts accordingly. Therefore
it automatically enables the describe block itemization (##<< after
list entries).
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Create a fake package environment in a way that keeps S4 working (so there is a .packageName) and also conforms to byte-code interpreter requirements on environment structure, particularly ensuring that the created environment is a namespace. A similar procedure (with the exception of not deleting objects) is now in testthat (test_pkg_env).
fake_package_env()
fake_package_env()
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Copied from R-3.0.1, to support findGeneric.
findGeneric(fname, envir)
findGeneric(fname, envir)
fname |
fname |
envir |
envir |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Copied from R-3.0.1, to support fixPackageFileNames.
fixPackageFileNames(list)
fixPackageFileNames(list)
list |
list |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
For each object in the package that satisfies the criterion
checked by subfun
, parse source using FUN
and return the resulting
documentation list.
forall(FUN, subfun = function(x) TRUE)
forall(FUN, subfun = function(x) TRUE)
FUN |
Function to apply to each element in the package. |
subfun |
Function to select subsets of elements of the package, such as
is.function. subfun(x)==TRUE means |
A Parser Function.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
List of Parser Functions that can be applied to any object.
"forall.parsers"
"forall.parsers"
For each function in the package, do something.
forfun(FUN)
forfun(FUN)
FUN |
FUN |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Parsers for each function that are constructed automatically. This is a named list, and each element is a parser function for an individual object.
"forfun.parsers"
"forfun.parsers"
Copied from R-3.0.1, to support getKnownS3generics
.
get_internal_S3_generics(primitive = TRUE)
get_internal_S3_generics(primitive = TRUE)
primitive |
primitive |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Copied from R-3.0.1, to support getKnownS3generics
.
get_S3_primitive_generics(include_group_generics = TRUE)
get_S3_primitive_generics(include_group_generics = TRUE)
include_group_generics |
include_group_generics |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Copied from R-3.0.1, to support getKnownS3generics.
getKnownS3generics()
getKnownS3generics()
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Extract a function's source code.
getSource(fun.obj)
getSource(fun.obj)
fun.obj |
A function. |
Source code lines as a character vector.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Copied from R-3.0.1, to support getKnownS3generics
.
is_primitive_in_base(fname)
is_primitive_in_base(fname)
fname |
fname |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Figure out what the whitespace preceding the example code is, and then delete that from every line.
kill.prefix.whitespace(ex)
kill.prefix.whitespace(ex)
ex |
character vector of example code lines. |
Character vector of code lines with preceding whitespace removed.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Determines whether a function name
looks like an S3 generic function
leadingS3generic(name, env, ...)
leadingS3generic(name, env, ...)
name |
|
env |
environment to search for additional generics |
... |
ignored here |
This function is one of the default parsers, but exposed as
possibly of more general interest. Given a function name
of the form
x.y.z it looks for the generic function x applying to objects of class
y.z and also for generic function x.y applying to objects of class z.
Assumes that the first name
which matches any known
generics is the target generic function, so if both x and x.y
are generic functions, will assume generic x applying to objects
of class y.z
If a matching generic found returns a list with a single component:
.s3method |
a character vector containing generic |
If no matching generic functions are found, returns an empty list.
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
List of parser functions that operate on single objects. This list is useful for testing these functions.
"lonely"
"lonely"
f <- function # title ### description (x, ##<< arg x y ### arg y ){ ##value<< a list with elements list(x=x, ##<< original x value y=y, ##<< original y value sum=x+y) ##<< their sum ##end<< } src <- getSource(f) lonely$extract.xxx.chunks(src) lonely$prefixed.lines(src)
f <- function # title ### description (x, ##<< arg x y ### arg y ){ ##value<< a list with elements list(x=x, ##<< original x value y=y, ##<< original y value sum=x+y) ##<< their sum ##end<< } src <- getSource(f) lonely$extract.xxx.chunks(src) lonely$prefixed.lines(src)
Assemble some R code into a package and process it using R CMD check, stopping with an error if the check resulted in any errors or warnings.
make.package.and.check(f, parsers = default.parsers, verbose = TRUE)
make.package.and.check(f, parsers = default.parsers, verbose = TRUE)
f |
R code file name from which we will make a package |
parsers |
Parsers to use to make the package documentation. |
verbose |
print the check command line? |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Add inline documentation from comments to an Rd file automatically-generated by package.skeleton.
modify.Rd.file(N, pkg, docs, verbose = FALSE)
modify.Rd.file(N, pkg, docs, verbose = FALSE)
N |
Name of function/file to which we will add documentation. |
pkg |
Package name. |
docs |
Named list of documentation in extracted comments. |
verbose |
Cat messages? |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Names of Parser Functions that do NOT use the desc arg.
"non.descfile.names"
"non.descfile.names"
Parsers that operate only on R code, independently of the description file.
"nondesc.parsers"
"nondesc.parsers"
Generates Rd files for a package based on R code and DESCRIPTION metadata. After reading the pkgdir/R/*.R code files to find inline documentation (by default R code in *.r files will not be used for inlinedocs), writes docs to pkgdir/man/*.Rd files, possibly overwriting the previous files there.
package.skeleton.dx(pkgdir = "..", parsers = NULL, namespace = FALSE, excludePattern = "[.][rsqS]$", verbose = FALSE)
package.skeleton.dx(pkgdir = "..", parsers = NULL, namespace = FALSE, excludePattern = "[.][rsqS]$", verbose = FALSE)
pkgdir |
Package directory where the DESCRIPTION file lives. Your code should be in pkgdir/R. |
parsers |
List of Parser functions, which will be applied in sequence to
extract documentation from your code. Default NULL means to first
search for a definition in the variable "parsers" in
pkgdir/R/.inlinedocs.R, if that file exists. If not, we use the
list defined in options("inlinedocs.parsers"), if that is
defined. If not, we use the package global default in the variable
|
namespace |
A logical indicating whether a NAMESPACE file should be generated
for this package. If |
excludePattern |
A regular expression matching the files that are not to be processed e.g. because inlinedocs can not handle them yet (like generic function definitions). Default value means to only process inlinedocs in .R files. Set excludePattern=NULL to process all code files, e.g. *.r files. |
verbose |
show messages about parser functions used? |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
owd <- setwd(tempdir()) ## get the path to the silly example package that is provided with ## package inlinedocs testPackagePath <- file.path(system.file(package="inlinedocs"),"silly") ## copy example project to the current unlocked workspace that can ## be modified file.copy(testPackagePath,".",recursive=TRUE) ## generate documentation .Rd files for this package package.skeleton.dx("silly") ## check the package to see if generated documentation passes ## without WARNINGs. if(interactive()){ cmd <- sprintf("%s CMD check --as-cran silly",file.path(R.home("bin"), "R")) print(cmd) system(cmd) } ## cleanup: remove the test package from current workspace again unlink("silly",recursive=TRUE) setwd(owd)
owd <- setwd(tempdir()) ## get the path to the silly example package that is provided with ## package inlinedocs testPackagePath <- file.path(system.file(package="inlinedocs"),"silly") ## copy example project to the current unlocked workspace that can ## be modified file.copy(testPackagePath,".",recursive=TRUE) ## generate documentation .Rd files for this package package.skeleton.dx("silly") ## check the package to see if generated documentation passes ## without WARNINGs. if(interactive()){ cmd <- sprintf("%s CMD check --as-cran silly",file.path(R.home("bin"), "R")) print(cmd) system(cmd) } ## cleanup: remove the test package from current workspace again unlink("silly",recursive=TRUE) setwd(owd)
The primary mechanism of inline documentation is via consecutive
groups of lines matching the specified prefix
regular expression
"^###
" (i.e. lines beginning with "###
") are
collected as follows into documentation sections:
group starting at line 2 in the code
group following each function argument
group ending at the penultimate line of the code
These may be added to by use of the ##<<
constructs
described below.
prefixed.lines(src, ...)
prefixed.lines(src, ...)
src |
src |
... |
... |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
test <- function ### the description (x, ### the first argument y ##<< another argument ){ 5 ### the return value ##seealso<< foobar } src <- getSource(test) prefixed.lines(src) extract.xxx.chunks(src)
test <- function ### the description (x, ### the first argument y ##<< another argument ){ 5 ### the return value ##seealso<< foobar } src <- getSource(test) prefixed.lines(src) extract.xxx.chunks(src)
Print method for functions constructed using forall
.
## S3 method for class 'allfun' print(x, ...)
## S3 method for class 'allfun' print(x, ...)
x |
x |
... |
... |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
remove aliases to methodnames from the Rd file of a class automatically-generated by package.skeleton.
removeAliasesfrom.Rd.file(N, pkg, code)
removeAliasesfrom.Rd.file(N, pkg, code)
N |
Name of function/file to which we will add documentation. |
pkg |
Package name. |
code |
The |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Do find and replace for one element of an inner documentation list on 1 Rd file.
replace.one(torep, REP, txt, verbose = FALSE)
replace.one(torep, REP, txt, verbose = FALSE)
torep |
tag to find. |
REP |
contents of tag to put inside. |
txt |
text in which to search. |
verbose |
cat messages? |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
For unit tests, this is an easy way of getting a text
representation of the list result of extract.docs.file
.
save.test.result(f)
save.test.result(f)
f |
R code file with inlinedocs to process with |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
Check an R code file with inlinedocs to see if the
extract.docs.file
parser accurately extracts all the code inside!
The code file should contain a variable .result which is the
documentation list that you should get when you apply
extract.docs.file
to the file. We check for identity of elements
of elements of the list, so the order of elements should not
matter, and thus this should be a good robust unit test.
test.file(f, CRAN.checks = TRUE, verbose = FALSE)
test.file(f, CRAN.checks = TRUE, verbose = FALSE)
f |
File name of R code file with inlinedocs to parse and check. |
CRAN.checks |
try to make a package and run CRAN checks? |
verbose |
Show output? |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]
List of classic parsers which were default before 2018.
"test.parsers"
"test.parsers"
Regex for a whole word to code/link tags.
whole.word(...)
whole.word(...)
... |
... |
Toby Dylan Hocking <[email protected]> [aut, cre], Keith Ponting [aut], Thomas Wutzler [aut], Philippe Grosjean [aut], Markus Müller [aut], R Core Team [ctb, cph]