【问题标题】:Document S4 class and "undocumented code object" during R CMD check在 R CMD 检查期间记录 S4 类和“未记录的代码对象”
【发布时间】:2018-03-22 17:23:45
【问题描述】:

在努力用 roxygen2 记录 S4 类之后,我决定退后一步,使用 package.skeleton、promptClass 和 promptMethod 创建一个最小示例。

我的问题是R CMD check 仍然给出关于“未记录的代码对象”的警告,尽管我认为我已经正确记录了它们。

我现在拥有的文件是:

testClass.R:

setClass("testClass",
        slots = c(a = "numeric"),
        prototype = prototype( a = 0 ),         
        validity = function(object) return(TRUE))

setGeneric(name = "testMethod",
            def = function(object, ...) standardGeneric("testMethod") )

setMethod(f = "testMethod", signature = "testClass",
        definition=function(object, x) 
        {
            cat("testMethod:",x,"\n")
            invisible(object)
        }
)

testClass-class.Rd

\name{testClass-class}
\Rdversion{1.1}
\docType{class}
\alias{testClass-class}
%%\alias{testMethod,testClass-method}
\title{Class \code{"testClass"}}
\description{bla bla}
\section{Objects from the Class}{bla bla}
\section{Slots}{\describe{\item{\code{a}:}{Object of class \code{"numeric"} ~~ }}}
\section{Methods}{\describe{\item{testMethod}{\code{signature(object = "testClass")}: ... }}}
\keyword{classes}

和 testMethod.Rd

\name{testMethod-methods}
\docType{methods}
\alias{testMethod-methods}
\alias{testMethod,testClass-method}
\title{ ~~ Methods for Function \code{testMethod}  ~~}
\description{blabla}
\section{Methods}{
\describe{\item{\code{signature(object = "testClass")}}{blabla}}}
\keyword{methods}

还有一个包文档文件,不过我觉得这里不相关。

R CMD check 给出:

* checking for missing documentation entries ... WARNING
Undocumented code objects:
‘testMethod’
All user-level objects in a package should have documentation entries.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.

我已经查阅了这些部分,从中得出的结论是,我至少需要一个 generic,signature-list-method 的别名,在这种情况下是 alias{testMethod,testClass-method},它通过我调用 promtMethod 自动放置在文档文件中(我已从类 .Rd 文件中将其注释掉,因为它在那里被复制了)。

我需要在 .Rd 文件中进行哪些更改才能消除此警告?

【问题讨论】:

    标签: r documentation-generation rd


    【解决方案1】:

    与此同时,我发现了问题所在。看来我还需要将 \alias{testMethod} 分配给 .Rd 文件。然而,我觉得奇怪的是,promptMethod 生成的文件没有包含这个别名。

    【讨论】:

      猜你喜欢
      • 2020-01-07
      • 2015-01-09
      • 2014-08-17
      • 1970-01-01
      • 2017-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      相关资源
      最近更新 更多