简体   繁体   English

R包渐晕

[英]R package vignettes

I am a little confused as to why there are multiple possible locations for "vignettes" in an R package. 我对为什么R包中有多个“渐晕”可能的位置感到困惑。 I don't understand which locations are used for what and when. 我不知道哪些位置和时间使用了哪些位置。 For example: 例如:

devtools::use_vignettes()

creates a vignettes folder under the root of the package 在包的根目录下创建一个vignettes文件夹

devtools::build_vignettes() 

creates a inst/doc folder that gets promoted to the root at build 创建一个inst / doc文件夹,该文件夹在构建时被提升到根目录

pkgdown::build_site()

creates a docs folder. 创建一个docs文件夹。

As background:I have read H.Wickhams R packages book and I have created several packages using the first option and all things have behaved well. 作为背景:我已经阅读了H.Wickhams R软件包书,并且使用第一个选项创建了多个软件包,并且一切正常。 I would have users install from github using: 我会让用户使用以下命令从github安装:

devtools::install_github(pkg,build_vignettes=TRUE)

Now, I have just started to contribute in the joint development of a package in which the first and third option have been used. 现在,我刚刚开始为使用第一个和第三个选项的软件包的联合开发做出贡献。 I have noticed that the .rmd file in the vignettes folder is the same as the index.html file in the docs folder. 我注意到vignettes文件夹中的.rmd文件与docs文件夹中的index.html文件相同。 Does pkgdown copy from the vignettes folder? pkgdown是否从vignettes文件夹复制?

Also for this package when i install from github (with build_vignettes=TRUE) i get an error saying installation failed because the doc/index.html path couldn't be found. 当我从github安装时(对于build_vignettes = TRUE),对于此软件包,我也会收到一条错误消息,指出安装失败,因为找不到doc / index.html路径。 Now why would that happen? 现在为什么会这样?

Vignettes development 小插图开发

There is only one place to put raw vignettes, it is in the vignette directory at the root. 只有一个地方可以放置原始小插图,它位于根的小插图目录中。 This is the place where you write your Rmd file with text and code examples, when developing your package. 在开发软件包时,这里是您使用文本和代码示例编写Rmd文件的地方。

Build vignettes for your users 为您的用户建立渐晕

When you build your vignettes, the Rmd file will be knit. 构建小插曲时,将编织Rmd文件。 The resulting html file, the raw Rmd file and the extraction of the R code will be three files saved in the inst/doc directory. 生成的html文件,原始Rmd文件和R代码的提取将是保存在inst / doc目录中的三个文件。 This is what will be kept in the package installation. 这就是软件包安装中将保留的内容。 This is what users will be able to read. 这是用户将能够阅读的内容。

{pkgdown} {} pkgdown

{pkgdown} is using your Rmd files of the vignette directory to knit html files so that it can build a website for your package. {pkgdown}正在使用小插图目录的Rmd文件来编织html文件,以便它可以为您的程序包建立网站。 It also build a page for the list of functions and a index from the Readme file that is also used for your git repository. 它还为功能列表和自述文件中的索引建立了一个页面,该文件也用于您的git存储库。 This is not supposed to stay in the R package, and not accessible to the users. 不应将其保留在R包中,并且用户不可访问。 This is to present your package on the Internet. 这是为了在互联网上展示您的包裹。

Conclusion 结论

Hence, when you develop, you only write your Rmd vignette in the vignette directory. 因此,当您进行开发时,只需将Rmd小插图写入小插图目录中。 The others will automatically keep what they need. 其他人将自动保留他们需要的东西。

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

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