Open hadley opened 2 years ago
Yeah. Btw. it would be great to have source references in roxygen2 (and an api for them?), then we could jump to the source instead of the docs here.
Another approach would be to make an url checker roclet? But that's probably too slow to run every time, so we'd need some caching.
I think having proper source refs in roxygen2 would benefit many use cases. Nevertheless, we can still implement this, and have a link to the .Rd
file for links in manual pages.
@gaborcsardi there are basic srcrefs in the roxygen2 data structure already (I don't bother storing the columns since they're most in the same place), but I don't see how we could serialize to .Rd
so that urlchecker could use them.
Like in C:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
% srcref R/cli.c:599
\name{cli_alert}
% srcref R/cli.c:599
\alias{cli_alert}
\alias{cli_alert_success}
\alias{cli_alert_danger}
\alias{cli_alert_warning}
\alias{cli_alert_info}
% srcref R/cli.c:599
\title{CLI alerts}
%srcref R/cli.c:603
\details{
...
}
...
So before every tag we would output where the tag was in the R file.
Of course this could be tricky for some tags, or even impossible, but then we'll just have the file name for those, or even NA.
We could just start with \description
and \details
, that would cover a lot of use cases, I think.
I does make the .Rd
file less readable, so we should allow opting out.
That feels like a lot of work for relatively little gain since only urlchecker would benefit from it, and it would also have to gain a bunch of new parsing code in order to make use of it.
Aren't you describing essentially the same method here? https://github.com/r-lib/roxygen2/issues/1334#issuecomment-1101403510
So you can immediately jump to the problem.