简体   繁体   English

使用devtools为R包创建主帮助页面(索引)

[英]Create main help page (index) for R package using devtools

I am building a R package using devtools. 我正在使用devtools构建一个R包。 All documentation is built using roxygen2. 所有文档都是使用roxygen2构建的。 For the functions this works all fine, but how can I provide a help page for the whole package, that lists all the available functions. 对于这些功能一切正常,但我如何为整个包提供一个帮助页面,列出所有可用的功能。

In other packages there's always a link in the bottom of each help page which leads to the index page: 在其他包中,每个帮助页面底部始终都有一个链接指向索引页面:

Screenshot from dplyr package (exemplary index link) dplyr包的截图(示例性索引链接)

How can I built/link this index page with devtools? 如何使用devtools构建/链接此索引页?

EDIT: If I access a help page by "?functionName", there will be also the following output printed to the console "Using development documentation for functionName". 编辑:如果我通过“?functionName”访问帮助页面,还会将以下输出打印到控制台“使用functionName的开发文档”。 From the github repository of devtools I find the function dev-help.R that gives this output. 从devtools的github存储库中我找到了提供此输出的函数dev-help.R In its comments it's stated that links won't work with this development help. 在其评论中声明链接不适用于此开发帮助。

Note that this only renders a single documentation file, so that links to other files within the package won't work. 请注意,这只会呈现单个文档文件,因此指向包中其他文件的链接将不起作用。

So how can I use the normal documentation instead of dev-help? 那么我怎样才能使用普通文档而不是dev-help?

Found the solution. 找到了解决方案。 If you have the following workflow: 如果您有以下工作流程:

  1. create()
  2. document()
  3. build()
  4. install.packages()
  5. library(<pkg-name>)

the documentation will be loaded in the namespace of R during document() . 文档将在document()期间加载到R的命名空间中。 Accordingly, a later call of ?functionName will refer to the development stage of the documentation and not the one provided by the compiled package. 因此,稍后调用?functionName将引用文档的开发阶段,而不是编译包提供的开发阶段。

Thus, creating a fresh R session after installation just solves the issue! 因此,安装后创建一个新的R会话就解决了这个问题!

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

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