【问题标题】:pkgdown fails parsing Rd files when examples are added添加示例时 pkgdown 无法解析 Rd 文件
【发布时间】:2021-06-22 16:15:47
【问题描述】:

由于某种原因,pkgdown 无法解析我的包中的 .Rd 文件之一。当我使用@examples 标记或@example inst/example/add.R 替代方法将示例添加到roxygen2 文档时,我发现它失败了。我将我的函数最小化为两个参数,以使其更“可重复”并且仍然得到相同的错误。请在下面找到错误消息、使用该devtools::document() 生成的 .Rd 文件以及该函数的 roxygen2 文档。如您所见,我正在使用一个非常简单的示例,应该可以毫无问题地运行...还要说的是,当我运行devtools::check() 时,我的所有示例都通过了,所以我不明白为什么pkgdown 失败了.

非常感谢您的帮助。

最好的,

错误信息

Reading 'man/merge.Rd'
Error : Failed to parse Rd in merge.Rd
i unused argument (output_handler = evaluate::new_output_handler(value = pkgdown_print))
Error: callr subprocess failed: Failed to parse Rd in merge.Rd
i unused argument (output_handler = evaluate::new_output_handler(value = pkgdown_print))

.Rd 文件

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/merge.R
\name{merge}
\alias{merge}
\title{Merge two tables}
\usage{
merge(x, y)
}
\arguments{
\item{x}{data frame: referred to \emph{left} in R terminology, or \emph{master} in
Stata terminology.}

\item{y}{data frame: referred to \emph{right} in R terminology, or \emph{using} in
Stata terminology.}
}
\value{
a data.table joining x and y.
}
\description{
This is the main and, basically, the only function in joyn.
}
\examples{
x <- c(1, 2)
}

roxygen2 文档

#' Merge two tables
#'
#' This is the main and, basically, the only function in joyn.
#'
#' @param x data frame: referred to *left* in R terminology, or *master* in
#'   Stata terminology.
#' @param y data frame: referred to *right* in R terminology, or *using* in
#'   Stata terminology.
#' @return a data.table joining x and y.
#' @export
#' @import data.table
#'
#' @examples
#' x <- c(1, 2)

【问题讨论】:

  • 看起来您使用的是来自 Github 的 pkgdown 的开发版本,而不是其依赖项的相应版本。除非您真的需要开发版本,否则请使用 CRAN 版本。
  • 太棒了,非常感谢。我使用了 CRAN 版本,它工作正常。但是,尽管我有一个工作页面,但它仍然会给出一些奇怪的消息,说有些地方不对劲。在任何情况下。非常感谢!

标签: r devtools roxygen2 pkgdown


【解决方案1】:

此错误来自downlit::evaluate_and_highlight(很遗憾没有在输出中报告),可以通过安装downlit的开发版来修复:

library(devtools)
install_github('r-lib/downlit')

只有当你使用来自 pkgdown 的 git 版本时才有意义,稳定版 pkgdown(版本 1.6.1)与稳定版 downlit 运行得很好。当然,任何包的开发版本都可能随时中断,但除非它没有,否则没关系。

【讨论】:

    猜你喜欢
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-27
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    相关资源
    最近更新 更多