Skip to content

Commit 074a140

Browse files
authored
Merge pull request #50 from ThinkR-open/47-escape-line
v0.2.5 - Prepare for CRAN
2 parents bb024ee + d5c3aa4 commit 074a140

File tree

14 files changed

+197
-44
lines changed

14 files changed

+197
-44
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.2.4.9001
3+
Version: 0.2.5
44
Authors@R:
55
c(person(given = "Sébastien",
66
family = "Rochette",

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# attachment 0.2.4.900x
1+
# attachment 0.2.5
22
## Major changes
33

44
* add `create_renv_for_dev()` and `create_renv_for_prod()` function to create `renv.lock` file based on development project (@VincentGuyader and @statnmap).
5+
* Quarto documents can be parsed with `att_from_rmds()`.
6+
* Documentation for bookdown and quarto dependencies extraction updated
57

68
## Minor changes
79

810
* `att_amend_desc()` now saves file before processing
11+
* Newline escape code `\n` will not interfere with package discovery
912

1013
# attachment 0.2.4
1114

R/att_from_rmds.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ att_from_rmd <- function(path, temp_dir = tempdir(), warn = -1,
6060
yaml <- c("\n# yaml to parse \n",
6161
paste(yaml_pkg, "\n"))
6262
cat(yaml, file = r_file, append = TRUE)
63-
att_from_rscript(r_file)
63+
res <- att_from_rscript(r_file)
64+
65+
# clean tempdir
66+
file.remove(runR)
67+
file.remove(r_file)
68+
69+
return(res)
6470
}
6571

6672
#' Get all packages called in vignettes folder
@@ -81,7 +87,7 @@ att_from_rmd <- function(path, temp_dir = tempdir(), warn = -1,
8187

8288
#' @export
8389
att_from_rmds <- function(path = "vignettes",
84-
pattern = "*.[.](Rmd|rmd)$",
90+
pattern = "*.[.](Rmd|rmd|qmd)$",
8591
recursive = TRUE, warn = -1,
8692
inside_rmd = FALSE, inline = TRUE) {
8793

R/att_from_rscripts.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
att_from_rscript <- function(path) {
2020

2121
file <- as.character(parse(path))
22+
# Replace newlines `\n` by space
23+
file <- gsub("\\\\n", " ", file)
2224

2325
pkg_points <- file %>%
2426
.[grep("^#", ., invert = TRUE)] %>%

README.Rmd

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,27 @@ for (i in to_install) {
108108
}
109109
```
110110

111-
### For bookdown
111+
### For bookdown, pagedown, quarto
112112

113-
If you write a {bookdown} and want to publish it on Github using Travis 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()`.
113+
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()`.
114114

115115
```{r, eval=FALSE}
116+
usethis::use_description()
116117
# bookdown Imports are in Rmds
117118
imports <- c("bookdown", attachment::att_from_rmds("."))
118119
attachment::att_to_desc_from_is(path.d = "DESCRIPTION",
119120
imports = imports, suggests = NULL)
120121
```
121122

123+
Then, install dependencies with
124+
```{r, eval=FALSE}
125+
remotes::install_deps()
126+
```
127+
122128

123129
### To list information
124-
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 files using `att_from_rmds()`.
130+
131+
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()`.
125132
If you are running this inside a Rmd, you may need parameter `inside_rmd = TRUE`.
126133

127134
```{r, eval=TRUE}
@@ -131,17 +138,18 @@ att_from_rscripts(path = dummypackage)
131138
att_from_rmds(path = file.path(dummypackage, "vignettes"), inside_rmd = TRUE)
132139
```
133140

134-
## Vignette
141+
## Vignettes
135142

136-
Package {attachment} has a vignette 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*)
143+
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*)
137144

138145
```{r, eval=FALSE}
139-
vignette("fill-pkg-description", package = "attachment")
146+
vignette("a-fill-pkg-description", package = "attachment")
147+
vignette("b-bookdown-and-scripts", package = "attachment")
148+
vignette("use_renv", package = "attachment")
140149
```
141150

142-
The vignette is available on the {pkgdown} page: <https://thinkr-open.github.io/attachment/articles/fill-pkg-description.html>
151+
The vignettes are available on the {pkgdown} page, in the "Articles" menu: <https://thinkr-open.github.io/attachment/>
143152

144-
See full documentation realized using {pkgdown} at <https://thinkr-open.github.io/attachment/>
145153

146154
## Code of Conduct
147155

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ dummypackage <- file.path(tmpdir, "dummypackage")
8585
# browseURL(dummypackage)
8686
att_amend_desc(path = dummypackage, inside_rmd = TRUE)
8787
#> Updating dummypackage documentation
88-
#> Updating roxygen version in /tmp/RtmpdAJaCu/dummypackage/DESCRIPTION
88+
#> Updating roxygen version in /tmp/RtmpK2L9Ud/dummypackage/DESCRIPTION
8989
#> ℹ Loading dummypackage
9090
#> Writing NAMESPACE
9191
#> Writing NAMESPACE
9292
#> Package(s) Rcpp is(are) in category 'LinkingTo'. Check your Description file to be sure it is really what you want.
9393
#> [-] 1 package(s) removed: utils.
94-
#> [+] 2 package(s) added: stats, ggplot2.
94+
#> [+] 2 package(s) added: stats, glue.
9595
```
9696

9797
### For installation
@@ -130,24 +130,32 @@ for (i in to_install) {
130130
}
131131
```
132132

133-
### For bookdown
133+
### For bookdown, pagedown, quarto
134134

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

140141
``` r
142+
usethis::use_description()
141143
# bookdown Imports are in Rmds
142144
imports <- c("bookdown", attachment::att_from_rmds("."))
143145
attachment::att_to_desc_from_is(path.d = "DESCRIPTION",
144146
imports = imports, suggests = NULL)
145147
```
146148

149+
Then, install dependencies with
150+
151+
``` r
152+
remotes::install_deps()
153+
```
154+
147155
### To list information
148156

149157
Of course, you can also use {attachment} out of a package to list all
150-
package dependencies of R scripts using `att_from_rscripts()` or Rmd
158+
package dependencies of R scripts using `att_from_rscripts()` or Rmd/qmd
151159
files using `att_from_rmds()`.
152160
If you are running this inside a Rmd, you may need parameter
153161
`inside_rmd = TRUE`.
@@ -158,26 +166,25 @@ dummypackage <- system.file("dummypackage", package = "attachment")
158166
att_from_rscripts(path = dummypackage)
159167
#> [1] "stats" "testthat" "dummypackage"
160168
att_from_rmds(path = file.path(dummypackage, "vignettes"), inside_rmd = TRUE)
161-
#> [1] "knitr" "rmarkdown" "ggplot2"
169+
#> [1] "knitr" "rmarkdown" "glue"
162170
```
163171

164-
## Vignette
172+
## Vignettes
165173

166-
Package {attachment} has a vignette to present the different functions
174+
Package {attachment} has vignettes to present the different functions
167175
available. There is also a recommendation to have a `dev_history.R` in
168176
the root directory of your package. (*Have a look at
169-
[dev\_history.R](https://github.com/ThinkR-open/attachment/blob/main/dev/dev_history.R)
177+
[dev_history.R](https://github.com/ThinkR-open/attachment/blob/main/dev/dev_history.R)
170178
in the present package*)
171179

172180
``` r
173-
vignette("fill-pkg-description", package = "attachment")
181+
vignette("a-fill-pkg-description", package = "attachment")
182+
vignette("b-bookdown-and-scripts", package = "attachment")
183+
vignette("use_renv", package = "attachment")
174184
```
175185

176-
The vignette is available on the {pkgdown} page:
177-
<https://thinkr-open.github.io/attachment/articles/fill-pkg-description.html>
178-
179-
See full documentation realized using {pkgdown} at
180-
<https://thinkr-open.github.io/attachment/>
186+
The vignettes are available on the {pkgdown} page, in the “Articles”
187+
menu: <https://thinkr-open.github.io/attachment/>
181188

182189
## Code of Conduct
183190

dev/dev_history.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
111111

112112
# Check content
113113
# remotes::install_github("ThinkR-open/checkhelper")
114-
checkhelper::find_missing_tags()
114+
out <- checkhelper::find_missing_tags()
115+
View(out)
115116

116117
# Check spelling
117118
# usethis::use_spell_check()
@@ -137,6 +138,7 @@ aa
137138
# _win devel
138139
devtools::check_win_devel()
139140
devtools::check_win_release()
141+
devtools::check_mac_release()
140142

141143
# Check reverse dependencies
142144
# remotes::install_github("r-lib/revdepcheck")
@@ -146,14 +148,17 @@ usethis::use_build_ignore("revdep/")
146148
devtools::revdep()
147149
library(revdepcheck)
148150
# In another session
151+
revdepcheck::revdep_todo()
152+
# revdepcheck::revdep_add(packages = "fusen")
149153
id <- rstudioapi::terminalExecute("Rscript -e 'revdepcheck::revdep_check(num_workers = 4)'")
150154
rstudioapi::terminalKill(id)
151155
# See outputs
152-
revdep_details(revdep = "pkg")
153-
revdep_summary() # table of results by package
156+
revdep_details(revdep = "fusen")
157+
revdep_summary()
158+
# table of results by package
154159
revdep_report() # in revdep/
155160
# Clean up when on CRAN
156-
revdep_reset()
161+
revdepcheck::revdep_reset()
157162

158163
# Update NEWS
159164
# Bump version manually and add list of changes

man/att_from_rmds.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/escape_newline.R

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This code contains knitr on a newline and should not be read with `\nknitr`
2+
3+
create_vignette_head <- function(pkg, vignette_name, yaml_options = NULL) {
4+
pkgname <- basename(pkg)
5+
6+
# Get all yaml options except Title, output, editor_options
7+
yaml_options <- yaml_options[
8+
!names(yaml_options) %in% c("output", "title", "editor_options")]
9+
10+
enc2utf8(
11+
glue(
12+
'---
13+
title: ".{vignette_name}."
14+
output: rmarkdown::html_vignette',
15+
ifelse(length(yaml_options) != 0,
16+
glue::glue_collapse(
17+
c("",
18+
glue("{names(yaml_options)}: \"{yaml_options}\""), ""),
19+
sep = "\n"),
20+
"\n"),
21+
'vignette: >
22+
%\\VignetteIndexEntry{.{vignette_name}.}
23+
%\\VignetteEngine{knitr::rmarkdown}
24+
%\\VignetteEncoding{UTF-8}
25+
---
26+
27+
```{r, include = FALSE}
28+
knitr::opts_chunk$set(
29+
collapse = TRUE,
30+
comment = "#>"
31+
)
32+
```
33+
34+
```{r setup}
35+
library(.{pkgname}.)
36+
```
37+
',
38+
.open = ".{", .close = "}."
39+
)
40+
)
41+
}

tests/testthat/quarto.qmd

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: "quarto demo"
3+
date: "5/22/2021"
4+
format:
5+
html:
6+
fig-width: 8
7+
fig-height: 4
8+
code-fold: true
9+
---
10+
11+
## Air Quality
12+
13+
@fig-airquality further explores the impact of temperature on ozone level.
14+
15+
```{r}
16+
#| label: fig-airquality
17+
#| fig-cap: Temperature and ozone level.
18+
#| warning: false
19+
20+
plot(pressure)
21+
utils::packageVersion("knitr")
22+
library("findme.quarto")
23+
# library("dontfindme.quarto")
24+
25+
```
26+
27+
## Python should not be parsed
28+
29+
```{python}
30+
#| label: fig-polar
31+
#| fig-cap: "A line plot on a polar axis"
32+
33+
import numpy as np
34+
import matplotlib.pyplot as plt
35+
36+
r = np.arange(0, 2, 0.01)
37+
theta = 2 * np.pi * r
38+
fig, ax = plt.subplots(
39+
subplot_kw = {'projection': 'polar'}
40+
)
41+
ax.plot(theta, r)
42+
ax.set_rticks([0.5, 1, 1.5, 2])
43+
ax.grid(True)
44+
plt.show()
45+
```
46+
47+

0 commit comments

Comments
 (0)