你如何使用roxygen2逃脱“}”?

时间:2016-05-21 08:23:38

标签: r roxygen2

我正在使用roxygen2使用@example记录函数。

该示例包含一个包含}符号的字符串。

#' ...
#' @examples
#' \dontrun{
#' ## polyline joining the capital cities of Australian states
#' pl <- "nnseFmpzsZgalNytrXetrG}krKsaif@kivIccvzAvvqfClp~uBlymzA~ocQ}_}iCthxo@srst@"
#'
#' df_polyline <- decodepl(pl)
#' }
#' ...

构建时,示例的文档是

enter image description here

第一个}之后的所有内容都被删除了。

如何转义}以便它包含在示例中的字符串中?

我尝试了反斜杠\{ / \\{但没有运气。

更新 - 2016年9月1日

Hadley的问题official response

  

修复这个问题非常困难(据我所知,它需要编写一个相当复杂的Rd解析器),而且这种情况很少发生,所以现实情况下,我的待办事项清单永远无法修复它

1 个答案:

答案 0 :(得分:5)

TLDR:长期修复:文件an issue

你很幸运&#34;这是因为你有足够的func(db *MySQL) Insert(query string, values ...interface{}) (int64, error) { /** * TODO: find a way to implement the args slice * to implement this remember that behind Exec(_, values) there is a [] interface{} element * which will decompose this element inside. so by passing a values ...interface{} function won't work * as the values ...interface{} has another data type structure in the end */ // if res, err := db.dbConn.Exec(query, values); err != nil { return -1, err } else { if lastId, err := res.LastInsertId(); err != nil { return -1, err } else { return lastId, nil } } } 来解决一些Rd安装错误。

我甚至尝试使用}并放置代码(使用@example inst/examples/ex.r包装器,因为它在那里受支持)并且该方法也发生了同样的事情,因为相同的roxygen解析/转换代码似乎是在那里玩。

  • 短期修复#1:手动编辑生成的\dontrun{}文件,为每个Rd执行单\}。为了做到这一点你不会意外覆盖,生成一次,然后进行修复,然后对该功能进行去氧化,直到修复为止。

  • SHORT TERM FIX#2:对于那段代码,字符串赋值可以在}块之外发生(这实际上是导致这种情况的原因)。将它移出,你可以继续进行氧化。

  • LONG TERM FIX:向上述网址提出问题。

相关问题