Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rd2html doesn't handle all links correctly #163

Open
nealrichardson opened this issue Sep 12, 2022 · 0 comments
Open

rd2html doesn't handle all links correctly #163

nealrichardson opened this issue Sep 12, 2022 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@nealrichardson
Copy link

I'm trying to add documentation to arrow that links to all of the functions in other R packages that are supported in arrow queries: apache/arrow#14014

I generate roxygen2 markdown with links to the original functions, like this: https://github.com/apache/arrow/pull/14014/files#diff-8e2b0f2944713c80b312477fd9e90bf65071251dd380b84940127cc167c7b55aR150

This turns into Rd: https://github.com/apache/arrow/pull/14014/files#diff-95f5533b9053bd8ef110bf03a4e1e97f7631a42639ed1603e191856145ac1b7aR136

But when I render the pkgdown site, some of those links don't convert to hrefs. The ones that don't are:

  • base:MathFun
  • base:Round
  • base:Log
  • base:Extremes
  • lubridate:date_utils
  • lubridate:posix_utils

Reprex:

> pkgdown::rd2html("\\link[base:Extremes]{something}")
[1] "something"

The documentation URLs do in fact exist, e.g. https://rdrr.io/r/base/Round.html and https://lubridate.tidyverse.org/reference/date_utils.html.

What they all have in common is that the topic name does not match the object or function being documented. But there are other topics where that is also true but the linking works:

> pkgdown::rd2html("\\link[base:Extract]{something}")
[1] "<a href='https://rdrr.io/r/base/Extract.html'>something</a>"

Interestingly, though, ?Extract does successfully open the help page, but ?Log or ?Extremes etc. do not.

I poked around in the internals at where the lookup happens and noticed this:

> x <- downlit:::topic_index("base")
# This case works: topic is in the names
> "Extract" %in% names(x)
[1] TRUE
> "Extract" %in% x
[1] TRUE
# This does not work: topic not in names
> "Extremes" %in% names(x)
[1] FALSE
> "Extremes" %in% x
[1] TRUE

Digging further, I noticed that you do get a link if the Rd points at the function name and not the topic for these:

> pkgdown::rd2html("\\link[base:max]{something}")
[1] "<a href='https://rdrr.io/r/base/Extremes.html'>something</a>"

So maybe this is a roxygen2 issue, or a downlit issue.

@hadley hadley transferred this issue from r-lib/pkgdown Oct 20, 2022
@hadley hadley added the bug an unexpected problem or unintended behavior label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants