0

The pkgdown autolinking vignette goes into some detail about how the package creates links in websites, both to other pages within the site itself and to documentation for other packages. I would like to know if there is an easy means of replicating this. E.g. is there a function that can be run within when building a site, something like generate_pkgdown_link("my_function") that will create such a link. This would be very useful, e.g. for creating HTML flow-charts etc that describe the package structure.

Note that it is relatively straightforward to look at an automatically generated link and produce something that looks the same. The main difficulty is in generating a link that works regardless of where the site is hosted - e.g. whether it be hosted locally or on an RStudio Connect server.

wurli
  • 2,314
  • 10
  • 17

1 Answers1

0

For anyone trying to answer the same question, there is a documented solution which I somehow missed when writing this question - use downlit::downlit_html_no(), e.g.

node <- xml2::read_xml("<p><code>base::t()</code></p>")
node
#> {xml_document}
#> <p>
#> [1] <code>base::t()</code>

# node is modified in place
downlit::downlit_html_node(node)
node
#> {xml_document}
#> <p>
#> [1] <code>\n  <a href="https://rdrr.io/r/base/t.html">base::t()</a>\n</code>

Created on 2021-04-09 by the reprex package (v2.0.0)

wurli
  • 2,314
  • 10
  • 17