You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在devtools::check()与devtools::build_vignettes()时排除耗时vignette?

Absolutely! There are straightforward ways to exclude time-consuming vignettes when running devtools::check() and devtools::build_vignettes()—here's how you can set this up:

Excluding Vignettes from devtools::check()

You’ve got two reliable options here, depending on whether you want to skip specific vignettes or all of them temporarily:

  • Mark individual vignettes as skip-worthy in their YAML frontmatter
    Open the slow vignette’s .Rmd file, and add build: false to the top YAML block. This tells devtools::check() to skip building and checking that particular vignette entirely:

    ---
    title: "My Super Slow Vignette"
    output: rmarkdown::html_vignette
    build: false
    ---
    

    This is the most maintainable approach because it’s tied directly to the vignette itself—anyone working on your package will see which ones are excluded by default.

  • Temporarily skip specific vignettes via environment variables
    If you don’t want to modify the vignette files, you can set an environment variable to exclude specific paths before running check():

    # Exclude one or more vignettes (separate with commas if multiple)
    Sys.setenv("_R_CHECK_BUILD_VIGNETTES_EXCLUDE_" = "vignettes/my-slow-vignette.Rmd")
    devtools::check()
    

    To skip all vignettes temporarily, you can pass a build argument instead:

    devtools::check(build_args = "--no-build-vignettes")
    
Excluding Vignettes from devtools::build_vignettes()

By default, this function builds all vignettes in your vignettes/ folder. To exclude slow ones, you have two simple strategies:

  • Explicitly list only the vignettes you want to build
    Use the vignettes parameter to specify the paths of the fast vignettes you want to process:

    devtools::build_vignettes(vignettes = c("vignettes/fast-vignette-1.Rmd", "vignettes/fast-vignette-2.Rmd"))
    
  • Dynamically exclude slow vignettes from the full list
    If you have many vignettes, you can programmatically filter out the slow ones instead of listing every fast one:

    # Get all vignette paths
    all_vignettes <- list.files("vignettes", pattern = "\\.Rmd$", full.names = TRUE)
    # Define the slow ones to exclude
    slow_vignettes <- c("vignettes/my-slow-vignette.Rmd", "vignettes/another-slow-one.Rmd")
    # Build only the fast ones
    devtools::build_vignettes(vignettes = setdiff(all_vignettes, slow_vignettes))
    

For most workflows, marking vignettes with build: false in their YAML is the cleanest long-term solution for check(), while explicitly targeting fast vignettes works best for build_vignettes() when you still want to generate some documentation quickly.

内容的提问来源于stack exchange,提问作者user2978524

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:51:36