16 Centralized Documentation Scheme

🚧 Under Construction 🚧

16.1 The main idea

16.2 The implementation

16.2.1 Source Rmd files

Pkg Info specifically build for a package, here is a generic example:

Download pkg_info.Rmd
---
title: "Pkg Info (source documentation file)"
output: html_document
---

# Pkg info setup
```{r, eval = T, include = TRUE, results='asis'}
PKG = 'bdDwC' # Package name
WAI = c('readme', 'website', 'user_guide', 'dev_guide') # Setup 'Where Am I?' (for conditioning sections of a code chunk)
H = 1 # Setup top header level within a code chunk
```

# Pkg info chunk 1
Conditional sections: **readme** | **website**

```{r, label='try-test1', echo=FALSE, eval=TRUE, results='asis'}
cat(strrep('#', H)) #> H1
cat(' Top level header: Something something...\n\n')

cat(strrep('#', H+1))
cat(' Secondery header: Looking good!\n\n')

cat(strrep('#', H+2))
cat(' Third-level header: Nice...\n\n')

if('readme' %in% WAI){
cat('
  *Only README can read me*... \n\n
  bla bla bla `fun()` bla bla bla
  ')
}
#> Show Code in block:
cat('\n\n```r\n')
cat('utils::packageDescription("',PKG,'")$Title \n', sep = "")
cat('utils::packageDescription(',PKG,')$Description \n', sep = '"')
cat('```\n\n')

#> Conditional section:
if('website' %in% WAI){
  cat('
  Some more text for the website and...\n
  ')
  
  cat('\n![](https://media.giphy.com/media/2HONNTJbRhzKE/giphy.gif)\n\n')
}

cat(strrep('#', H+2))
cat(' Package title \n\n')
#> Show Code output:
cat('\n\n', utils::packageDescription(PKG)$Title)
```

# Pkg info chunk 2
```{r, label='try-test2', echo=FALSE, eval=TRUE, results='asis'}
cat(strrep('#', H+2))
cat(' Package description \n\n')
cat(utils::packageDescription(PKG)$Description)

cat('\n\n')
cat(strrep('#', H))
cat(' Rmd file labels: \n\n')
cat(knitr::all_labels())
```

Rmd templates

16.2.2 Client Rmd files:

  • Pkg README.Rmd
  • Pkg Rmd file in the user guide
  • Pkg Rmd file in the dev guide
  • Pkg Rmd file in the website

A README example:

---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# Pkg Name

<!-- Reading pkg_info.Rmd + setup WAI -->
```{r setup-pkg-info, eval = T, echo=F, include = FALSE}
knitr::knit_child('pkg_info.Rmd')
PKG = 'bdchecks' # Package name
WAI = 'readme' # Setup 'Where Am I?' (for conditioning part of a code chunk)
# 'readme', 'website', 'user_guide', 'dev_guide'
```

## Chunk 1
```{r eval = T, include = FALSE}
H = 3 # Setup top header level within the following code chunk
```
```{r ref.label='try-test1', echo = F, eval = T, results='asis'}
```

## Chunk 2
```{r eval = T, include = FALSE}
H = 4 # Setup top header level within the following code chunk
```
```{r ref.label='try-test2', echo = F, eval = T, results='asis'}
```

16.3 Centralized reposotoiers

16.3.1 bdtemplates

16.3.1.1 CI templates

16.3.1.2 .gitignore & .Rbuildignore

16.3.1.3 Rmd templates

  • Pkg info
  • Pkg badges
  • Pkg CI table

16.3.2 Graphics

For more details see bdgraphics (under the Graphics section).