-
Notifications
You must be signed in to change notification settings - Fork 238
Description
CRAN (and Bioconductor) wish that all cross-references were anchored (And testing via a new environmental variable).
I was checking the current state of CRAN's cross references and I found out that some of my own cross-references were missing the anchor (See for example the source and the output). This happens when they are generated with #' @family group.
library(roxygen2)
roc_proc_text(rd_roclet(), "
#' Title1
#'
#' See [bar()]
#' @family check
#' @md
foo <- function() {}
#' Title2
#'
#' @family check
bar <- function() {}
"
)
#> $foo.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{foo}
#> \alias{foo}
#> \title{Title1}
#> \usage{
#> foo()
#> }
#> \description{
#> See \code{\link[=bar]{bar()}}
#> }
#> \seealso{
#> Other check:
#> \code{\link{bar}()}
#> }
#> \concept{check}
#>
#> $bar.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{bar}
#> \alias{bar}
#> \title{Title2}
#> \usage{
#> bar()
#> }
#> \description{
#> Title2
#> }
#> \seealso{
#> Other check:
#> \code{\link{foo}()}
#> }
#> \concept{check}Created on 2024-08-27 with reprex v2.1.1
I think the root cause is that it is handled different than in other cases where links are created (as in markdown it works well), see:
Lines 56 to 60 in 9652d15
| by_file <- map_chr(other_aliases[order_c(other_aliases_order)], function(x) { | |
| obj <- find_object(x[1], env) | |
| suffix <- if (is.function(obj$value)) "()" else "" | |
| paste0("\\code{\\link{", escape(x[1]), "}", suffix, "}") | |
| }) |
Different from:
Lines 36 to 41 in 9652d15
| links <- paste0( | |
| "\\code{\\link[", pkg$pkg, | |
| ifelse(pkg$file == pkg$fun, "", paste0(":", pkg$file)), | |
| "]{", escape(pkg$fun), "}}", | |
| collapse = ", ") | |
| paste0("\\item{", pkg$pkg[[1]], "}{", links, "}") |
I'm not sure how it handles multiple topics in the same file after #1109 or how to find the right topic on the rd-family.R, but fixing this will eventually help solve a note from packages that use roxygen2.