From 0000e8cb86c83f400f59622d1681cd572372e675 Mon Sep 17 00:00:00 2001 From: StatnMap Date: Mon, 13 May 2024 14:32:30 +0200 Subject: [PATCH] refactor: rename draw_package_structure --- NAMESPACE | 2 +- NEWS.md | 2 +- R/get_package_structure.R | 8 ++++---- README.Rmd | 2 +- README.md | 5 +++-- dev/README.Rmd | 2 +- dev/README.md | 4 ++-- dev/dev_history_cran.R | 6 +++++- dev/flat_get_package_structure.Rmd | 12 ++++++------ inst/the-dev-history.Rmd | 2 +- man/get_package_structure.Rd | 10 +++++----- tests/testthat/_snaps/get_package_structure.md | 4 ++-- tests/testthat/test-get_package_structure.R | 4 ++-- vignettes/Maintain-packages-with-fusen.Rmd | 2 +- ...aw-a-tree-of-your-package-files-and-functions.Rmd | 6 +++--- vignettes/tips-and-tricks.Rmd | 2 +- 16 files changed, 39 insertions(+), 34 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 0447619..7f8af91 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,7 +11,7 @@ export(add_minimal_package) export(check_not_registered_files) export(create_fusen) export(deprecate_flat_file) -export(draw_the_tree) +export(draw_package_structure) export(fill_description) export(get_all_created_funs) export(get_package_structure) diff --git a/NEWS.md b/NEWS.md index a5e0058..58cf0a0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,7 +7,7 @@ ## New features -- `draw_the_tree()` along with `get_package_structure()` allows to draw the package structure with +- `draw_package_structure()` along with `get_package_structure()` allows to draw the package structure with all functions created in each R file, and whether they are exported (#189) - `rename_flat_file()` allows to rename a flat file, and deals with config and inflated files - `deprecate_flat_file()` helps properly deprecate a flat file, modifies the config file diff --git a/R/get_package_structure.R b/R/get_package_structure.R index d79efec..3a8eee0 100644 --- a/R/get_package_structure.R +++ b/R/get_package_structure.R @@ -14,7 +14,7 @@ #' \dontrun{ #' # This only works inside a 'fusen' built package #' pkg_structure <- get_package_structure() -#' draw_the_tree(pkg_structure) +#' draw_package_structure(pkg_structure) #' } #' #' # Example with a dummy package @@ -36,7 +36,7 @@ #' #' # Works with classical package #' pkg_structure <- get_package_structure() -#' draw_the_tree(pkg_structure) +#' draw_package_structure(pkg_structure) #' }) #' #' usethis::with_project(dummypackage, { @@ -50,7 +50,7 @@ #' ) #' #' pkg_structure <- get_package_structure() -#' draw_the_tree(pkg_structure) +#' draw_package_structure(pkg_structure) #' }) get_package_structure <- function( config_file, @@ -164,7 +164,7 @@ get_package_structure <- function( #' @export #' @rdname get_package_structure #' -draw_the_tree <- function(structure_list, silent = FALSE) { +draw_package_structure <- function(structure_list, silent = FALSE) { if (missing(structure_list)) { structure_list <- get_package_structure(silent = silent) } diff --git a/README.Rmd b/README.Rmd index 20a83f3..7e9ca2c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -144,7 +144,7 @@ There is a dedicated vignette to answer this: https://thinkr-open.github.io/fuse > Advice: Use git as soon as possible, this will avoid losing your work if you made some modifications in the wrong place -> Advice: Show the package structure with `fusen::draw_the_tree()` in a "dev/Readme.md" file to help developers +> Advice: Show the package structure with `fusen::draw_package_structure()` in a "dev/Readme.md" file to help developers ## Who is {fusen} for? diff --git a/README.md b/README.md index a604cdd..5ba9196 100644 --- a/README.md +++ b/README.md @@ -190,8 +190,9 @@ There is a dedicated vignette to answer this: > Advice: Use git as soon as possible, this will avoid losing your work > if you made some modifications in the wrong place -> Advice: Show the package structure with `fusen::draw_the_tree()` in a -> β€œdev/Readme.md” file to help developers +> Advice: Show the package structure with +> `fusen::draw_package_structure()` in a β€œdev/Readme.md” file to help +> developers ## Who is {fusen} for? diff --git a/dev/README.Rmd b/dev/README.Rmd index 69fb6d6..c25646e 100644 --- a/dev/README.Rmd +++ b/dev/README.Rmd @@ -10,6 +10,6 @@ The _keep_ section is for independent files, which were not issued from a flat f pkgload::load_all() usethis::with_project(here::here(), { - fusen::draw_the_tree(silent = TRUE) + fusen::draw_package_structure(silent = TRUE) }) ``` diff --git a/dev/README.md b/dev/README.md index 9a3d582..1f891f0 100644 --- a/dev/README.md +++ b/dev/README.md @@ -8,7 +8,7 @@ a flat file. pkgload::load_all() usethis::with_project(here::here(), { - fusen::draw_the_tree(silent = TRUE) + fusen::draw_package_structure(silent = TRUE) }) ``` @@ -74,7 +74,7 @@ usethis::with_project(here::here(), { - πŸ‘€ get\_all\_created\_funs - R/get\_package\_structure.R - πŸ‘€ get\_package\_structure - - πŸ‘€ draw\_the\_tree + - πŸ‘€ draw\_package\_structure - tests - tests/testthat/test-get\_package\_structure.R - tests/testthat/test-get\_all\_created\_funs.R diff --git a/dev/dev_history_cran.R b/dev/dev_history_cran.R index 89c9efb..350fd5e 100644 --- a/dev/dev_history_cran.R +++ b/dev/dev_history_cran.R @@ -53,13 +53,17 @@ Sys.setenv("FUSEN_TEST_PUBLISH" = "FALSE") # Run with r-devel using {rig} #> rig run devtools::check() +suppressMessages(devtools::test()) # interactivity # Update the tree structure of the package -fusen::draw_the_tree() +fusen::draw_package_structure() rmarkdown::render("dev/README.Rmd", output_format = "github_document", output_file = "README.md" ) +rmarkdown::render("README.Rmd", + output_format = "github_document", output_file = "README.md" +) # > Copy from Prepare-for-cran - https://github.com/ThinkR-open/prepare-for-cran ==================== diff --git a/dev/flat_get_package_structure.Rmd b/dev/flat_get_package_structure.Rmd index 1a307e0..3219857 100644 --- a/dev/flat_get_package_structure.Rmd +++ b/dev/flat_get_package_structure.Rmd @@ -154,7 +154,7 @@ get_package_structure <- function( #' @export #' @rdname get_package_structure #' -draw_the_tree <- function(structure_list, silent = FALSE) { +draw_package_structure <- function(structure_list, silent = FALSE) { if (missing(structure_list)) { structure_list <- get_package_structure(silent = silent) } @@ -215,7 +215,7 @@ draw_the_tree <- function(structure_list, silent = FALSE) { #' \dontrun{ #' # This only works inside a 'fusen' built package #' pkg_structure <- get_package_structure() -#' draw_the_tree(pkg_structure) +#' draw_package_structure(pkg_structure) #' } #' #' # Example with a dummy package @@ -237,7 +237,7 @@ usethis::with_project(dummypackage, { # Works with classical package pkg_structure <- get_package_structure() - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) }) usethis::with_project(dummypackage, { @@ -251,7 +251,7 @@ usethis::with_project(dummypackage, { ) pkg_structure <- get_package_structure() - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) }) ``` @@ -276,7 +276,7 @@ usethis::with_project(dummypackage, { pkg_structure <- get_package_structure() expect_snapshot(pkg_structure) - expect_snapshot(draw_the_tree(pkg_structure)) + expect_snapshot(draw_package_structure(pkg_structure)) }) @@ -307,7 +307,7 @@ usethis::with_project(dummypackage, { expect_snapshot(pkg_structure) - expect_snapshot(draw_the_tree(pkg_structure)) + expect_snapshot(draw_package_structure(pkg_structure)) }) }) ``` diff --git a/inst/the-dev-history.Rmd b/inst/the-dev-history.Rmd index 869193d..142b71e 100644 --- a/inst/the-dev-history.Rmd +++ b/inst/the-dev-history.Rmd @@ -60,7 +60,7 @@ usethis::use_code_of_conduct("contact@fake.com") # NEWS usethis::use_news_md() # Package structure (add this in a dev/Readme.md file) -fusen::draw_the_tree() +fusen::draw_package_structure() ``` **From now, you will need to "inflate" your package at least once to be able to use the following commands. Let's go to your flat template, and come back here later if/when needed.** diff --git a/man/get_package_structure.Rd b/man/get_package_structure.Rd index a0af447..839d2da 100644 --- a/man/get_package_structure.Rd +++ b/man/get_package_structure.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/get_package_structure.R \name{get_package_structure} \alias{get_package_structure} -\alias{draw_the_tree} +\alias{draw_package_structure} \title{Get structure and information of a 'fusen' built package for developers} \usage{ get_package_structure(config_file, emoji = TRUE, silent = FALSE) -draw_the_tree(structure_list, silent = FALSE) +draw_package_structure(structure_list, silent = FALSE) } \arguments{ \item{config_file}{Path to a source configuration file @@ -32,7 +32,7 @@ Draw a tree of the package structure in the console \dontrun{ # This only works inside a 'fusen' built package pkg_structure <- get_package_structure() -draw_the_tree(pkg_structure) +draw_package_structure(pkg_structure) } # Example with a dummy package @@ -54,7 +54,7 @@ usethis::with_project(dummypackage, { # Works with classical package pkg_structure <- get_package_structure() - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) }) usethis::with_project(dummypackage, { @@ -68,6 +68,6 @@ usethis::with_project(dummypackage, { ) pkg_structure <- get_package_structure() - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) }) } diff --git a/tests/testthat/_snaps/get_package_structure.md b/tests/testthat/_snaps/get_package_structure.md index 5a76f90..518d8a7 100644 --- a/tests/testthat/_snaps/get_package_structure.md +++ b/tests/testthat/_snaps/get_package_structure.md @@ -26,7 +26,7 @@ --- Code - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) Output - keep @@ -93,7 +93,7 @@ --- Code - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) Output - flat_full.Rmd diff --git a/tests/testthat/test-get_package_structure.R b/tests/testthat/test-get_package_structure.R index 8bab65e..c7f5672 100644 --- a/tests/testthat/test-get_package_structure.R +++ b/tests/testthat/test-get_package_structure.R @@ -20,7 +20,7 @@ usethis::with_project(dummypackage, { pkg_structure <- get_package_structure() expect_snapshot(pkg_structure) - expect_snapshot(draw_the_tree(pkg_structure)) + expect_snapshot(draw_package_structure(pkg_structure)) }) @@ -51,6 +51,6 @@ usethis::with_project(dummypackage, { expect_snapshot(pkg_structure) - expect_snapshot(draw_the_tree(pkg_structure)) + expect_snapshot(draw_package_structure(pkg_structure)) }) }) diff --git a/vignettes/Maintain-packages-with-fusen.Rmd b/vignettes/Maintain-packages-with-fusen.Rmd index 5195aae..ed15890 100644 --- a/vignettes/Maintain-packages-with-fusen.Rmd +++ b/vignettes/Maintain-packages-with-fusen.Rmd @@ -56,7 +56,7 @@ Your first `inflate()` may not directly work as expected as with any R code that > Advice 2: Use git as soon as possible, this will avoid losing your work if you made some modifications in the wrong place -> Advice 3: Create a Readme.Rmd in the "dev/" directory with a chunk having `fusen::draw_the_tree()` and knit it. This will help to understand the structure of your package and see what is inflated or not. Have a look at the {fusen} package itself on GitHub to see how it looks like. +> Advice 3: Create a Readme.Rmd in the "dev/" directory with a chunk having `fusen::draw_package_structure()` and knit it. This will help to understand the structure of your package and see what is inflated or not. Have a look at the {fusen} package itself on GitHub to see how it looks like. ## Option 1: Continue with the "flat_template.Rmd" diff --git a/vignettes/draw-a-tree-of-your-package-files-and-functions.Rmd b/vignettes/draw-a-tree-of-your-package-files-and-functions.Rmd index 3bddba1..a696cdb 100644 --- a/vignettes/draw-a-tree-of-your-package-files-and-functions.Rmd +++ b/vignettes/draw-a-tree-of-your-package-files-and-functions.Rmd @@ -45,7 +45,7 @@ With `draw_the_map()`, you can draw a tree of the package structure in the conso #' \dontrun{ #' # This only works inside a 'fusen' built package #' pkg_structure <- get_package_structure() -#' draw_the_tree(pkg_structure) +#' draw_package_structure(pkg_structure) #' } #' #' # Example with a dummy package @@ -67,7 +67,7 @@ usethis::with_project(dummypackage, { # Works with classical package pkg_structure <- get_package_structure() - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) }) usethis::with_project(dummypackage, { @@ -81,7 +81,7 @@ usethis::with_project(dummypackage, { ) pkg_structure <- get_package_structure() - draw_the_tree(pkg_structure) + draw_package_structure(pkg_structure) }) ``` diff --git a/vignettes/tips-and-tricks.Rmd b/vignettes/tips-and-tricks.Rmd index e9c0a41..d97fa89 100644 --- a/vignettes/tips-and-tricks.Rmd +++ b/vignettes/tips-and-tricks.Rmd @@ -423,5 +423,5 @@ Although default {golem} "dev/" files already contain the main actions to mainta # How can I know if R files were created from a flat or not ? -You can draw the structure of your package with `fusen:::draw_the_tree(). +You can draw the structure of your package with `fusen:::draw_package_structure(). Read vignette "Draw a tree of your package files and functions"" for more details. \ No newline at end of file