[R-pkg-devel] Macros in Rd files --- supplementary question.
Rolf Turner
r.turner at auckland.ac.nz
Fri Nov 10 21:01:27 CET 2017
On 10/11/17 09:29, Rolf Turner wrote:
> On 09/11/17 23:40, Duncan Murdoch wrote:
>> On 09/11/2017 5:06 AM, Uwe Ligges wrote:
>>> Note the % may be a comment?
>>>
>>
>> Yes, and the body should be written in Rd markup, not R. Working out
>> the appropriate number of escapes is painful; I recommend trial and
>> error.
>>
>> This worked for me:
>>
>> \newcommand{\today}{\Sexpr{format(Sys.Date(),"\\\%d/\\\%m/\\\%Y")}}
>
> Did that, and it worked like a charm. However when I do the "R CMD
> build" thing, when it comes to the "* building the PDF package manual"
> step it says "Hmm ... looks like a package" (no shit, Sherlock!) and
> emits a huge amount of verbose LaTeX diagnostics.
>
> "Normally" one just gets the line "* building the PDF package manual"
> and nothing else, and "R CMD build" just carries on cruising.
>
> Evidently defining a macro in the *.Rd file triggers the extra elaboration.
>
> It's no big deal of course, but I just thought I'd ask:
>
> (a) Is there anything to worry about in this respect?
>
> (b) Is there anything different that I should be doing?
>
> (c) Is there anyway of suppressing the (ever-so-slightly annoying)
> extra screen output?
>
> I guess that's really three supplementary questions ....
Following up a suggestion that I got from Adrian Baddeley I did
R CMD build --help
(I guess this is a case of RTFM) and I got:
> Usage: R CMD build [options] pkgdirs
>
> Build R packages from package sources in the directories specified by
> ‘pkgdirs’
>
> Options:
> -h, --help print short help message and exit
> -v, --version print version info and exit
>
> --force force removal of INDEX file
> --keep-empty-dirs do not remove empty dirs
> --no-build-vignettes do not (re)build package vignettes
> --no-manual do not build the PDF manual even if \Sexprs are present
> ...
> ...
> ...
So: What's triggering the building of the manual is the presence of
\Sexpr in my macro, and I can suppress this and get rid of all the
unwanted LaTeX bumff by using the --no-manual flag.
I must say that I don't see why the presence of a \Sexpr (WTF ever that
is) should trigger the building of the manual.
May I humbly suggest to R Core that this behaviour be modified; perhaps
there could be a --manual flag asking that the manual be built (whether
or not there are \Sexpr expressions in the *.Rd files).
cheers,
Rolf
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
More information about the R-package-devel
mailing list