Skip to content

Commit 8a5a576

Browse files
committed
Avoid evaluation of code by default
1 parent 6fbbb92 commit 8a5a576

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

inst/hooks/exported/parsable-roxygen.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
"Check whether roxygen comments within files are valid
44
Usage:
5-
parsable-roxygen [--no-eval] <files>...
5+
parsable-roxygen [--eval] <files>...
66
77
Options:
8-
--no-eval Parse, but do not evaluate, file contents - this also suppresses evaluation of `@eval` tags
8+
--eval Evaluate file contents after parsing - this is required if `@eval` tags must be evaluated
99
1010
" -> doc
1111

@@ -17,10 +17,10 @@ out <- lapply(arguments$files, function(path) {
1717
msg <- capture.output(
1818
roxygen2::parse_file(
1919
path,
20-
env = if (isTRUE(arguments$no_eval)) {
21-
NULL
22-
} else {
20+
env = if (isTRUE(arguments$eval)) {
2321
roxygen2::env_file(path)
22+
} else {
23+
NULL
2424
}
2525
),
2626
type = "message"

vignettes/available-hooks.Rmd

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,27 @@ running `roxygen2::parse_file()` on them returns any messages.
146146

147147
This hook does not modify files.
148148

149-
**no eval**
149+
**eval**
150150

151-
The `--no-eval` flag causes `roxygen2::parse_file()` to be run with`env = NULL`.
152-
This means each file will be parsed, but code will not be evaluated - neither
151+
By default, each file will be parsed, but code will not be evaluated - neither
153152
any explicit code in the file, nor any `@eval` tags within roxygen comments.
154-
This can be useful if your files contain anything other than
155-
"simple object declarations" (e.g. [box modules](https://github.com/klmr/box/)
156-
containing `box::use()` calls). When `--no-eval` is missing, this means dependencies
157-
of the code to evaluate must be available for pre-commit. You may list these as
158-
`additional_dependencies:` for the `parsable-roxygen` hook in
153+
154+
If your commentary contains `@eval` tags which you would prefer to evaluate, you
155+
can specify the `--eval` flag, which will cause the file's code to be evaluated
156+
in an environment created by `roxygen2::env_file()`. Note that dependencies of
157+
the code to evaluate must be available for pre-commit. You may list these as
158+
`additional_dependencies:` for the `parsable-roxygen` hook in
159159
`.pre-commit-config.yaml`.
160160

161161
Inline R code within roxygen comments (i.e. within backticks) is **not**
162-
evaluated by this hook, whether or not `--no-eval` is specified. You would need to run the `roxygenize` hook for that.
162+
evaluated by this hook, whether or not `--eval` is specified. You would need
163+
to run the `roxygenize` hook for that.
163164

164165
id: parsable-roxygen
165-
args: [--no-eval]
166+
args: [--eval]
166167

167168
This hook was added in version 0.4.3.9000.
169+
168170
## `no-browser-statement`
169171

170172
Guarantees you that you don't accidentally commit code with a

0 commit comments

Comments
 (0)