build_site() failing to parse Roxygen rd

Hello! This is a strange error which I cannot get to the bottom of.

I've been building a data access package, using roxygen2 for documentation. For everything thus-far things have gone swimmingly, but today I decided to take on the task of using pkgdown to create the documentation site for the package.

Unfortunately I cannot get pkgdown to build the site from the Rd files for love nor money.

When I get to the "Building function reference" step, it immediately fails out on the first file with the following error:

── Building function reference ──────────────────────────────────────────
Reading man/check_db_status.Rd
Error: 
! in callr subprocess.
Caused by error in `build_reference()`:
! Failed to parse Rd in check_db_status.Rd
ℹ See `$stdout` and `$stderr` for standard output and error.
Type .Last.error to see the more details.

The file it is complaining about looks like this:

#' @title Generate a base request string for the AREAdata database
#' @description This string is used as the basis for all calls to AREAdata.
#' It does not contain any tokens or session ids, and thus can be regenerated at any time.
#'
#' @author Francis Windram
#' @return Returns a string containing the root address of the AREAdata dataset.
#'
#' @examples
#' \dontrun{
#' basereq <- ad_basereq()
#' }
#'
#'
#' @export
#'

ad_basereq <- function() {
  return("https://github.com/pearselab/areadata/raw/main/")
}

It builds fine using document() and the documentation shows up perfectly rendered afterwards with ?ad_basereq()

The full stack trace upon calling .Last.error is as follows:

<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! in callr subprocess.
Caused by error in `build_reference()`:
! Failed to parse Rd in ad_basereq.Rd
ℹ See `$stdout` and `$stderr` for standard output and error.
---
Backtrace:
1. pkgdown::build_site()
2. pkgdown:::build_site_external(pkg = pkg, examples = examples, run_dont_run = run_dont_run, …
3. callr::r(function(..., cli_colors, hyperlinks, pkgdown_internet) { …
4. callr:::get_result(output = out, options)
5. callr:::throw(callr_remote_error(remerr, output), parent = fix_msg(remerr[[3]]))
---
Subprocess backtrace:
 1. pkgdown::build_site(...)
 2. pkgdown:::build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_run, …
 3. pkgdown::build_reference(pkg, lazy = lazy, examples = examples, run_dont_run = run_dont_run, …
 4. pkgdown:::unwrap_purrr_error(purrr::map(topics, build_reference_topic, …
 5. base::withCallingHandlers(code, purrr_error_indexed = function(err) { …
 6. purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, …
 7. purrr:::map_("list", .x, .f, ..., .progress = .progress)
 8. purrr:::with_indexed_errors(i = i, names = names, error_call = .purrr_error_call, …
 9. base::withCallingHandlers(expr, error = function(cnd) { …
10. purrr:::call_with_cleanup(map_impl, environment(), .type, .progress, …
11. local .f(.x[[i]], ...)
12. base::withCallingHandlers(data_reference_topic(topic, pkg, examples_env = examples_env, …
13. pkgdown:::data_reference_topic(topic, pkg, examples_env = examples_env, …
14. pkgdown:::run_examples(tags$tag_examples[[1]], env = if (is.null(examples_env)) NULL else new.env(parent = examples_env), …
15. pkgdown:::highlight_examples(code, topic, env = env)
16. downlit::evaluate_and_highlight(code, fig_save = fig_save_topic, …
17. evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
18. evaluate:::evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, …
19. output_handler$source(source)
20. base::.handleSimpleError(function (err) …
21. local h(simpleError(msg, call))
22. cli::cli_abort("Failed to parse Rd in {.file {topic$file_in}}", …
23. | rlang::abort(message, ..., call = call, use_cli_format = TRUE, …
24. | rlang:::signal_abort(cnd, .file)
25. | base::signalCondition(cnd)
26. (function (cnd) …
27. cli::cli_abort(message, location = i, name = name, parent = cnd, …
28. | rlang::abort(message, ..., call = call, use_cli_format = TRUE, …
29. | rlang:::signal_abort(cnd, .file)
30. | base::signalCondition(cnd)
31. (function (err) …
32. rlang::cnd_signal(err$parent)
33. rlang:::signal_abort(cnd)
34. base::signalCondition(cnd)
35. global (function (e) …

For completeness, the generated ad_basereq.Rd file contains this code:

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ad_basereq.R
\name{ad_basereq}
\alias{ad_basereq}
\title{Generate a base request string for the AREAdata database}
\usage{
ad_basereq()
}
\value{
Returns a string containing the root address of the AREAdata dataset.
}
\description{
This string is used as the basis for all calls to AREAdata.
It does not contain any tokens or session ids, and thus can be regenerated at any time.
}
\examples{
\dontrun{
basereq <- ad_basereq()
}


}
\author{
Francis Windram
}

Finally the packages and versions are:

Package Version
devtools 2.4.5
usethis 2.2.3
roxygen2 7.3.2
pkgdown 2.1.0
downlit 0.4.4
purrr 1.0.2

I listed the last two as functions from those pop out in the stack trace.

It looks like the error is coming out of downlit::evaluate_and_highlight()but I really can't see any particular reason why that might be.

The only other thing I can think of is that build_site() will only run if I unload the dev package prior, using detach("package:ohvbd", unload=TRUE), but I don't particularly see why that would cause this issue.

Anyone seen anything like this? Is there something super obvious that I am missing?

Thank you!

2 Likes

Aha! I found the issue.

It seems like I had an incorrect version of evaluate installed (0.23.0 vs the required 0.24.0) as specified in the suggests section of the DESCRIPTION file of pkgdown 2.1.0.

Upon updating to 0.24.0 the site now builds just fine!

Don't quite know why evaluate did not get updated when installing pkgdown but I guess I already had it installed and it didn't force an update because it was indeed a suggestion for pkgdown rather than a requirement.

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.