library(fusen)fusen::add_dev_history()development chunk with library(testthat) insidedescription"dev/dev_history.Rmd" template to write your documentation and build your functions and test your examples.
function gets the code of a functionexample gets the code for examples of using the function. This will be used for function @examples and will be kept for the vignettetests gets the code for unit testingdevelopment gets the code for development purposes, usually only used once like {usethis} functionsCreate multiple
"dev_history_xxx.Rmd"files withfusen::add_dev_history()if needed
examples and tests chunks need to be placed after the associated function chunkfunction chunk to store them in the same R file, but they won’t have @examples. Only the first function of the chunk will be able to get examples.examples-1, examples-2, …# Create a new project
tmpdir <- tempdir()
dummypackage <- file.path(tmpdir, "dummypackage")
dir.create(dummypackage)
# Add
add_dev_history(pkg = dummypackage)
#> Created file .here in /tmp/RtmpyjDr1k/dummypackage . Please start a new R session in the new project directory.
#> [1] "/tmp/RtmpyjDr1k/dummypackage/dev/dev_history.Rmd"
# Delete dummy package
unlink(dummypackage, recursive = TRUE)# Create a new project
tmpdir <- tempdir()
dummypackage <- file.path(tmpdir, "dummypackage")
dir.create(dummypackage)
fill_description(
pkg = dummypackage,
fields = list(
Title = "Build A Package From Rmarkdown file",
Description = paste("Use Rmarkdown First method to build your package.",
"Start your package with documentation.",
"Everything can be set from a Rmarkdown file in your project."),
`Authors@R` = c(
person("Sebastien", "Rochette", email = "sebastien@thinkr.fr",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-1565-9313")),
person(given = "ThinkR", role = "cph")
)
)
)
#> [1] "/tmp/RtmpyjDr1k/dummypackage/DESCRIPTION"
# Delete dummy package
unlink(dummypackage, recursive = TRUE)These will be included in the dev/dev_history.R file of your package, but won’t be direct part of it.
Name the following chunk with {r development-1, eval=FALSE}
# Run but keep eval=FALSE to avoid infinite loop
usethis::use_mit_license("Sébastien Rochette")
# Execute in the console directly
fusen::inflate(rmd = "dev/dev_history.Rmd")
You’re one inflate from paper to box. Build your package from this very Rmd using fusen::inflate()
After that, you can:
"DESCRIPTION" file has been updated"R/" directory"tests/testthat/" directory"vignettes/" directorypkgdown::build() for vignette and examples checks# Create a new project
tmpdir <- tempdir()
dummypackage <- file.path(tmpdir, "dummypackage")
dir.create(dummypackage)
# {fusen} steps
fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
dev_file <- add_dev_history(pkg = dummypackage, overwrite = TRUE)
inflate(pkg = dummypackage, rmd = dev_file, name = "Exploration of my Data", check = FALSE)
# Explore directory of the package
# browseURL(dummypackage)
# Try pkgdown build
# pkgdown::build_site(dummypackage)
# usethis::use_build_ignore("docs")
# usethis::use_git_ignore("docs")
# Delete dummy package
unlink(dummypackage, recursive = TRUE)