Skip to content

Commit 97740f3

Browse files
Change hook type of {pkgdown} hook to script
1 parent c811fe4 commit 97740f3

File tree

8 files changed

+44
-44
lines changed

8 files changed

+44
-44
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ repos:
8686
renv/activate.R|
8787
vignettes/FAQ\.Rmd|
8888
)$
89-
# - id: pkgdown-check
90-
# additional_dependencies:
91-
# - pkgdown
92-
# - mockery
89+
# - id: pkgdown-check
9390
- repo: https://github.com/pre-commit/pre-commit-hooks
9491
rev: v4.3.0
9592
hooks:

.pre-commit-hooks.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
- id: roxygenize
22
name: roxygenize
3-
description: run roxygen2::roxygenize()
3+
description: run `roxygen2::roxygenize()`
44
entry: Rscript inst/hooks/exported/roxygenize.R
55
language: r
66
files: '^(R|man)/'
77
require_serial: true
88
minimum_pre_commit_version: "2.13.0"
99
- id: use-tidy-description
1010
name: use-tidy-description
11-
description: run usethis::use_tidy_description()
11+
description: run `usethis::use_tidy_description()`
1212
entry: Rscript inst/hooks/exported/use-tidy-description.R
1313
language: r
1414
files: '^DESCRIPTION$'
1515
minimum_pre_commit_version: "2.13.0"
1616
- id: style-files
1717
name: style-files
18-
description: style files with styler
18+
description: style files with {styler}
1919
entry: Rscript inst/hooks/exported/style-files.R
2020
language: r
2121
files: '(\.[rR]profile|\.[rR]|\.[rR]md|\.[rR]nw|\.[qQ]md)$'
@@ -44,21 +44,21 @@
4444
minimum_pre_commit_version: "2.13.0"
4545
- id: readme-rmd-rendered
4646
name: readme-rmd-rendered
47-
description: make sure README.Rmd hasn't been edited more recently than README.md
47+
description: make sure README.Rmd hasn't been edited more recently than `README.md`
4848
entry: Rscript inst/hooks/exported/readme-rmd-rendered.R
4949
language: r
5050
files: 'README\.[Rr]?md$'
5151
minimum_pre_commit_version: "2.13.0"
5252
- id: codemeta-description-updated
5353
name: codemeta-description-updated
54-
description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description.
54+
description: make sure `codemeta.json` is in sync with `DESCRIPTION`. It should be run after use-tidy-description
5555
entry: Rscript inst/hooks/exported/codemeta-description-updated.R
5656
language: r
5757
files: '^DESCRIPTION$'
5858
minimum_pre_commit_version: "2.13.0"
5959
- id: spell-check
6060
name: spell-check
61-
description: perform a spell check with spelling::spell_check_files()
61+
description: perform a spell check with `spelling::spell_check_files()`
6262
entry: Rscript inst/hooks/exported/spell-check.R
6363
language: r
6464
exclude: >
@@ -92,24 +92,24 @@
9292
minimum_pre_commit_version: "2.13.0"
9393
- id: deps-in-desc
9494
name: deps-in-desc
95-
description: Check if dependencies that can be parsed from code are in DESCRIPTION.
95+
description: Check if dependencies that can be parsed from code are in `DESCRIPTION`
9696
entry: Rscript inst/hooks/exported/deps-in-desc.R
9797
language: r
9898
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
9999
exclude: 'renv/activate\.R'
100100
minimum_pre_commit_version: "2.13.0"
101101
- id: lintr
102102
name: lintr
103-
description: check if a .R file is lint free (using lintr)
103+
description: check if a `.R` file is lint free (using {lintr})
104104
entry: Rscript inst/hooks/exported/lintr.R
105105
language: r
106106
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
107107
exclude: 'renv/activate\.R'
108108
minimum_pre_commit_version: "2.13.0"
109109
- id: pkgdown-check
110110
name: pkgdown-check
111-
description: check if _pkgdown.yml has the correct entries for references and articles.
112-
entry: Rscript inst/hooks/exported/pkgdown-check.R
113-
language: r
111+
description: check if your {pkgdown} config file has the correct entries for references and articles
112+
entry: inst/hooks/exported/pkgdown-check.R
113+
language: script
114114
minimum_pre_commit_version: "2.13.0"
115115
files: '^man/|_pkgdown\.yml'

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ editor_options:
44
wrap: 72
55
---
66

