Roxygen2 + cygwin + default parameter = truncated `\ usage` section

I have a package for R that I developed under Linux, and an awful time has come when I am testing it under Windows.

The documentation is done using roxygen, and I use cygwin to build the package.

The thing is, when I roxygenise('test-package') , roxygen truncates the \usage section of the documentation for a single character. This is done for some, but not all of my functions, and I cannot understand the pattern.

This does not happen when executing the same command (i.e. roxygenise('test-package') from the R prompt) on Linux or Windows - just Cygwin on Windows (using the R devtools + command prompt from windows this is not an option for me - this is part of a large project with Makefile, etc.).

In all cases, I use roxygen v2.2.2.


Update:

This is similar to any function with a default parameter.


I pushed it back to one reproducible example, reducing it as much as possible in order to isolate the problem:

  • From R:

     # this function used to trim strings, but I've stripped it right down # to eliminate it as a cause of the problem trim <- function(x='asdf') { return( x ) } package.skeleton('test') 
  • change trim.R (in test / R) and add the following roxygen to the beginning, so that the file looks like this:

     #' trim white spaces from a string #' #' @param x string or vector of strings to trim #' @return x trimmed. #' @export trim <- function(x='asdf') { return( x ) } 
  • Run R and create the documentation:

     library(roxygen2) roxygenise('test') 
  • Look at the resulting trim.Rd file (in test / man):

     \name{trim} \alias{trim} \title{trim white spaces from a string} \usage{ t } \arguments{ ... # rest of .Rd file - nothing wrong here. 

See how simple \usage{t} ??

Of course, when you run the R CMD check , an error appears about document arguments that are not displayed in \usage , but this is because \usage got truncated.

Does anyone know why this is happening and how I can get around this? Perhaps something in roxygen2 that relies on something that works on Mac, Windows, and Linux, but not Cygwin?

cheers (I took my hair off of this).

Update # 2:

I used R installed from Cygwin's package manager, unlike my Windows R (i.e. the one that was in C:/Program Files/R/R-2.14.2/bin ). I did not understand that Windows R would run under Cygwin.

If I use Windows R in Cygwin, the error will disappear. If I use Cygwin R in Cygwin, an error is present.

I can only assume that this is some bug related to Cygwin R, unlike roxygen2.

Currently, I will use a workaround for using Windows R in cygwin (in fact, now that I know that I can do this, in any case there is no need for Cygwin R!).

+6
source share
1 answer

This is not a fix, but a workaround.

I used R installed from the Cygwin package manager, unlike my Windows R (i.e. the one that was in C: / Program Files / R / R-2.14.2 / bin) - I did not understand that Windows R will work under cygwin.

If I use Windows R in Cygwin, the error will disappear. If I use Cygwin R in Cygwin, an error is present.

I can only assume that this is some bug related to Cygwin R, unlike roxygen2.

Currently, I will use a workaround for using Windows R in cygwin (in fact, now that I know that I can do this, there is no need for Cygwin R anyway). This still gives me access to linux commands like make , sed and grep , but allows me to work with the documentation.

The problem still is that Cygwin-R in Cygwin (and not Windows-R in Cygwin) is causing this error, but it may no longer be related to roxygen2.

0
source

Source: https://habr.com/ru/post/910135/


All Articles