library(fusen)
teaching
to startcreate_fusen("path/to/new/project", template = "teaching")
development
chunk with library(testthat)
insidedescription
asking to describe your package and license it
"dev/flat_teaching.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} functionsdev-inflate
chunk to inflate the flat template and transform it as an inflated package with functions, unit tests and the current Rmd template transformed as a vignette. And check.Create multiple
"flat_xxx.Rmd"
files withfusen::add_flat_template(template = "add")
if needed
Fonction fill_description()
requires the description of your package: What does it do? Who are the developers?
This will fill the DESCRIPTION file in the proper way.
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")
)
) )
You’re one inflate from flat paper to box. Build your package from the flat Rmd template using the inflate()
command below.
After that, you can:
"DESCRIPTION"
file has been updated"R/"
directory"tests/testthat/"
directory"vignettes/"
directoryusethis::use_pkgdown()
then pkgdown::build()
for vignette and examples checks::inflate(
fusenflat_file = "dev/flat_teaching.Rmd",
vignette_name = "Exploration of my Data",
open_vignette = TRUE,
document = TRUE,
check = TRUE
)
# Create a new project
<- tempfile(pattern = "dummy")
dummypackage
# {fusen} steps
<- create_fusen(dummypackage, template = "teaching", open = FALSE)
dev_file # Description
::fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
fusen
# From inside the package
::with_project(dummypackage, {
usethis# Define License with use_*_license()
::use_mit_license("Sébastien Rochette")
usethis
# You may need to execute inflate() in the console directly
::inflate(pkg = dummypackage,
fusenflat_file = dev_file,
vignette_name = "Get started")
})
# Explore directory of the package
browseURL(dummypackage)
# Delete dummy package
unlink(dummypackage, recursive = TRUE)
# Add an additional dev template
add_flat_template(template = "add", pkg = dummypackage)
These are only included in the flat template file, their content will not be part of the package anywhere else.
Name the following chunk with {r development-something, eval=FALSE}
```{r development-inflate, 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(flat_file = "dev/dev_history.Rmd")
```
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-myfunction
, examples-myotherfunction
, …