Skip to content

Commit a9a3810

Browse files
authored
Merge pull request #98 from ThinkR-open/att_config
chore: Bump version for CRAN
2 parents ed1d3bc + d4093d7 commit a9a3810

File tree

6 files changed

+154
-78
lines changed

6 files changed

+154
-78
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: attachment
22
Title: Deal with Dependencies
3-
Version: 0.3.1.9003
3+
Version: 0.4.0
44
Authors@R: c(
55
person("Sébastien", "Rochette", , "[email protected]", role = c("cre", "aut"),
66
comment = c(ORCID = "0000-0002-1565-9313")),

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# attachment 0.3.1.XXXX
1+
# attachment 0.4.0
22

33
## Breaking changes
44

README.Rmd

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,46 +42,54 @@ install.packages("attachment")
4242

4343
Development version
4444
``` r
45-
# install.packages("devtools")
46-
devtools::install_github("ThinkR-open/attachment")
45+
install.packages('attachment', repos = c('https://thinkr-open.r-universe.dev', 'https://cloud.r-project.org'))
4746
```
4847

49-
## Use package {attachment}
50-
### During package development
51-
```{r}
52-
library(attachment)
53-
```
48+
## Declare all dependencies in DESCRIPTION during package development
5449

5550
What you really want is to fill and update your description file along with the modifications of your documentation. Indeed, only the following function will really be called. Use and abuse during the development of your package !
5651

5752
```{r, eval=FALSE}
5853
attachment::att_amend_desc()
5954
```
6055

61-
As {pkgdown} and {covr} are not listed in any script in your package, a common call for your development packages would be:
56+
{attachment} detects all calls to `library(pkg)`, `@importFrom pkg fun`, `pkg::fun()` in the different classical directories of your R package, then list them in the correct "Imports" or "Suggests" category in the DESCRIPTION file, according to their position in the package.
57+
58+
### Declare extra dependencies for extra uses
59+
60+
If you want to add extra packages like {pkgdown} or {covr} that are not listed in any script in your package, a call for your development packages would be:
6261
```{r, eval=FALSE}
63-
attachment::att_amend_desc(extra.suggests = c("pkgdown", "covr"))
62+
attachment::att_amend_desc(extra.suggests = c("pkgdown", "covr"), update.config = TRUE)
6463
```
6564

66-
If you would like to add dependencies in the "Remotes" field of your DESCRIPTION file, to mimic your local installation, you will want to use:
65+
Note the `update.config = TRUE` parameter that will save the parameters used in the call of `att_amend_desc()` to the package configuration file: "dev/config_attachment.yaml".
66+
67+
If you run `att_amend_desc()` a second time afterwards, directly from the console, it will use the last set of parameters extracted from the configuration file.
68+
69+
Indeed, we recommend to store the complete command line in a "dev/dev_history.R" file to update and run it when needed. If the parameters do not change, you can run `attachment::att_amend_desc()` directly in the console, wherever you are, it will use the configuration file.
70+
71+
### Automatically fill the "Remotes" field
72+
73+
If you would like to detect the sources of your installations so that you can add dependencies in the "Remotes" field of your DESCRIPTION file, to mimic your local installation, you will use:
6774

6875
```{r, eval=FALSE}
6976
attachment::set_remotes_to_desc()
7077
```
7178

7279

73-
#### Example on a fake package
80+
## Example on a fake package
7481

7582
```{r}
76-
# Copy package in a temporary directory
83+
# Copy example package in a temporary directory
7784
tmpdir <- tempfile(pattern = "fakepkg")
7885
dir.create(tmpdir)
7986
file.copy(system.file("dummypackage",package = "attachment"), tmpdir, recursive = TRUE)
8087
dummypackage <- file.path(tmpdir, "dummypackage")
8188
# browseURL(dummypackage)
8289
8390
# Fill the DESCRIPTION file automatically
84-
desc_file <- attachment::att_amend_desc(path = dummypackage, inside_rmd = TRUE)
91+
# `inside_rmd` is specifically designed here to allow to run this command line in the "Readme.Rmd" file
92+
desc_file <- attachment::att_amend_desc(path = dummypackage, inside_rmd = TRUE, update.config = TRUE)
8593
8694
# Add Remotes if you have some installed
8795
attachment::set_remotes_to_desc(path.d = desc_file)
@@ -90,10 +98,10 @@ attachment::set_remotes_to_desc(path.d = desc_file)
9098
unlink(tmpdir, recursive = TRUE)
9199
```
92100

93-
#### More on finding Remotes repositories (non installed from CRAN)
101+
## More on finding Remotes repositories (non installed from CRAN)
94102

95103
Find packages installed out of CRAN. This helps fill the "Remotes" field in DESCRIPTION file with `set_remotes_to_desc()`.
96-
Behind the scene, it uses `fund_remotes()`.
104+
Behind the scene, it uses `find_remotes()`.
97105

98106
- See the examples below if {fusen} is installed from GitHub
99107
+ Also works for GitLab, Bioconductor, Git, Local installations
@@ -108,25 +116,25 @@ attachment::find_remotes("fusen")
108116
```
109117

110118

111-
### For installation
119+
## Find and install missing dependencies required for your R scripts
112120
To quickly install missing packages from a DESCRIPTION file, use:
113121

114122
```{r, eval=TRUE}
115123
attachment::install_from_description()
116124
```
117125

118-
To quickly install missing packages needed to compile Rmd files or run Rscripts, use:
126+
To quickly install missing packages needed to compile Rmd files or run R scripts, use:
119127

120128
```{r, eval=FALSE}
121-
attachment::att_from_rmds(path = ".") %>% attachment::install_if_missing()
129+
attachment::att_from_rmds(path = ".") |> attachment::install_if_missing()
122130
123-
attachment::att_from_rscripts(path = ".") %>% attachment::install_if_missing()
131+
attachment::att_from_rscripts(path = ".") |> attachment::install_if_missing()
124132
```
125133

126134
Function `attachment::create_dependencies_file()` will create a `dependencies.R` file in `inst/` directory. This R script contains the procedure to quickly install missing dependencies:
127135

128136
```{r eval=FALSE}
129-
# No Remotes ----
137+
# Remotes ----
130138
# remotes::install_github("ThinkR-open/fcuk")
131139
# Attachments ----
132140
to_install <- c("covr", "desc", "devtools", "glue", "knitr", "magrittr", "rmarkdown", "stats", "stringr", "testthat", "utils")
@@ -139,7 +147,7 @@ for (i in to_install) {
139147
}
140148
```
141149

142-
### For bookdown, pagedown, quarto
150+
## Allow the CI to install all dependencies required for your bookdown, pagedown, quarto, ...
143151

144152
If you write a {bookdown} and want to publish it on Github using GitHub Actions or GitLab CI for instance, you will need a DESCRIPTION file with list of dependencies just like for a package. In this case, you can use the function to description from import/suggest: `att_to_desc_from_is()`.
145153

@@ -157,26 +165,28 @@ remotes::install_deps()
157165
```
158166

159167

160-
### To list information
168+
## List packages required in any script or notebook
161169

162170
Of course, you can also use {attachment} out of a package to list all package dependencies of R scripts using `att_from_rscripts()` or Rmd/qmd files using `att_from_rmds()`.
163171
If you are running this inside a Rmd, you may need parameter `inside_rmd = TRUE`.
164172

165173
```{r, eval=TRUE}
174+
library(attachment)
166175
dummypackage <- system.file("dummypackage", package = "attachment")
167176
168177
att_from_rscripts(path = dummypackage)
169178
att_from_rmds(path = file.path(dummypackage, "vignettes"), inside_rmd = TRUE)
170179
```
171180

172-
## Vignettes
181+
## Vignettes included
173182

174183
Package {attachment} has vignettes to present the different functions available. There is also a recommendation to have a `dev_history.R` in the root directory of your package. (*Have a look at [dev_history.R](https://github.com/ThinkR-open/attachment/blob/main/dev/dev_history.R) in the present package*)
175184

176185
```{r, eval=FALSE}
177186
vignette("a-fill-pkg-description", package = "attachment")
178187
vignette("b-bookdown-and-scripts", package = "attachment")
179188
vignette("use_renv", package = "attachment")
189+
vignette("create-dependencies-file", package = "attachment")
180190
```
181191

182192
The vignettes are available on the {pkgdown} page, in the "Articles" menu: <https://thinkr-open.github.io/attachment/>

README.md

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,10 @@ install.packages("attachment")
4444
Development version
4545

4646
``` r
47-
# install.packages("devtools")
48-
devtools::install_github("ThinkR-open/attachment")
47+
install.packages('attachment', repos = c('https://thinkr-open.r-universe.dev', 'https://cloud.r-project.org'))
4948
```
5049

51-
## Use package {attachment}
52-
53-
### During package development
54-
55-
``` r
56-
library(attachment)
57-
```
50+
## Declare all dependencies in DESCRIPTION during package development
5851

5952
What you really want is to fill and update your description file along
6053
with the modifications of your documentation. Indeed, only the following
@@ -65,25 +58,49 @@ your package !
6558
attachment::att_amend_desc()
6659
```
6760

68-
As {pkgdown} and {covr} are not listed in any script in your package, a
69-
common call for your development packages would be:
61+
{attachment} detects all calls to `library(pkg)`, `@importFrom pkg fun`,
62+
`pkg::fun()` in the different classical directories of your R package,
63+
then list them in the correct “Imports” or “Suggests” category in the
64+
DESCRIPTION file, according to their position in the package.
65+
66+
### Declare extra dependencies for extra uses
67+
68+
If you want to add extra packages like {pkgdown} or {covr} that are not
69+
listed in any script in your package, a call for your development
70+
packages would be:
7071

7172
``` r
72-
attachment::att_amend_desc(extra.suggests = c("pkgdown", "covr"))
73+
attachment::att_amend_desc(extra.suggests = c("pkgdown", "covr"), update.config = TRUE)
7374
```
7475

75-
If you would like to add dependencies in the “Remotes” field of your
76-
DESCRIPTION file, to mimic your local installation, you will want to
77-
use:
76+
Note the `update.config = TRUE` parameter that will save the parameters
77+
used in the call of `att_amend_desc()` to the package configuration
78+
file: “dev/config_attachment.yaml”.
79+
80+
If you run `att_amend_desc()` a second time afterwards, directly from
81+
the console, it will use the last set of parameters extracted from the
82+
configuration file.
83+
84+
Indeed, we recommend to store the complete command line in a
85+
“dev/dev_history.R” file to update and run it when needed. If the
86+
parameters do not change, you can run `attachment::att_amend_desc()`
87+
directly in the console, wherever you are, it will use the configuration
88+
file.
89+
90+
### Automatically fill the “Remotes” field
91+
92+
If you would like to detect the sources of your installations so that
93+
you can add dependencies in the “Remotes” field of your DESCRIPTION
94+
file, to mimic your local installation, you will use:
7895

7996
``` r
8097
attachment::set_remotes_to_desc()
8198
```
8299

83-
#### Example on a fake package
100+
## Example on a fake package
84101

85102
``` r
86-
# Copy package in a temporary directory
103+
# Copy example package in a temporary directory
87104
tmpdir <- tempfile(pattern = "fakepkg")
88105
dir.create(tmpdir)
89106
file.copy(system.file("dummypackage",package = "attachment"), tmpdir, recursive = TRUE)
@@ -92,21 +109,22 @@ dummypackage <- file.path(tmpdir, "dummypackage")
92109
# browseURL(dummypackage)
93110

94111
# Fill the DESCRIPTION file automatically
95-
desc_file <- attachment::att_amend_desc(path = dummypackage, inside_rmd = TRUE)
112+
# `inside_rmd` is specifically designed here to allow to run this command line in the "Readme.Rmd" file
113+
desc_file <- attachment::att_amend_desc(path = dummypackage, inside_rmd = TRUE, update.config = TRUE)
114+
#> 'update.config' was set to TRUE, hence, 'use.config' was forced to FALSE
115+
#> Saving attachment parameters to yaml config file
96116
#> Updating dummypackage documentation
97117
#> ────────────────────────────────────────────────────────────────────────────────
98118
#> Changes in roxygen2 7.0.0:
99119
#> * `%` is now escaped automatically in Markdown mode.
100120
#> Please carefully check .Rd files for changes
101121
#> ────────────────────────────────────────────────────────────────────────────────
102122
#>
103-
#> Setting `RoxygenNote` to "7.2.0"
123+
#> Setting `RoxygenNote` to "7.2.2"
104124
#> ℹ Loading dummypackage
105-
#>
106-
#> Writing 'NAMESPACE'
107-
#> Writing 'NAMESPACE'
125+
#> Writing ']8;;file:///tmp/Rtmp3Dpn4h/fakepkg3538450e5c49/dummypackage/NAMESPACENAMESPACE]8;;'
126+
#> Writing ']8;;file:///tmp/Rtmp3Dpn4h/fakepkg3538450e5c49/dummypackage/NAMESPACENAMESPACE]8;;'
108127
#> ℹ Loading dummypackage
109-
#>
110128
#> Package(s) Rcpp is(are) in category 'LinkingTo'. Check your Description file to be sure it is really what you want.
111129
#>
112130
#> [-] 1 package(s) removed: utils.
@@ -122,14 +140,14 @@ attachment::set_remotes_to_desc(path.d = desc_file)
122140
unlink(tmpdir, recursive = TRUE)
123141
```
124142

125-
#### More on finding Remotes repositories (non installed from CRAN)
143+
## More on finding Remotes repositories (non installed from CRAN)
126144

127145
Find packages installed out of CRAN. This helps fill the “Remotes” field
128146
in DESCRIPTION file with `set_remotes_to_desc()`.
129-
Behind the scene, it uses `fund_remotes()`.
147+
Behind the scene, it uses `find_remotes()`.
130148

131-
- See the examples below if {fusen} is installed from GitHub
132-
- Also works for GitLab, Bioconductor, Git, Local installations
149+
- See the examples below if {fusen} is installed from GitHub
150+
- Also works for GitLab, Bioconductor, Git, Local installations
133151

134152
``` r
135153
# From GitHub
@@ -140,7 +158,7 @@ attachment::find_remotes("fusen")
140158
#> [1] "ThinkR-open/fusen"
141159
```
142160

143-
### For installation
161+
## Find and install missing dependencies required for your R scripts
144162

145163
To quickly install missing packages from a DESCRIPTION file, use:
146164

@@ -149,21 +167,21 @@ attachment::install_from_description()
149167
#> All required packages are installed
150168
```
151169

152-
To quickly install missing packages needed to compile Rmd files or run
153-
Rscripts, use:
170+
To quickly install missing packages needed to compile Rmd files or run R
171+
scripts, use:
154172

155173
``` r
156-
attachment::att_from_rmds(path = ".") %>% attachment::install_if_missing()
174+
attachment::att_from_rmds(path = ".") |> attachment::install_if_missing()
157175

158-
attachment::att_from_rscripts(path = ".") %>% attachment::install_if_missing()
176+
attachment::att_from_rscripts(path = ".") |> attachment::install_if_missing()
159177
```
160178

161179
Function `attachment::create_dependencies_file()` will create a
162180
`dependencies.R` file in `inst/` directory. This R script contains the
163181
procedure to quickly install missing dependencies:
164182

165183
``` r
166-
# No Remotes ----
184+
# Remotes ----
167185
# remotes::install_github("ThinkR-open/fcuk")
168186
# Attachments ----
169187
to_install <- c("covr", "desc", "devtools", "glue", "knitr", "magrittr", "rmarkdown", "stats", "stringr", "testthat", "utils")
@@ -176,7 +194,7 @@ for (i in to_install) {
176194
}
177195
```
178196

179-
### For bookdown, pagedown, quarto
197+
## Allow the CI to install all dependencies required for your bookdown, pagedown, quarto, …
180198

181199
If you write a {bookdown} and want to publish it on Github using GitHub
182200
Actions or GitLab CI for instance, you will need a DESCRIPTION file with
@@ -198,7 +216,7 @@ Then, install dependencies with
198216
remotes::install_deps()
199217
```
200218

201-
### To list information
219+
## List packages required in any script or notebook
202220

203221
Of course, you can also use {attachment} out of a package to list all
204222
package dependencies of R scripts using `att_from_rscripts()` or Rmd/qmd
@@ -207,6 +225,7 @@ If you are running this inside a Rmd, you may need parameter
207225
`inside_rmd = TRUE`.
208226

209227
``` r
228+
library(attachment)
210229
dummypackage <- system.file("dummypackage", package = "attachment")
211230

212231
att_from_rscripts(path = dummypackage)
@@ -215,7 +234,7 @@ att_from_rmds(path = file.path(dummypackage, "vignettes"), inside_rmd = TRUE)
215234
#> [1] "knitr" "rmarkdown" "glue"
216235
```
217236

218-
## Vignettes
237+
## Vignettes included
219238

220239
Package {attachment} has vignettes to present the different functions
221240
available. There is also a recommendation to have a `dev_history.R` in
@@ -227,6 +246,7 @@ in the present package*)
227246
vignette("a-fill-pkg-description", package = "attachment")
228247
vignette("b-bookdown-and-scripts", package = "attachment")
229248
vignette("use_renv", package = "attachment")
249+
vignette("create-dependencies-file", package = "attachment")
230250
```
231251

232252
The vignettes are available on the {pkgdown} page, in the “Articles”

_pkgdown.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
template:
2-
package: thinkrtemplate
1+
# template:
2+
# package: thinkrtemplate
33

44
url: https://thinkr-open.github.io/attachment/
55

66
development:
77
mode: auto
8+
9+
template:
10+
bootstrap: 5
11+
bslib:
12+
bg: "#ffffff"
13+
fg: "#3b4450"
14+
primary: "#DE633C"
15+
secondary: "#15b7d6"
16+
body-color: "#28292B"

0 commit comments

Comments
 (0)