使用devtools构建.md小插图 [英] Build .md vignette using devtools

查看:92
本文介绍了使用devtools构建.md小插图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用knitr::rmarkdown(但knitr::knitr的用法与我的VignetteEngine相同).然后,我使用devtools::build_vignettes()构建我的包装插图.

I’m using knitr::rmarkdown (but knitr::knitr does the same) as my VignetteEngine. I then build my package vignette using devtools::build_vignettes().

这有效,但仅在inst/doc中创建HTML和R输出文件.我想要的是Markdown输出文件,因为只有该文件可以直接在Github项目页面中显示(对于HTML文件,Github显示源,对于Rmd文件,它显示渲染的输出,但是-显然-而不执行R块).

This works, but only creates HTML and R output files in inst/doc. What I want is a Markdown output file, since only that can be displayed directly within the Github project pages (for HTML files, Github shows the source and for Rmd files it shows a rendered output but — obviously — without executing the R blocks).

我尝试找出如何为自定义VignetteEngine指定输出,我认为应该有可能(毕竟,其他软件包至少使用它来构建PDF小插图),但是我找不到通过devtools::build_vignettes执行此操作的方式.

I’ve tried finding out how to specify the output for custom VignetteEngines and I think that it should be possible (after all, other packages use this to build PDF vignettes, at a minimum) but I cannot find a way of doing this via devtools::build_vignettes. Is there no way around building the vignette manually (i.e. via knitr::knit or similar mechanisms that ignore the VignetteBuilder directives)?

我也无法在文档/源中找到相关信息.

I can’t find relevant information in the documentation/source either.

推荐答案

vignettes的唯一输出格式是HTML和PDF(和LaTeX,但会转换为PDF,但不显示).不支持Markdown.

The only output formats for vignettes are HTML and PDF (and LaTeX, but it is converted to PDF, not displayed). Markdown isn't supported.

您可以在软件包中包含任意文档文件(按照惯例,您可以将它们放在inst/doc中),但是它们不被视为渐晕,因此不会自动生成,例如browseVignettes()之类的功能将被忽略他们,等等.

You can have arbitrary documentation files in your package (by convention you put them in inst/doc), but they aren't considered to be vignettes, so they won't be automatically built, functions like browseVignettes() will ignore them, etc.

要将Rmd文件转换为md,只需在其上运行knitr::knit.

To convert an Rmd file to md, just run knitr::knit on it.

这篇关于使用devtools构建.md小插图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