首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用`devtools::build_vignette`编译一个小片段,以便将.md保存在vignettes目录中

使用`devtools::build_vignette`编译一个小片段,以便将.md保存在vignettes目录中
EN

Stack Overflow用户
提问于 2017-08-08 18:51:40
回答 1查看 682关注 0票数 7

我正在试图编译一个软件包,使.md文件仍然保存在github上的vignette文件夹中。所有这些我都使用devtools。我已经看过这个方法,并将在下面概述它:

我已经自动生成了一个使用devtools::use_vignette()的微缩模板。然后,我将.Rmd文件修改为如下所示(截断模板版本):

代码语言:javascript
运行
复制
---
  title: "package"
author: "author"
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette:
  toc: true
  keep_md: true
vignette: >
  %\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

  Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format:

  - Never uses retina figures
- Has a smaller default figure size
- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style

## Vignette Info

Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette.

因此,.yaml被修改了,但是当我使用devtools::build_vignettes()编译时,它似乎没有将一个.md文件留在vignettes目录中。没有错误信息,而vignette构建得很好,所以这有点让人困惑。

因此,为了总结这个问题,有没有人知道如何使用devtools::build_vignette编译一个vignette,以便将基本的标记文件保存在vignettes目录中?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-10 19:26:32

如果您对build_vignette()以外的函数开放,那么这很容易,因为归根结底,所有东西都只是外部pandoc二进制文件的包装器。

代码语言:javascript
运行
复制
/tmp/vig> ls -l     ## start with nothing but Rmd
total 4
-rw-r--r-- 1 user grp 1015 Aug 10 14:21 soVig.Rmd
/tmp/vig> 
/tmp/vig> Rscript -e 'rmarkdown::render("soVig.Rmd", clean=FALSE)'


processing file: soVig.Rmd
  |.................................................................| 100%
   inline R code fragments


output file: soVig.knit.md

/usr/bin/pandoc +RTS -K512m -RTS soVig.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output soVig.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html --highlight-style pygments --css /usr/local/lib/R/site-library/rmarkdown/rmarkdown/templates/html_vignette/resources/vignette.css --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' 

Output created: soVig.html
/tmp/vig> ls -l soVig.*
-rw-r--r-- 1 user grp 7066 Aug 10 14:24 soVig.html
-rw-r--r-- 1 user grp 1011 Aug 10 14:24 soVig.knit.md
-rw-r--r-- 1 user grp 1015 Aug 10 14:21 soVig.Rmd
-rw-r--r-- 1 user grp 1011 Aug 10 14:24 soVig.utf8.md
/tmp/vig> 

因此,通过简单地告诉render()不要干净,我们就可以保留标记源。

票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45575971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档