7-
# precommit v0.3.2.9001 (Development version)
7+
# precommit v0.3.2.9003 (Development version)
88

9+
- new hook `pkgdown-check` to emulate a {pkgdown} build for reference and
10+
articles (#393).
911
- `codemeta-description-updated`, `roxygenize`, and
1012
`use-tidy-description` now all support a `root` argument that
1113
specifies the directory in the git repo that contains the R package.

inst/hooks/exported/pkgdown-check.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env Rscript
22

33
if (!require(pkgdown, quietly = TRUE)) {
4-
stop("{pkgdown} could not be loaded.")
4+
stop("{pkgdown} could not be loaded, please install it.")
55
}
66
if (!require(mockery, quietly = TRUE)) {
7-
stop("{mockery} could not be loaded.")
7+
stop("{mockery} could not be loaded, please install it.")
88
}
99

1010
stub_render_page <- function(pkg, name, data, ...) {
@@ -13,6 +13,7 @@ stub_render_page <- function(pkg, name, data, ...) {
1313
stub(build_reference_index, "render_page", stub_render_page)
1414
stub(build_articles_index, "render_page", stub_render_page)
1515
config <- yaml::read_yaml(pkgdown:::pkgdown_config_path("."))
16+
1617
tryCatch(
1718
{
1819
if ("reference" %in% names(config)) {

inst/pre-commit-config-pkg.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ repos:
4646
- id: no-browser-statement
4747
- id: no-debug-statement
4848
- id: deps-in-desc
49-
- id: pkgdown-check
50-
additional_dependencies:
51-
- pkgdown
52-
- mockery
5349
- repo: https://github.com/pre-commit/pre-commit-hooks
5450
rev: v1.2.3
5551
hooks:

inst/pre-commit-hooks.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
- id: roxygenize
22
name: roxygenize
3-
description: run roxygen2::roxygenize()
3+
description: run `roxygen2::roxygenize()`
44
entry: Rscript inst/hooks/exported/roxygenize.R
55
language: r
66
files: '^(R|man)/'
77
require_serial: true
88
minimum_pre_commit_version: "2.13.0"
99
- id: use-tidy-description
1010
name: use-tidy-description
11-
description: run usethis::use_tidy_description()
11+
description: run `usethis::use_tidy_description()`
1212
entry: Rscript inst/hooks/exported/use-tidy-description.R
1313
language: r
1414
files: '^DESCRIPTION$'
1515
minimum_pre_commit_version: "2.13.0"
1616
- id: style-files
1717
name: style-files
18-
description: style files with styler
18+
description: style files with {styler}
1919
entry: Rscript inst/hooks/exported/style-files.R
2020
language: r
2121
files: '(\.[rR]profile|\.[rR]|\.[rR]md|\.[rR]nw|\.[qQ]md)$'
@@ -44,21 +44,21 @@
4444
minimum_pre_commit_version: "2.13.0"
4545
- id: readme-rmd-rendered
4646
name: readme-rmd-rendered
47-
description: make sure README.Rmd hasn't been edited more recently than README.md
47+
description: make sure README.Rmd hasn't been edited more recently than `README.md`
4848
entry: Rscript inst/hooks/exported/readme-rmd-rendered.R
4949
language: r
5050
files: 'README\.[Rr]?md$'
5151
minimum_pre_commit_version: "2.13.0"
5252
- id: codemeta-description-updated
5353
name: codemeta-description-updated
54-
description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description.
54+
description: make sure `codemeta.json` is in sync with `DESCRIPTION`. It should be run after use-tidy-description
5555
entry: Rscript inst/hooks/exported/codemeta-description-updated.R
5656
language: r
5757
files: '^DESCRIPTION$'
5858
minimum_pre_commit_version: "2.13.0"
5959
- id: spell-check
6060
name: spell-check
61-
description: perform a spell check with spelling::spell_check_files()
61+
description: perform a spell check with `spelling::spell_check_files()`
6262
entry: Rscript inst/hooks/exported/spell-check.R
6363
language: r
6464
exclude: >
@@ -92,24 +92,24 @@
9292
minimum_pre_commit_version: "2.13.0"
9393
- id: deps-in-desc
9494
name: deps-in-desc
95-
description: Check if dependencies that can be parsed from code are in DESCRIPTION.
95+
description: Check if dependencies that can be parsed from code are in `DESCRIPTION`
9696
entry: Rscript inst/hooks/exported/deps-in-desc.R
9797
language: r
9898
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
9999
exclude: 'renv/activate\.R'
100100
minimum_pre_commit_version: "2.13.0"
101101
- id: lintr
102102
name: lintr
103-
description: check if a .R file is lint free (using lintr)
103+
description: check if a `.R` file is lint free (using {lintr})
104104
entry: Rscript inst/hooks/exported/lintr.R
105105
language: r
106106
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
107107
exclude: 'renv/activate\.R'
108108
minimum_pre_commit_version: "2.13.0"
109109
- id: pkgdown-check
110110
name: pkgdown-check
111-
description: check if _pkgdown.yml has the correct entries for references and articles.
112-
entry: Rscript inst/hooks/exported/pkgdown-check.R
113-
language: r
111+
description: check if your {pkgdown} config file has the correct entries for references and articles
112+
entry: inst/hooks/exported/pkgdown-check.R
113+
language: script
114114
minimum_pre_commit_version: "2.13.0"
115115
files: '^man/|_pkgdown\.yml'

tests/testthat/reference-objects/pre-commit-config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ repos:
4949
- id: no-browser-statement
5050
- id: no-debug-statement
5151
- id: deps-in-desc
52-
- id: pkgdown-check
53-
additional_dependencies:
54-
- pkgdown
55-
- mockery
5652
- repo: local
5753
hooks:
5854
- id: consistent-release-tag

vignettes/available-hooks.Rmd

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,18 @@ This hook does not modify input files, but writes to `.Rd` files in
223223
`man/`, `NAMESPACE` and potentially others depending on which roxygen
224224
roclets you specified in `DESCRIPTION`.
225225

226-
227226
**Arguments**
228227

229228
<!-- -->
230229

231230
id: roxygenize
232231
args: [--root=<R package root>]
233232

234-
235233
- Argument `root` specifies the directory in the git repo that
236234
contains the R package. Defaults to `.` since for most R package git
237235
repos, the git and R package root coincide. Added in version
238236
0.3.3.00000.
239237

240-
241-
242238
## `deps-in-desc`
243239

244240
Checks if packages used with the `pkgname::fun()` syntax are listed in
@@ -284,12 +280,11 @@ This hook does modify the file `DESCRIPTION`.
284280
id: use-tidy-description
285281
args: [--root=<R package root>]
286282

287-
288283
- Argument `root` specifies the directory in the git repo that
289284
contains the R package. Defaults to `.` since for most R package git
290285
repos, the git and R package root coincide. Added in version
291286
0.3.3.00000.
292-
287+
293288
## `lintr`
294289

295290
A hook to run `lintr::lint()` to check that R files are lint free.
@@ -325,8 +320,21 @@ This hook does not modify any file.
325320
id: codemeta-description-updated
326321
args: [--root=<R package root>]
327322

328-
329323
- Argument `root` specifies the directory in the git repo that
330324
contains the R package. Defaults to `.` since for most R package git
331325
repos, the git and R package root coincide. Added in version
332326
0.3.3.00000.
327+
328+
329+
## `pkgdown-check`
330+
331+
Check if your {pkgdown} config file (e.g. `_pkgdown.yml` in your root) has the
332+
correct entries for references and articles.
333+
This hook skips the time-consuming parts of building the index and reference and
334+
only performs the validation.
335+
336+
For this check, we rely on the the global R package library and require all
337+
development dependencies of the package to be installed, as well as {pkgdown}
338+
and {mockery}.
339+
340+
This hook does not modify files. Added in version 0.3.2.9003.

0 commit comments

Comments
 (0)