On 22/04/2019 2:40 a.m., Boris Steipe wrote:
I see .. you mean code that extends Roxygen. I was thinking something simple 
like an .Rmd chunk. But just creating an existing tag doesn't do much either:

   #' @eval sprintf("@section Time: %s", Sys.time() )

Renders as...

   @eval sprintf("@section Time:

  ... in the .Rd - more than before, but not what I though

An actual example would be most enlightening.

If you look in the Roxygen2 code you'll find some, e.g. in R/rd.R, which displays in ?rd_roclet.

I'd guess the percent sign is messing things up. It's a comment in Rd files, and perhaps also in roxygen.

Doing the search through the source code also turned up @evalRd and @evalNamespace, which might be worth exploring.

Duncan Murdoch


Thanks Jeff,
Boris



On 2019-04-22, at 02:25, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote:

What tag are you creating with the eval? Your example wouldn't create valid 
roxygen code... as I said, it looks rather meta....

On April 21, 2019 10:40:27 PM PDT, Boris Steipe <boris.ste...@utoronto.ca> 
wrote:
Yes, that's where I started -  the vignette says:

   ... Run arbtirary R code with @eval.

   ... the @eval tag. It evaluates code and treats the result as if it
   was a literal roxygen tags. This makes it possible to eliminate
   duplication by writing functions.

The first thing I noticed was that it does not say anything about
delimiters. By trial and error it seems to consider everything up to
the next @... tag in the header. Things that are not R code create an
error during devtools::document() processing. It seems the output is
captured and processed, i.e. System.time() creates a not-a-string
error, but as.character(System.time()) passes ... but then nothing
appears in the .Rd - and I haven't been able to find a single example
of @eval in use in the wild.

No joy.




On 2019-04-22, at 01:29, Jeff Newmiller <jdnew...@dcn.davis.ca.us>
wrote:

I have not used it... but did you read the vignette [1]? It sounds
like it is a bit more meta than you think it is...

[1]
https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html

On April 21, 2019 7:44:17 PM PDT, Boris Steipe
<boris.ste...@utoronto.ca> wrote:
Playing with Roxygen features, but can't get @eval to work. E.g. ...

#' @eval sprintf("%s", Sys.time())

... does not do what I thought it would (i.e. substitute the tag and
the expression with the string). Instead I see nothing in the .RD
file.

Any working examples out there?
Thanks!
Boris

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to