[inlinedocs] tabs before comments and symbols, S3 methods

Keith Ponting k.ponting at aurix.com
Mon Apr 19 11:14:41 CEST 2010


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


More information about the Inlinedocs-support mailing list