[Rd] stage=install in \doi definition could lead to problems

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Mar 15 21:38:28 CET 2022


Good Sys.time() everyone,

If this is not the right place for such questions, please let me know.

I was wondering why \doi has been changed to stage=install instead of
stage=build in r81891 [1]. I think it might lead to problems, but in
the spirit of Chesterton's fence, I'd like to learn the reasons. Is it
to make R CMD build more performant, avoiding the need for the
"installing the package to process man pages" step for the common case
of the \doi macro?

Some DOIs look a bit scary. One example that comes to mind is as
follows:

10.1002/(SICI)1099-128X(199801/02)12:1<55::AID-CEM501>3.0.CO;2-#

Until the recent fix in r81817 [2], it used to require special
treatment in order to display correctly in a man page, but now it just
works if I copy and paste it into \doi{}. With the macro definition
using [stage=build], I could build a package with a recent build of
R-devel, get the correct \doi expansion inlined, install the package on
an older version of R, and it would still work, thanks to R keeping the
parse tree in build/partial.rdb.

With the macro defined using [stage=install], any version of R older
than 2022-02-25 (r81817), which doesn't have this fix, would fail to
link to the DOI correctly, not having the correct expansion of \doi
to rely upon any more:

Rd2HTML(parse_Rd(textConnection('\\name{foo}\n\\title{bar}\\description{\\doi{10.1002/(SICI)1099-128X(199801/02)12:1<55::AID-CEM501>3.0.CO;2-#}}'),
fragment = FALSE), stages = c('build'))

<a
href="http://doi.org/10.1002/(SICI)1099-128X(199801/02)12:1%3C55::AID-CEM501%3E3.0.CO;2-#">doi:
10.1002/(SICI)1099-128X(199801/02)12:1<55::AID-CEM501>3.0.CO;2-#</a>

(The hash sign doesn't get URL-encoded, and the link gets broken.)

Sorry for giving you yet another case of <https://xkcd.com/1172/>. If I
have to, I might be able to "unroll" the macro myself for the few cases
where it matters.

-- 
Best regards,
Ivan

[1]
https://github.com/r-devel/r-svn/commit/2de6a23b3ee31dadb77aabc598dbc3420cd419c0

[2]
https://github.com/r-devel/r-svn/commit/628bb4c3479d6c28694c2fa0e7f3440840eef59e



More information about the R-devel mailing list