2012-11-10 3 views
6

Ho problemi con le funzioni di assegnazione check con Roxygen.La documentazione della funzione di assegnazione non funziona R CMD CHECK

Ecco un esempio abbastanza minimal:

#' Get sp feature IDs 
#' @aliases IDs IDs.default IDs.SpatialPolygonsDataFrame IDs<- IDs<-.SpatialPolygonsDataFrame 
#' @param x The object to get the IDs from or assign to 
#' @param value The character vector to assign to the IDs 
#' @param \dots Pass-alongs 
#' @author Ari B. Friedman 
#' @rdname IDs 
IDs <- function(x,...) { 
    UseMethod("IDs",x) 
} 
#' @method IDs default 
#' @S3method IDs default 
#' @rdname IDs 
IDs.default <- function(x,...) { 
    stop("Currently only SpatialPolygonsDataFrames are supported.") 
} 
#' @method IDs SpatialPolygonsDataFrame 
#' @S3method IDs SpatialPolygonsDataFrame 
#' @rdname IDs 
IDs.SpatialPolygonsDataFrame <- function(x,...) { 
    vapply(slot(x, "polygons"), function(x) slot(x, "ID"), "") 
} 

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

E quando corro check:

* checking for code/documentation mismatches ... WARNING 
Codoc mismatches from documentation object 'IDs': 
IDs<- 
    Code: function(x, value) 
    Docs: function(x, value, value) 
IDs<-.SpatialPolygonsDataFrame 
    Code: function(x, value) 
    Docs: function(x, value, value) 

Non capisco dove il secondo value proviene. Ho provato a eliminare lo @param value sulla teoria che forse Roxygen crea automaticamente una voce per le funzioni di assegnazione, ma ciò non elimina la definizione (x,value,value) e genera un nuovo avviso che lamenta che non ho definito value.

Ecco la quota di competenza del .Rd generato:

\usage{ 
    IDs(x, ...) 

    \method{IDs}{default} (x, ...) 

    \method{IDs}{SpatialPolygonsDataFrame} (x, ...) 

    IDs(x, value) <- value 

    \method{IDs}{SpatialPolygonsDataFrame} (x, value) <- 
    value 
} 

non vedo la firma (x, value, value) che check affermazioni c'è.

Questa è una funzione S3 ma funziona su un oggetto S4. Questo dovrebbe comunque renderlo S3, penso. Ma se così non fosse potrebbe essere che il mio uso di @S3method è il problema.

Aiuto?

+5

E 'probabilmente perché il supporto S4 in roxygen2 succhia :(È possibile provare la sperimentale [roxygen3] (http://github.com/hadley/roxygen3/) che sarà fusa nuovamente dentro roxygen2 ad un certo punto della futuro – hadley

+0

Questo sembra essere correlato: http://stackoverflow.com/questions/8873514/documenting-setter-functions-with-roxygen – Dason

risposta

4

Questo è un modo abbastanza approssimativo di procedere, ma sembra che il modo in cui il sistema gestisce questo sia ancora interrotto per il momento (LINK). Ma puoi aggiungere manualmente la sezione di utilizzo direttamente ai tuoi commenti di roxygen.

#' 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) 
}