From f63ec24218edddd749cd43627f3f662f6f3c2dcc Mon Sep 17 00:00:00 2001 From: Yohann Mansiaux Date: Wed, 12 Jun 2024 15:58:32 +0200 Subject: [PATCH] doc: doc for code coverage in inflate and inflate_all #256 --- R/inflate_all.R | 7 ++++++- dev/flat_inflate_all.Rmd | 11 ++++++++++- man/inflate_all.Rd | 6 ++++++ vignettes/inflate-all-your-flat-files.Rmd | 10 ++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/R/inflate_all.R b/R/inflate_all.R index 1eb112c..1d6ee04 100644 --- a/R/inflate_all.R +++ b/R/inflate_all.R @@ -97,6 +97,12 @@ #' inflate_all(check = FALSE, document = TRUE) #' }) #' +#' # If you wish, the code coverage can be computed +#' usethis::with_project(dummypackage, { +#' # now you can run inflate_all() +#' inflate_all(check = FALSE, document = TRUE, codecov = TRUE) +#' }) +#' #' # Clean the temporary directory #' unlink(dummypackage, recursive = TRUE) inflate_all <- function( @@ -200,7 +206,6 @@ inflate_all <- function( ) if (codecov) { - print("entering codecov") cli::cli_alert_info("Computing code coverage - it might take some time") print( covr::package_coverage() diff --git a/dev/flat_inflate_all.Rmd b/dev/flat_inflate_all.Rmd index aefa372..3bd10cd 100644 --- a/dev/flat_inflate_all.Rmd +++ b/dev/flat_inflate_all.Rmd @@ -55,6 +55,10 @@ There is a wrapper named `inflate_all_no_check()` that will prevent running `dev Note also that all files stored in R, tests and vignettes directories are checked to detect those not created from a flat file. They will need to be registered in the config file too, in order to help you keep your package clean of deprecated files. `inflate_all()` thus runs `check_not_registered_files()` behind the scene and informs about the procedure. Read `vignette('register-files-in-config', package = 'fusen')` to get more information. +## Compute the code coverage + +If you want to compute the code coverage of your package, you can run `inflate_all(codecov = TRUE)`. It will run `covr::package_coverage()` at the end of the process. + ## Complete the process with your own code style You can run your preferred styling functions just before the check of the package in `inflate_all()`. For instance, if you want {styler} package to clean your code during the inflate process, you can run `inflate_all(stylers = styler::style_pkg)`. If you also would like to clean the "dev/" directory, you can run `inflate_all(stylers = function() {styler::style_pkg(); styler::style_dir("dev")})`. @@ -204,7 +208,6 @@ inflate_all <- function( ) if (codecov) { - print("entering codecov") cli::cli_alert_info("Computing code coverage - it might take some time") print( covr::package_coverage() @@ -275,6 +278,12 @@ usethis::with_project(dummypackage, { inflate_all(check = FALSE, document = TRUE) }) +# If you wish, the code coverage can be computed +usethis::with_project(dummypackage, { + # now you can run inflate_all() + inflate_all(check = FALSE, document = TRUE, codecov = TRUE) +}) + # Clean the temporary directory unlink(dummypackage, recursive = TRUE) ``` diff --git a/man/inflate_all.Rd b/man/inflate_all.Rd index 10096c6..e1b6a39 100644 --- a/man/inflate_all.Rd +++ b/man/inflate_all.Rd @@ -133,6 +133,12 @@ usethis::with_project(dummypackage, { inflate_all(check = FALSE, document = TRUE) }) +# If you wish, the code coverage can be computed +usethis::with_project(dummypackage, { + # now you can run inflate_all() + inflate_all(check = FALSE, document = TRUE, codecov = TRUE) +}) + # Clean the temporary directory unlink(dummypackage, recursive = TRUE) } diff --git a/vignettes/inflate-all-your-flat-files.Rmd b/vignettes/inflate-all-your-flat-files.Rmd index 7326e38..4aa75a0 100644 --- a/vignettes/inflate-all-your-flat-files.Rmd +++ b/vignettes/inflate-all-your-flat-files.Rmd @@ -62,6 +62,10 @@ There is a wrapper named `inflate_all_no_check()` that will prevent running `dev Note also that all files stored in R, tests and vignettes directories are checked to detect those not created from a flat file. They will need to be registered in the config file too, in order to help you keep your package clean of deprecated files. `inflate_all()` thus runs `check_not_registered_files()` behind the scene and informs about the procedure. Read `vignette('register-files-in-config', package = 'fusen')` to get more information. +## Compute the code coverage + +If you want to compute the code coverage of your package, you can run `inflate_all(codecov = TRUE)`. It will run `covr::package_coverage()` at the end of the process. + ## Complete the process with your own code style You can run your preferred styling functions just before the check of the package in `inflate_all()`. For instance, if you want {styler} package to clean your code during the inflate process, you can run `inflate_all(stylers = styler::style_pkg)`. If you also would like to clean the "dev/" directory, you can run `inflate_all(stylers = function() {styler::style_pkg(); styler::style_dir("dev")})`. @@ -122,6 +126,12 @@ usethis::with_project(dummypackage, { inflate_all(check = FALSE, document = TRUE) }) +# If you wish, the code coverage can be computed +usethis::with_project(dummypackage, { + # now you can run inflate_all() + inflate_all(check = FALSE, document = TRUE, codecov = TRUE) +}) + # Clean the temporary directory unlink(dummypackage, recursive = TRUE) ```