knitr::opts_chunk$set(
  echo = TRUE,
  message = FALSE,
  warning = FALSE,
  collapse = TRUE,
  comment = "#>"
)

This document shows how to use pkgdoc to organize, search, and link documentation from multiple R packages -- all in one page. pkgdoc complements existing tools. It is similar to RDocumentation but not limited to packages published on CRAN. It is also similar to the Reference section of pkgdown websites but is not limited to a single package.

pkgdoc may be used to centralize R packages developed during Chicago R Unconference. Suppose that during chirunconf Emily Riederer and Alex Hayes developed the packages projmgr and formulize. This document shows some ways you could use pkgdoc to show Emily's and Alex's work.

library(dplyr)
library(projmgr)
library(formulize)

With pkgdoc + DT::datatable() you can create searchable widgets. For example, you can show the packages by different authors (or groups).

A package by Emily

# Organization that serves the websites all all packages
# (Not really -- this is just a toy example)
chirunconf <- "https://maurolepore.github.io/"

pkgdoc::reference_package("projmgr", url = chirunconf) %>% 
  DT::datatable(
    escape = FALSE,
    rownames = NULL,
    options = list(search = list(search = "issues"))
  )

A package by Alex

pkgdoc::reference_package("formulize", url = chirunconf) %>% 
  DT::datatable(
    escape = FALSE,
    rownames = NULL,
    options = list(search = list(search = ""))
  )

With pkgdoc + knitr::kable() you can create a static table with clickable links. Here for example we group features across multiple packages by concept (create concepts with the tag #' @family)

#' @family chirunconf

(The concept 'chirunconf' was created for this demo only.)

pkgdoc::reference_concept("chirunconf", url = chirunconf) %>% 
  knitr::kable()

With the kableExtra package we can tweak the output like the 'Reference' section of a pkgdown website.

#' @family chirunconf

nice_kable <- function(x) {
  x %>% 
    select(-package, -concept) %>% 
    unique() %>%
    knitr::kable(
      x, 
      format = "html",
      col.names = NULL,
      escape = FALSE
    ) %>%
    kableExtra::column_spec(1, bold = TRUE) %>% 
    kableExtra::column_spec(2, width = "20em")
}

pkgdoc::reference_concept("chirunconf", url = chirunconf) %>% 
  nice_kable()


maurolepore/pkgdoc documentation built on Nov. 4, 2024, 6:56 a.m.