[英]How do you escape “}” using roxygen2?
I'm documenting a function using roxygen2
with an @example
. 我正在使用
roxygen2
的@example
来记录函数。
The example has a string that contains a }
symbol. 该示例包含一个包含
}
符号的字符串。
#' ...
#' @examples
#' \dontrun{
#' ## polyline joining the capital cities of Australian states
#' pl <- "nnseFmpzsZgalNytrXetrG}krKsaif@kivIccvzAvvqfClp~uBlymzA~ocQ}_}iCthxo@srst@"
#'
#' df_polyline <- decodepl(pl)
#' }
#' ...
When built, the documentation for the example is 构建时,示例的文档是
Where everything after the first }
is cutt off. 其中,第一之后的所有内容
}
是CUTT关闭。
How do I escape the }
so that it is included in the string in the example? 如何逃避
}
以便它包含在示例中的字符串中?
I've tried a backslash \\{
/ \\\\{
with no luck. 我试过反斜杠
\\{
/ \\\\{
没有运气。
The official response to my issue from Hadley 哈德利对我的问题的官方回应
Fixing this is quite difficult (as far as I can it will require writing a considerably more complicated Rd parser), and it's a rare occurrence, so realistically this is never going to get high up enough on my to do list to fix it.
解决这个问题非常困难(据我所知,它需要编写一个相当复杂的Rd解析器),而且这种情况很少发生,所以现实情况下,我的待办事项清单永远不会达到很高的水平。
TLDR: longer term fix: file an issue . TLDR:长期修复:提出问题 。
You "got lucky" this built since you had just enough }
's to get past some Rd installation errors. 你因为你有刚好够“很幸运”这个内置
}
的让过去一些路安装错误。
I even tried using @example inst/examples/ex.r
and putting the code (with the \\dontrun{}
wrapper since it is supported there) and the same thing happens with that method since the same roxygen parsing/translating code seems to be in play there too. 我甚至尝试使用
@example inst/examples/ex.r
并放置代码(使用\\dontrun{}
包装器,因为它支持那里)和同样的事情发生在那个方法,因为相同的roxygen解析/翻译代码似乎是在那里玩。
SHORT TERM FIX #1: manually edit the generated Rd
file to do the single \\}
for each of the }
. SHORT TERM FIX#1:手动编辑生成的
Rd
文件,为每个\\}
执行单个\\}
}
。 To make this something you don't accidentally overwrite, generate it once, do the fix then de-roxygenize that function until there's a fix. 为了使你不会意外地覆盖它,生成一次,然后进行修复,然后对该功能进行除氧,直到修复为止。
SHORT TERM FIX #2: for that bit of code, the string assignment can happen outside of the \\dontrun{}
block (which is really what's causing this). SHORT TERM FIX#2:对于那段代码,字符串赋值可以在
\\dontrun{}
块之外发生(这正是造成这种情况的原因)。 Move it out and you can continue with roxygenizing. 将它移出,你可以继续进行氧化。
LONG TERM FIX: file an issue to the above URL. 长期修复:向上述网址提出问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.