简体   繁体   English

roxygen2 和 RStudio,不为函数创建文档

[英]roxygen2 and RStudio, not creating the documentation for the functions

I am trying to add documentation via roxygen2 in a package.我正在尝试通过 roxygen2 在包中添加文档。 I am able to create the packag successfully and on load able to use the functions too.我能够成功创建包,并且在加载时也可以使用这些功能。 Here is my understanding of how to do it, I create an empty R-Package project on RStudio and then have a source file named "getSomething.R".这是我对如何做的理解,我在 RStudio 上创建了一个空的 R-Package 项目,然后有一个名为“getSomething.R”的源文件。 The contents are the following,内容如下,

#' Test function to ask on stackoverflow
#' 
#' \code{getSomething} Does something to get something.
#' 
#' @param a param 1
#' @param b param 2
#' 
#'

getSomething <- function(a,b){
  return(a*b)
}

Now, I build and load the package which should ideally, create the package with .Rd file in the /man folder and also come up on doing "?getSomething".现在,我构建并加载理想情况下应该使用的包,在 /man 文件夹中创建带有 .Rd 文件的包,并开始执行“?getSomething”。 But nothing comes up on using the command nor are the Rd files created.但是使用该命令没有任何结果,也没有创建 Rd 文件。 Am I missing something here?我在这里错过了什么吗? In my original project, I have some dependent packages which I have added.在我的原始项目中,我添加了一些依赖包。

Following is the decription file,以下是解密文件,

Package: testPackage
Type: Package
Title: Learn how to use roxygen2.
Version: 1.0.1
Date: 2014-11-27
Author: amj2403
Maintainer: amj2403 <emailid>
Description: Write something here
License: NA
Depends:
    R (>= 3.0.0),
    rjson,
    futile.logger,
    RCurl

Also the NAMESPACE file,还有 NAMESPACE 文件,

exportPattern("^[[:alpha:]]+" exportPattern("^[[:alpha:]]+"

I think I am missing some vital step.我想我错过了一些重要的步骤。

The default in RStudio, when you enable roxygen2, is to roxygenise everything on package builds and R CMD CHECK but not on "build and reload".当您启用 roxygen2 时,RStudio 中的默认设置是对包构建和 R CMD CHECK 上的所有内容进行 roxygenise,但不在“构建和重新加载”上。 To enable that, go to Project Options -> Build Tools.要启用它,请转到项目选项 -> 构建工具。 Then click the "Configure" button next to "Generate documentation with Roxygen" and tick the "Build & Reload" box.然后单击“使用 Roxygen 生成文档”旁边的“配置”按钮并勾选“构建和重新加载”框。

Sometimes RStudio would not display the checkbox "Generate documentation with Roxygen" at all.有时 RStudio 根本不会显示“使用 Roxygen 生成文档”复选框。 If this is the case, in R Console type library(roxygen2) and it will suddenly appear.如果是这种情况,在 R Console 类型库(roxygen2)中,它会突然出现。

I wish default would be to mandate loading of it and enabling it.我希望默认是强制加载并启用它。

I had the same problem while making a package with devtools .我在使用devtools制作软件包时遇到了同样的问题。 I just needed to run devtools::document() to create the help files.我只需要运行devtools::document()来创建帮助文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM