Skip to content

Commit

Permalink
refactor: rename draw_package_structure
Browse files Browse the repository at this point in the history
  • Loading branch information
statnmap committed May 13, 2024
1 parent 2de9db2 commit 0000e8c
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions R/get_package_structure.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, {
Expand All @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion dev/README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
```
4 changes: 2 additions & 2 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
```

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion dev/dev_history_cran.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ====================
Expand Down
12 changes: 6 additions & 6 deletions dev/flat_get_package_structure.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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, {
Expand All @@ -251,7 +251,7 @@ usethis::with_project(dummypackage, {
)
pkg_structure <- get_package_structure()
draw_the_tree(pkg_structure)
draw_package_structure(pkg_structure)
})
```

Expand All @@ -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))
})
Expand Down Expand Up @@ -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))
})
})
```
Expand Down
2 changes: 1 addition & 1 deletion inst/the-dev-history.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ usethis::use_code_of_conduct("[email protected]")
# 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.**
Expand Down
10 changes: 5 additions & 5 deletions man/get_package_structure.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/get_package_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
---

Code
draw_the_tree(pkg_structure)
draw_package_structure(pkg_structure)
Output
- keep
Expand Down Expand Up @@ -93,7 +93,7 @@
---

Code
draw_the_tree(pkg_structure)
draw_package_structure(pkg_structure)
Output
- flat_full.Rmd
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-get_package_structure.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})


Expand Down Expand Up @@ -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))
})
})
2 changes: 1 addition & 1 deletion vignettes/Maintain-packages-with-fusen.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions vignettes/draw-a-tree-of-your-package-files-and-functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, {
Expand All @@ -81,7 +81,7 @@ usethis::with_project(dummypackage, {
)
pkg_structure <- get_package_structure()
draw_the_tree(pkg_structure)
draw_package_structure(pkg_structure)
})
```

Expand Down
2 changes: 1 addition & 1 deletion vignettes/tips-and-tricks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 0000e8c

Please sign in to comment.