r-lib / pkgdown

Generate static html documentation for an R package
https://pkgdown.r-lib.org/
Other
718 stars 336 forks source link

make it more clear how to cross link to other pkgdown site #946

Closed dongzhuoer closed 5 years ago

dongzhuoer commented 5 years ago

I'm very happy to see that link to other package can be customized, rather than just use www.rdocumentation.org .

However, the document is too simple, I have spent a while finding how to achieve this.

dongzhuoer commented 5 years ago

For example, let's look at a sentence in "Programming with dplyr" vignette of dplyr

If this function is in a package, using .data also prevents R CMD check from giving a NOTE about undefined global variables (provided that you've also imported rlang::.data with @importFrom rlang .data).

rlang::.data is linked to https://rlang.r-lib.org/reference/tidyeval-data.html

This is achieved in three steps.

dongzhuoer commented 5 years ago

First, DESCRIPTION of rlang contains the following line:

URL: http://rlang.tidyverse.org, https://github.com/r-lib/rlang
dongzhuoer commented 5 years ago

Then pkgdown tries each url, and finds that https://rlang.r-lib.org/pkgdown.yml does exist:

pandoc: '2.2'
pkgdown: 1.3.0.9000
pkgdown_sha: fa9b7502e80401db4b410086b0a8f6ab444f0c66
articles: []
urls:
  reference: https://rlang.r-lib.org/reference
  article: https://rlang.r-lib.org/articles
dongzhuoer commented 5 years ago

Finally, https://rlang.r-lib.org/reference is used for creating links to functions in rlang

dongzhuoer commented 5 years ago

In summary, the user need to do two things:

  1. include pkgdown website url in the package DESCRIPTION file's URL field
  2. specify url field of pkgdown.yml as introduced in pkgdown documentation
hadley commented 5 years ago

I think this should probably be the start of a new vignette on linking.