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

Resolve markdown links to external packages #1633

Merged
merged 21 commits into from
Aug 1, 2024
Merged

Conversation

gaborcsardi
Copy link
Member

@gaborcsardi gaborcsardi commented Jul 9, 2024

  • Anchor links to base packages as well.
  • Do not anchor base packages.
  • Tests.
  • News.
  • Docs.
  • Cache dependency info.
  • Resolve re-exported functions.

Closes #1612.

Copy link
Member

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me in duckdb, thank you for the very quick fix!

R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
Copy link
Member

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super-minor stuff.

Next level: automatically add these qualifications with @inheritParams -- I have this in DBI, and I see how niche this probably is.

R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown-link.R Show resolved Hide resolved
gaborcsardi and others added 6 commits July 10, 2024 00:10
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com>
Should not be needed. But we still error for a name
clash between a base and non-base package.
So we don't parse DESCRIPTION for every link.
@gaborcsardi gaborcsardi requested review from hadley and jeroen July 10, 2024 08:45
@gaborcsardi
Copy link
Member Author

@krlmlr

Next level: automatically add these qualifications with @inheritParams -- I have this in DBI, and I see how niche this probably is.

You mean adjusting the link target packages in Rd from @inheritParams? Doesn't that work already?

@krlmlr
Copy link
Member

krlmlr commented Jul 10, 2024

This might work, I have only tried with \linkS4class{} where it doesn't.

@krlmlr
Copy link
Member

krlmlr commented Jul 10, 2024

It changes things in tibble, trying in CI/CD now: https://github.com/tidyverse/tibble/actions/runs/9871752503

Thank you very much!

NEWS.md Outdated Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown.R Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
@krlmlr
Copy link
Member

krlmlr commented Jul 10, 2024

Works for tibble, green builds again!

@gaborcsardi
Copy link
Member Author

So, I have been using this for a bit, and it does not work very well when you are adding new functions that are not documented yet, or refactoring a package and renaming functions. The errors don't allow the changes to propagate properly.

One solution would be to have a warning instead of an error. This is easy to implement. The caveat is that you might end up with incorrect links, unless you run document() twice.

Another solution is to delay the resolution of the link target packages until the (new) topic of the documented package are known. This might be difficult to implement with how roxygen2 works currently. We would essentially need to do the final link fixup in the generated Rd docs.

@krlmlr
Copy link
Member

krlmlr commented Jul 14, 2024

To better understand this: the problem is that this PR works worse than the main branch if documentation is added to a function that didn't have documentation before? What errors are you seeing?

@hadley
Copy link
Member

hadley commented Jul 14, 2024

I think switching to warnings are probably a good start. Can we assume that if we can't find the topic it's in the current package?

@gaborcsardi
Copy link
Member Author

Good idea. R CMD check will catch the real errors anyway.

@gaborcsardi
Copy link
Member Author

@krlmlr Yeah, when you are refactoring or developing, you might have a state where you are referring to a function that is not documented. E.g. if you simply rename a function that you are cross-linking from a manual page. With this PR the package of the renamed function cannot be resolved, which causes an error, and the manual pages are not updated. So you are stuck in this state.

Otherwise renaming functions is impossible. (Well, very
cumbersome.) Cf. #1633 (comment)
@gaborcsardi
Copy link
Member Author

@hadley OK, I turned them into warnings. Can you please take another look?

R/markdown-link.R Outdated Show resolved Hide resolved
R/markdown-link.R Outdated Show resolved Hide resolved
Also need an early return from name clashes. Now that we
don't error we need to return explicitly.
@jeroen
Copy link
Member

jeroen commented Jul 21, 2024

Great, this worked for all cases I tried!

@hadley hadley merged commit b94b42f into main Aug 1, 2024
13 checks passed
@hadley hadley deleted the feature/anchored-links branch August 1, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always resolve to "anchored" Rd xrefs
4 participants