From murdoch@dunc@n @ending from gm@il@com  Thu Jul 12 13:23:34 2018
From: murdoch@dunc@n @ending from gm@il@com (Duncan Murdoch)
Date: Thu, 12 Jul 2018 07:23:34 -0400
Subject: [Rd] Top level \Sexpr and R CMD check
In-Reply-To: <CABtg=KkE7gNvho-PLvsS-48yOR5nVTTSsekf35uLS4JJiZmjjg@mail.gmail.com>
References: <CABtg=KkE7gNvho-PLvsS-48yOR5nVTTSsekf35uLS4JJiZmjjg@mail.gmail.com>
Message-ID: <eaf1c672-fb4c-5327-9b5a-4349ef75eec7@gmail.com>

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
  ')}
}

Duncan Murdoch

> 
> Thanks, Gabor
> 
> In the Rd  file:
> 
> \Sexpr[stage=install,strip.white=FALSE,results=rd]{pkg:::decorate_examples('
> CODE
> ')}
> 
> and pkg::decorate_examples outputs
> 
> \examples{
> MODIFIED CODE
> }
> 
> But then:
> 
> * checking Rd files ... WARNING
> prepare_Rd: ps_cmdline.Rd:36-42: Section \Sexpr is unrecognized and
> will be dropped
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



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