Linking to other packages in documentation in roxygen2 in R

前端 未结 4 1185
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 00:32

I am wondering it there exists a method to link to function from other package when I\'m trying to write a documentation for new package using roxygen2

相关标签:
4条回答
  • 2021-02-01 00:50

    In addition to the answer by potockan:
    Some packages document several functions in a single help page. For example, the trim function from Bioconductor package GenomicRanges is documented in intra-range-methods (which is also the name of a help page from other packages such as IRanges).

    To link to the right page with roxygen2 you can use:

    \link[GenomicRanges:intra-range-methods]{trim} 
    

    or

    \code{\link[GenomicRanges:intra-range-methods]{trim}}  
    

    to format the text correctly.

    The help page will only show trim but will link to the right help page.

    0 讨论(0)
  • 2021-02-01 00:55

    From the book R packages:

    • \code{\link{function}} - function in this package.
    • \code{\link[MASS]{abbey}} - function in another package.
    • \link[=dest]{name} - link to dest, but show name.
    • \code{\link[MASS:abbey]{name}} - link to function in another package, but show name.
    • \linkS4class{abc} - link to an S4 class.

    Note: In the fourth option there is only one colon, not two as one is used to when referencing functions from other packages in code.

    0 讨论(0)
  • 2021-02-01 00:58

    Roxygen2 now also supports documentation written in markdown.

    The markdown syntax is for the link is [foo::bar()] which is translated to \code{\link[foo:bar]{foo::bar()}} in the generated .Rd file. (See Roxygen2 vignette.)

    Note that you may need to specifically turn on Markdown support by writing Roxygen: list(markdown = TRUE) in your DESCRIPTION file, or by putting an #' @md comment if you want to enable markdown only for a specific man page. This is also explained at the very top of the linked vignette. (Thanks to @Tjebo for the comment)

    Note that there are two colons in the markdown version whereas there is only one colon in the Rd version.

    0 讨论(0)
  • 2021-02-01 01:04

    You have to type \link[pkg]{function} e.g. \link[stringi]{stri_c}

    0 讨论(0)
提交回复
热议问题