You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rd2roxygen() throws the error below if the function name contains a regex metacharacter (e.g. "[" for a subset method).
##------ Sun Mar 10 10:10:18 2024 ------##
parsed: subset.xts.Rd
looking for the object '[.xts' in:
Error in grep(sprintf(pattern, gsub("\\.", "\\\\.", fname)), (r.Rd = readLines(r, :
invalid regular expression '^[[:space:]]*(`|"|'|)([\.xts)(\1)[[:space:]]*(<-|=)', reason 'Missing ')''
In addition: Warning message:
In grep(sprintf(pattern, gsub("\\.", "\\\\.", fname)), (r.Rd = readLines(r, :
TRE pattern compilation error 'Missing ')''
You already escape any "." in the function name. Here's a patch that escapes all the regular expression metacharacters. This worked for me. Let me know if you'd like a PR.
diff --git a/R/rd2roxygen.R b/R/rd2roxygen.R
index 40ba00f..f5ab07d 100644
--- a/R/rd2roxygen.R+++ b/R/rd2roxygen.R@@ -207,7 +207,7 @@ Rd2roxygen = function(pkg, nomatch, usage = FALSE) {
for (i in tryf) {
r = file.path(R.dir, i)
idx = grep(sprintf('^[[:space:]]*(`|"|\'|)(%s)(\\1)[[:space:]]*(<-|=)',
- gsub('\\.', '\\\\.', fname)),+ gsub('([][{}()+*^$|?.])', '\\\\\\1', fname)),
(r.Rd = readLines(r, warn = FALSE)))
message(' ', i, ': ', appendLF = FALSE)
message(ifelse(length(idx), paste('line', idx), 'not found'))
The text was updated successfully, but these errors were encountered:
Rd2roxygen()
throws the error below if the function name contains a regex metacharacter (e.g. "[" for a subset method).You already escape any "." in the function name. Here's a patch that escapes all the regular expression metacharacters. This worked for me. Let me know if you'd like a PR.
The text was updated successfully, but these errors were encountered: