Skip to content

Commit

Permalink
close #597: ignore renv folders in both the site config and check_con…
Browse files Browse the repository at this point in the history
…tent()
  • Loading branch information
yihui committed Mar 15, 2021
1 parent b488452 commit 0cf9e1b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: blogdown
Type: Package
Title: Create Blogs and Websites with R Markdown
Version: 1.2.1
Version: 1.2.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0003-4474-2498")),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# CHANGES IN blogdown VERSION 1.3

## NEW FEATURES

- `check_config()` will suggest ignoring the `renv` folder and the `renv.lock` file in the Hugo config if **renv** is used in the project (thanks, @solarchemist, #597).

## MAJOR CHANGES

- The `method` argument of `build_site()` has been removed (it was defunct in **blogdown** v1.2). Please set the build method in the global option `options(blogdown.method = )` instead.

- The `use_brew` argument of `install_hugo()` has been removed.

## BUG FIXES

- `check_content()` will ignore `renv` folders when looking for Rmd/md files to be checked (thanks, @solarchemist, #597).

# CHANGES IN blogdown VERSION 1.2

## NEW FEATURES
Expand Down
5 changes: 4 additions & 1 deletion R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ check_config = function() {
}

msg_next('Checking "ignoreFiles" setting for Hugo...')
ignore = c('\\.Rmd$', '\\.Rmarkdown$', '_cache$', '\\.knit\\.md$', '\\.utf8\\.md$')
ignore = c(
'\\.Rmd$', '\\.Rmarkdown$', '_cache$', '\\.knit\\.md$', '\\.utf8\\.md$',
if (length(grep('/renv$', list.dirs()))) c('(^|/)renv$', 'renv\\.lock$')
)
if (is.null(s <- config[['ignoreFiles']])) {
# missing field: add one
msg_todo('Set "ignoreFiles" to ', xfun::tojson(ignore))
Expand Down
2 changes: 1 addition & 1 deletion R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ list_rmds = function(
# but include _index.Rmd/.md
files = files[!grepl('^_', basename(files)) | grepl('^_index[.]', basename(files))]
# exclude Rmd within packrat / renv library
files = files[!grepl('/(?:packrat|renv)/', files)]
files = files[!grepl('(^|/)(?:packrat|renv)/', files)]
# do not allow special characters in filenames so dependency names are more
# predictable, e.g. foo_files/
if (check) bookdown:::check_special_chars(files)
Expand Down
11 changes: 4 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,8 @@ rmd_pattern = '[.][Rr](md|markdown)$'
md_pattern = '[.][Rr]?(md|markdown)$'

# scan YAML metadata of all Rmd/md files
scan_yaml = function(dir = 'content', warn = TRUE) {
if (missing(dir)) dir = switch(generator(),
hugo = 'content', jekyll = '.', hexo = 'source'
)
files = list_files(dir, md_pattern)
scan_yaml = function(warn = TRUE) {
files = list_rmds(pattern = md_pattern)
if (length(files) == 0) return(list())
res = lapply(files, function(f) {
yaml = fetch_yaml(f)
Expand All @@ -669,10 +666,10 @@ scan_yaml = function(dir = 'content', warn = TRUE) {

# collect specific fields of all YAML metadata
collect_yaml = function(
fields = c('categories', 'tags'), dir, uniq = TRUE, sort = TRUE
fields = c('categories', 'tags'), uniq = TRUE, sort = TRUE
) {
res = list()
meta = scan_yaml(dir)
meta = scan_yaml()
for (i in fields) {
res[[i]] = unlist(lapply(meta, `[[`, i))
if (sort) res[[i]] = sort2(res[[i]])
Expand Down

0 comments on commit 0cf9e1b

Please sign in to comment.