From murdoch@dunc@n @ending from gm@il@com  Thu Jul 12 15:21:51 2018
From: murdoch@dunc@n @ending from gm@il@com (Duncan Murdoch)
Date: Thu, 12 Jul 2018 09:21:51 -0400
Subject: [Rd] Top level \Sexpr and R CMD check
In-Reply-To: <CABtg=KkNXXPBg+6yzQZ2FOdWsUqZj0xnbUAaOu=-ZG7pGUOvHQ@mail.gmail.com>
References: <CABtg=KkE7gNvho-PLvsS-48yOR5nVTTSsekf35uLS4JJiZmjjg@mail.gmail.com>
 <eaf1c672-fb4c-5327-9b5a-4349ef75eec7@gmail.com>
 <CABtg=KkNXXPBg+6yzQZ2FOdWsUqZj0xnbUAaOu=-ZG7pGUOvHQ@mail.gmail.com>
Message-ID: <b03ecf4b-f59b-eed6-ddb2-4788a4cd98ef@gmail.com>

On 12/07/2018 7:30 AM, G?bor Cs?rdi wrote:
> On Thu, Jul 12, 2018 at 12:23 PM Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>>
>> On 12/07/2018 6:33 AM, G?bor Cs?rdi wrote:
>>> I would like to create \examples{} in the manual dynamically, and
>>> while it is possible to do this with a \Sexpr at the top level, R CMD
>>> check issues a warning for it. (See below.)
>>>
>>> Is it intentional that \Sexpr is not allowed at the top level?  The Rd
>>> grammar allows this, but R CMD check does not.
>>>
>>> Is there any other way to generate/modify the \examples{} section dynamically?
>>
>> That looks like a bug in the check code, but wouldn't it be possible to
>> work around it with something like this?
>>
>> \examples{
>> \Sexpr[stage=install,strip.white=FALSE,results=rd]{pkg:::decorate_code('
>>     CODE
>>    ')}
>> }
> 
> Thanks for the reply! Unfortunately it seems that \Sexpr is not allowed inside
> \examples, either:
> 
> checkRd: (7) ps_handle.Rd:46-47: Tag \Sexpr is invalid in a \examples block
> 
> G.

I think I found the bug.  The tools::checkRd function only processes 
\Sexpr's with "stage=render".  I think the author (who might have been 
me, I forget) assumed that would imply all the earlier stages as well, 
but apparently it doesn't.

So you could use that as a workaround.

I'll do some more checking, then submit a bug report and patch to Bugzilla.

Duncan Murdoch



[Rd] Top level \Sexpr and R CMD check
Duncan Murdoch