Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quote aliases? #24

Closed
yihui opened this issue Jul 28, 2011 · 3 comments
Closed

quote aliases? #24

yihui opened this issue Jul 28, 2011 · 3 comments
Labels

Comments

@yihui
Copy link
Contributor

@yihui yihui commented Jul 28, 2011

it seems that aliases are quoted when they contain special characters; I looked at the the documentation of %in%, its alias was \%in\% (no quotes but % was escaped). The alias for substr<- is not quoted either.

@hadley
Copy link
Member

@hadley hadley commented Jul 28, 2011

Does that cause any problems for you? If it should be quoted, R CMD check should be warning about it.

@yihui
Copy link
Contributor Author

@yihui yihui commented Jul 28, 2011

I mean it should NOT be quoted, but currently roxygen2 does quote it.

library(roxygen2)
roc <- rd_roclet()
out <- roc_proc_text(roc, "
    #' @name a
    #' @aliases \\%a\\%
    NULL")[[1]]
roxygen2:::get_tag(out, 'alias')$values

The output is:

> roxygen2:::get_tag(out, 'alias')$values
[1] "a"           "\"\\%a\\%\""

@unDocUMeantIt
Copy link

@unDocUMeantIt unDocUMeantIt commented Sep 21, 2011

here's a fix, in two patches:

patch1

--- roclet-namespace.R.orig     2011-08-29 23:52:59.648650390 +0200
+++ roclet-namespace.R  2011-09-01 19:25:54.228446954 +0200
@@ -182,9 +182,15 @@
   unlist(lapply(matches, f, tag = tag, all = partitum), use.names = FALSE)
 }

-words <- function(x) {
-  quote_if_needed(str_split(str_trim(x), "\\s+")[[1]])
+words <- function(x, quote=TRUE) {
+  x.trimmed <- str_split(str_trim(x), "\\s+")[[1]]
+  if(isTRUE(quote)){
+    return(quote_if_needed(x.trimmed))
+  } else {
+    return(x.trimmed)
+  }
 }
+
 is.syntactic <- function(x) make.names(x) == x
 has.quotes <- function(x) str_detect(x, "'|\"")
 quote_if_needed <- function(x) {

patch2

--- roclet-rd.R.orig    2011-07-28 20:59:24.000000000 +0200
+++ roclet-rd.R 2011-09-01 19:27:26.976672899 +0200
@@ -333,7 +333,7 @@
   add_tag(rd, process_description(partitum, base_path))

   add_tag(rd, process_had_tag(partitum, 'aliases', function(tag, param) {
-      new_tag('alias', words(param))
+      new_tag('alias', words(param, quote=FALSE))
     }))
   add_tag(rd, process.usage(partitum))
   add_tag(rd, process.arguments(partitum))

@hadley hadley closed this in 3e1f0e1 Oct 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants