[inlinedocs] tabs before comments and symbols, S3 methods

Keith Ponting k.ponting at aurix.com
Thu Apr 22 12:20:48 CEST 2010


I have just committed a revision to the setMethodS3 handling which
eliminates the warnings under R2.10.1, with the following notes:

Further fixes for S3 methods declared with setMethodS3

1) automatically generates \method{}{} markup which should be correct if
and only if the generic name is everything up to but not including the
first period in the function name. Thus this will not work properly if a
generic function has a name like "my.generic" so that the specific
function
is "my.generic.my_type".

2) fix for behaviour of package.skeleton, which, as used within this
package, for a function "[[.Distribution" generates a file with name
"z[[.Distribution.Rd"

3) prints S3method calls suitable for inclusion in a NAMESPACE file

The mechanism depends on the parse of the source file picking up and
setting the "created" field to "setMethodS3". Something similar might
work
for other ways of creating S3 generics, but I am not currently clear how
to
pick those up reliably.


Keith

Keith Ponting
Aurix Ltd, Malvern WR14 3SZ  UK

> -----Original Message-----
> From: inlinedocs-support-bounces at lists.r-forge.r-project.org
> [mailto:inlinedocs-support-bounces at lists.r-forge.r-project.org] On
> Behalf Of Keith Ponting
> Sent: 19 April 2010 10:15
> To: Thomas Wutzler
> Cc: inlinedocs-support at r-forge.wu-wien.ac.at
> Subject: Re: [inlinedocs] tabs before comments and symbols, S3 methods
> 
> Hello Thomas,
> 
> I added some support for S3 methods but only when they are declared
via
> the useful setMethodS3/setConstructorS3 from the R.oo package, so
> somewhat limited support for S3 methods is present.
> 
> If you are looking to extend this, then note that there are two
slightly
> different ways of analysing package code used within inlinedocs,
either
> of which might be a good place to start - I do not know enough about
> general use of S3 methods to comment further:
> 1) sys.source the file into an environment and inspect that
environment,
> which is very good for standard function definitions;
> 2) parse the package source file(s) (via extract.file.parse) and
inspect
> the parse tree - this was necessary to handle S4 setClass and the
> set{Method,Constructor}S3 calls.
> There are various comments such as "not sure what to do with these
yet"
> which I left in the source of extract.file.parse for some of the S4
> class calls, such as setMethod.
> 
> I'm glad you like inlinedocs.
> 
> Keith Ponting
> Aurix Ltd, Malvern WR14 3SZ  UK
> > -----Original Message-----
> > From: inlinedocs-support-bounces at lists.r-forge.r-project.org
> > [mailto:inlinedocs-support-bounces at lists.r-forge.r-project.org] On
> > Behalf Of Thomas Wutzler
> > Sent: 16 April 2010 18:42
> > To: inlinedocs-support at lists.r-forge.r-project.org
> > Subject: [inlinedocs] tabs before comments and symbols, S3 methods
> >
> > Dear Keith Ponting and Toby Dylan Hocking
> >
> > thanks very much for this package!
> > It reduces redundancies and helps very much to keep documentation
and
> > code consistent.
> >
> > I two questions or a feature suggestions:
> >
> > 1) I use source formatting that uses tabs and and current version
bof
> > inlinedocs reaks when trying to extract the parameter names with
tabs
> > before, because the label is not correctly parsed. Also I would like
> to
> > allow indented comments like
> >
> > traceback.curr <- function(
> > 	### prints the current function calls, deepest on top
> > 	collapse=NULL
> > 	### an optional character string to separate the results.
> > 	,someOtherArgument
> > ){}
> >
> > (there are tabs not spaces in the real file)
> >
> > Therefore, I suggest the following changes prefix <- "^[ \t]*###[
\t]"
> > #changed the pattern to handle tabs
> >
> > in extract_doc_chunk, line 14 in the stable version add support for
\t
> > and , and remove trainling spaces
> >
> > lab <- if (end + 1 == length(code))
> >             "value"
> >         else if (start == 2)
> >             "description"
> >         else if (0 == length(grep("^\\s*#", code[start - 1], perl =
> > TRUE))) {
> > 	    #strip leading white spaces and brackets and ,
> >             arg <- gsub("^[ \t(,]*", "", code[start - 1])
> >             arg <- gsub("^([^=,]*)[=,].*", "\\1", arg)
> > 	    #remove trailing whitespaces
> >             arg <- gsub("^(.*)[ \t]+$*", "\\1", arg)
> >             arg <- gsub("...", "\\dots", arg, fix = TRUE)
> >             paste("item{", arg, "}", sep = "")
> >         }
> >         else {
> >             next
> >         }
> >
> >
> > 2) Is it already possible somehow to parse for S3 methods and insert
> the
> > \method markup instead of the full name.
> >
> > R CMD check  on 2.10.1 complains:
> > The \usage entries for S3 methods should use the \method markup and
> not
> > their full name.
> >
> >
> > Thanks again for your work !!
> >
> > Best regards
> > Thomas Wutzler
> >
> > _______________________________________________
> > Inlinedocs-support mailing list
> > Inlinedocs-support at lists.r-forge.r-project.org
> >
>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/inlinedocs-
> > support
> _______________________________________________
> Inlinedocs-support mailing list
> Inlinedocs-support at lists.r-forge.r-project.org
>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/inlinedocs-
> support


More information about the Inlinedocs-support mailing list