r-lib / downlit

Syntax Highlighting and Automatic Linking
https://downlit.r-lib.org
Other
89 stars 22 forks source link

Feature request: keep track of autolinks #161

Closed larmarange closed 11 months ago

larmarange commented 1 year ago

Would it be a way to keep a track of identified autolinks, for example by saving a tibble indicating the list of links (name, link, type ie function package or vignette, the source file, etc.)?

Such functionality could be useful to generate an index of functions or an index of packages in books created with bookdownor quarto.

See https://github.com/quarto-dev/quarto-cli/discussions/2747

GregorDeCillia commented 1 year ago

I second that feature. This would also make it possible to auto-generate tooltips as suggested in https://github.com/r-lib/downlit/issues/18 by using fairly straightforward post processing of the generated articles.

read autolink tibble -> query Rd documentation -> render tooltips -> patch articles/*.html

I've played around with auto-generating tooltips a few weeks ago and found that this would be a reasonable representation of the autolink tibble for this usecase

type reference url
package downlit https://downlit.r-lib.org/
article cli::progress https://cli.r-lib.org/articles/progress.html
manpage downlit::autolink https://downlit.r-lib.org/reference/autolink.html

The post-processing would then be something like this

readRDS("pkgdown/built/autolinks.rds") %>%
  add_tooltips(join_by = c("type", "reference")) %>%
  patch_articles("articles/*.html", join_by = "url")
hadley commented 11 months ago

This sounds like an interesting idea, but I think it's out of scope for downlit.