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

Use cli::style_hyperlink() #23

Open
hadley opened this issue Apr 24, 2022 · 7 comments
Open

Use cli::style_hyperlink() #23

hadley opened this issue Apr 24, 2022 · 7 comments
Labels
feature a feature request or enhancement

Comments

@hadley
Copy link
Member

hadley commented Apr 24, 2022

So you can immediately jump to the problem.

@gaborcsardi
Copy link
Member

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.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Apr 24, 2022
@hadley
Copy link
Member Author

hadley commented Apr 25, 2022

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.

@gaborcsardi
Copy link
Member

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.

@hadley
Copy link
Member Author

hadley commented Apr 25, 2022

@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.

@gaborcsardi
Copy link
Member

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.

@hadley
Copy link
Member Author

hadley commented Apr 25, 2022

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.

@gaborcsardi
Copy link
Member

Aren't you describing essentially the same method here? r-lib/roxygen2#1334 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants