-
Notifications
You must be signed in to change notification settings - Fork 235
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
UTF-8 in usage being converted to symbols again #748
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Here is a minimal example. This function converts a numeric vector to character and replaces
When I document this in roxygen, the
When documenting, roxygen should render the text in usage directly as-is, without any interpretation. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks, that's helpful. That allowed me to create this minimal reprex: library(roxygen2)
roc_proc_text(rd_roclet(), "
#' Correct compilation with explicit usage section
#' @usage format_num(neg.sign = '\\u2212')
works <- function(neg.sign = '\\u2212') {}
")[[1]]$get_field("usage")
#> \usage{
#> format_num(neg.sign = '\u2212')
#> }
roc_proc_text(rd_roclet(), "
#' Incorrect compilation if usage is determined from the function call
#' roxygen2 renders the actual unicode characters in the documentation
fails_1 <- function(neg.sign = '\\u2212') {}
")[[1]]$get_field("usage")
#> \usage{
#> fails_1(neg.sign = "−")
#> }
roc_proc_text(rd_roclet(), "
#' Also incorrect compilation if usage is determined from the function call with double escapes
#' roxygen2 renders both slashes in the documentation and the function behavior changes
fails_2 <- function(neg.sign = '\\\\u2212') {}
")[[1]]$get_field("usage")
#> \usage{
#> fails_2(neg.sign = "\\\\u2212")
#> } Created on 2019-08-22 by the reprex package (v0.3.0) |
This is going to be hard (impossible?) to fix, because roxygen currently looks at the abstract syntax tree where that distinction is lost: f1 <- quote(function(neg.sign = '\u2212') {})
f1
#> function(neg.sign = "−") {
#> } Created on 2019-08-22 by the reprex package (v0.3.0) |
If it can’t be fixed, maybe a note about needing an explicit usage section when using unicode characters in function arguments should be added? |
I can't recreate this R CMD check failure on any platform: https://dev.azure.com/r-lib/roxygen2/_build/results?buildId=194. My documentation at b741e0e |
Some UTF-8 characters, such as
\u2212
and\u221e
are being exported incorrectly in the usage section. On Windows, these are being converted to (-
and8
, respectively). On Mac, they are being converted to their unicode symbols, rather than remaining as escaped sequences.I thought this would have been fixed in #649, but apparently not.
Edit: Added details that it is failing in a different way on Mac.
Reprex:
The text was updated successfully, but these errors were encountered: