[Roxygen-devel] [roxygen2] More explicit error messages?

Renaud Gaujoux renaud at cbio.uct.ac.za
Wed Sep 21 18:45:21 CEST 2011



On 21/09/2011 18:18, Hadley Wickham wrote:
> On Wed, Sep 21, 2011 at 11:10 AM, Renaud Gaujoux<renaud at cbio.uct.ac.za>  wrote:
>> It was very straightforward indeed.
>> Patching line 324 of roclet-rd.R with the following seems to do the trick:
>>
>> if (is.null(name)){
>>     # get the location and filename from srcref
>>     ll<- partitum$srcref$lloc
>>     stop("Missing name in block ", basename(partitum$srcref$filename),
>> ":lines ", ll[1], "-", ll[3])
>> }
>>
>> More verbose error messages for other types of errors (e.g. related to wrong
>> usage of roxygen flags) would still be nice to have as well, but this at
>> least allows to pinpoint very problematic blocks.
> It would be even better to pull that out into a separate function:
>
> roxygen_stop<- function(msg, srcref) {
>    ll<-srcref$lloc
>    stop(msg, "\n", "In: ",  basename(srcref$filename),  ":lines ",
> ll[1], "-", ll[3])
> }
>
> then replace all uses of stop (and similarly for warning).
>
> A patch along those lines would be greatly appreciated!
>
I am happy to try to provide such a patch.

>> This brought me to another question (which might need a separate post
>> though): it seems that union class names are not extracted (throws the
>> error: Missing name).
> You'll need to provide more details on that one.
If one puts roxygen documentation before a statement setClassUnion one 
gets the error of Missing name at the line of setClassUnion.
I think it is because this statement is not known to roxygen2 parser.
Adding the following to roclet-rd.R makes it aware it, but I am not sure 
if the name 'S4class' is correct in this case:

register.srcref.parser('setClassUnion', function(call, env) {
   list(S4class = as.character(call$name))
})

Renaud

> Hadley
>
>



###

UNIVERSITY OF CAPE TOWN 

This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity.

###
 



More information about the Roxygen-devel mailing list