moodymudskipper / inops

Infix Operators for Detection, Subsetting and Replacement
GNU General Public License v3.0
40 stars 0 forks source link

command check doesn't like exotic assignment ops #1

Closed moodymudskipper closed 4 years ago

moodymudskipper commented 4 years ago

It detects invalid syntax such as >=(e1, e2) <- value.

checking Rd \usage sections ... WARNING
  Bad \usage lines found in documentation object 'comparison_ops':
    >=(e1, e2) <- value
    >(e1, e2) <- value
    <=(e1, e2) <- value
    <(e1, e2) <- value
    ==(e1, e2) <- value
    !=(e1, e2) <- value
  Bad \usage lines found in documentation object 'element_wise_in':
    %in{}%(x, table) <- value
    %!in{}%(x, table) <- value
  Bad \usage lines found in documentation object 'in_variants':
    %in%(x, table) <- value
    %!in%(x, table) <- value
  Bad \usage lines found in documentation object 'like_variants':
    %like%(x, pattern) <- value
    %!like%(x, pattern) <- value
  Bad \usage lines found in documentation object 'range_ops':
    %in()%(x, range) <- value
    %!in()%(x, range) <- value
    %in(]%(x, range) <- value
    %!in(]%(x, range) <- value
    %in[)%(x, range) <- value
    %!in[)%(x, range) <- value
    %in[]%(x, range) <- value
    %!in[]%(x, range) <- value

  Functions with \usage entries need to have the appropriate \alias
  entries, and all their arguments documented.
  The \usage entries must correspond to syntactically valid R code.
  See chapter 'Writing R documentation files' in the 'Writing R
  Extensions' manual.
karoliskoncevicius commented 4 years ago

This might be bug in Roxygen actually, but not sure. I remember that for infixer I had to adjust the usage in the docs manually for them to pass CMD check.

moodymudskipper commented 4 years ago

It seems like we can define the usage manually as described in this answer : https://stackoverflow.com/questions/13322021/assignment-function-documentation-fails-r-cmd-check

Examples given :

 #' Assign sp feature IDs
#' @rdname IDs
#' @usage IDs(x) <- value
"IDs<-" <- function( x, value ) {
    UseMethod("IDs<-",x)
}

#' @method IDs<- SpatialPolygonsDataFrame
#' @S3method IDs<- SpatialPolygonsDataFrame
#' @rdname IDs
#' @usage IDs(x) <- value
"IDs<-.SpatialPolygonsDataFrame" <- function( x, value) {
    spChFIDs(x,value)
}

Untested yet

Maybe that's what you meant, but I didn't know @usage and thought first you had edited the doc files manually.

moodymudskipper commented 4 years ago

solved by explicit @usage definitions, escaping the \%.

https://github.com/moodymudskipper/rangeops/commit/f4940844eba811aa8b008c7633af6e2896b71ac3

https://github.com/moodymudskipper/rangeops/commit/50502be958b6ec9f7f2f7ee08ad78c093de413b1

CMD check now succeeds

karoliskoncevicius commented 4 years ago

Nice!