Skip to contents

Inflate all the flat files stored in "dev/" and starting with "flat_"

Usage

inflate_all(
  pkg = ".",
  document = TRUE,
  check = TRUE,
  open_vignette = FALSE,
  overwrite = TRUE,
  clean = TRUE,
  stylers,
  ...
)

inflate_all_no_check(
  pkg = ".",
  document = TRUE,
  open_vignette = FALSE,
  overwrite = TRUE,
  clean = TRUE,
  stylers,
  ...
)

Arguments

pkg

Path to package

document

Logical. Whether to document your package using att_amend_desc

check

Logical. Whether to check package after Rmd inflating

open_vignette

Logical. Whether to open vignette file at the end of the process

overwrite

Logical (TRUE, FALSE) or character ("ask", "yes", "no). Whether to overwrite vignette and functions if already exists.

clean

Logical. Whether to help detect unregistered files.

stylers

Function to be run at the end of the process, like styler::style_pkg or lintr::lint_package or a lambda function combining functions like: function() {styler::style_pkg(); lintr::lint_package()}. For a unique function, use the format without parenthesis () at the end of the command.

...

Arguments passed to devtools::check(). For example, you can do inflate(check = TRUE, quiet = TRUE), where quiet is passed to devtools::check().

Value

side effect. Inflates all your flat files that can be inflated.

Details

This requires to inflate() all flat files individually at least once, so that their specific inflate configurations are stored.

This also requires to register all R, tests and vignettes files of your package, even if not created with an inflate. Run inflate_all() once and read the messages. The first time, you will probably need to run register_all_to_config() if your package is not new.

For more information, read the vignette("inflate-all-your-flat-files", package = "fusen")

See also

inflate() for the options of a single file inflate, check_not_registered_files() for the list of files not already associated with a flat file in the config file, register_all_to_config() for automatically registering all files already present in the project before the first inflate_all()

Examples

if (FALSE) {
# Usually, in the current package run inflate_all() directly
# These functions change the current user workspace
inflate_all()
# Or inflate_all_no_check() to prevent checks to run
inflate_all_no_check()
# Or inflate with the styler you want
inflate_all(stylers = styler::style_pkg)
}

# You can also inflate_all flats of another package as follows
# Example with a dummy package with a flat file
dummypackage <- tempfile("inflateall.otherpkg")
dir.create(dummypackage)
fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
#> [1] "/tmp/RtmplI2md2/inflateall.otherpkg18bd23c2178e/DESCRIPTION"
flat_files <- add_minimal_package(
  pkg = dummypackage,
  overwrite = TRUE,
  open = FALSE
)
#> Created file .here in /tmp/RtmplI2md2/inflateall.otherpkg18bd23c2178e . Please start a new R session in the new project directory.
flat_file <- flat_files[grep("flat", basename(flat_files))]
# Inflate the flat file once
usethis::with_project(dummypackage, {
  # if you are starting from a brand new package, inflate_all() will crash
  # it's because of the absence of a fusen config file
  #
  # inflate_all() # will crash

  # Add licence
  usethis::use_mit_license("John Doe")

  # you need to inflate manually your flat file first
  inflate(
    pkg = dummypackage,
    flat_file = flat_file,
    vignette_name = "Get started",
    check = FALSE,
    open_vignette = FALSE,
    document = TRUE,
    overwrite = "yes"
  )

  # your config file has been created
  config_yml_ref <-
    yaml::read_yaml(getOption("fusen.config_file", default = "dev/config_fusen.yaml"))
})
#>  Setting active project to '/tmp/RtmplI2md2/inflateall.otherpkg18bd23c2178e'
#>  Adding 'MIT + file LICENSE' to License
#>  Writing 'LICENSE'
#>  Writing 'LICENSE.md'
#>  Adding '^LICENSE\\.md$' to '.Rbuildignore'
#>  Loading inflateall.otherpkg18bd23c2178e
#> Writing NAMESPACE
#>  Adding 'knitr' to Suggests field in DESCRIPTION
#>  Use `requireNamespace("knitr", quietly = TRUE)` to test if package is installed
#>  Then directly refer to functions with `knitr::fun()`
#>  Adding 'inst/doc' to '.gitignore'
#> ── config file for dev/flat_minimal.Rmd ────────────────────────────────────────
#>  path: dev/flat_minimal.Rmd was added to the config file
#>  state: active was added to the config file
#>  R: R/my_fun.R was added to the config file
#>  tests: tests/testthat/test-my_fun.R was added to the config file
#>  vignettes: vignettes/get-started.Rmd was added to the config file
#>  inflate: each parameter was added to the config file
#> Saving attachment parameters to yaml config file
#> Updating inflateall.otherpkg18bd23c2178e documentation
#>  Loading inflateall.otherpkg18bd23c2178e
#> Writing NAMESPACE
#> Writing my_fun.Rd
#>  Loading inflateall.otherpkg18bd23c2178e
#> [+] 2 package(s) added: rmarkdown, testthat.
#>  Setting active project to '/tmp/RtmplI2md2/dummy.package18bd7482b961'

# Next time, you can run inflate_all() directly
usethis::with_project(dummypackage, {
  # now you can run inflate_all()
  inflate_all(check = FALSE, document = TRUE)
})
#>  Setting active project to '/tmp/RtmplI2md2/inflateall.otherpkg18bd23c2178e'
#>  The flat file flat_minimal.Rmd is going to be inflated
#> ── config file for dev/flat_minimal.Rmd ────────────────────────────────────────
#> ── check not registered files ──────────────────────────────────────────────────
#>  There are no unregistered files.
#> Documentation parameters were restored from attachment config file.
#> Updating inflateall.otherpkg18bd23c2178e documentation
#>  Loading inflateall.otherpkg18bd23c2178e
#> Writing NAMESPACE
#>  Loading inflateall.otherpkg18bd23c2178e
#>  Setting active project to '/tmp/RtmplI2md2/dummy.package18bd7482b961'

# Clean the temporary directory
unlink(dummypackage, recursive = TRUE)