Skip to content

Commit

Permalink
Update to modern vignette style
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Oct 28, 2015
1 parent 5ff0007 commit 24faf7c
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
## Qt Creator
*.pro
*.pro.user
inst/doc
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ Authors@R: c(
person("Manuel", "Eugster", role = c("aut", "cph")),
person("RStudio", role = "cph")
)
Depends:
Depends:
R (>= 3.0.2)
Imports:
Imports:
stringr (>= 0.5),
stringi,
brew,
digest,
methods,
Rcpp (>= 0.11.0)
Suggests:
Suggests:
testthat (>= 0.8.0),
knitr,
devtools
devtools,
rmarkdown
VignetteBuilder: knitr
LinkingTo: Rcpp
Collate:
Collate:
'RcppExports.R'
'alias.R'
'default-data-format.R'
Expand Down
24 changes: 12 additions & 12 deletions vignettes/collate.Rmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Controlling collation order}
-->
---
title: "Collation order"
author: "Hadley Wickham"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Collation order}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
```{r, include = FALSE}
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
```

# Collation order

R loads files in alphabetical order. Unfortunately not every alphabet puts letters in the same order, so you can't rely on alphabetic ordering if you need one file loaded before another. The order in which files are loaded doesn't matter for most packages. But if you're using S4, you'll need to make sure that classes are loaded before subclasses and generics are defined before methods.

Rather than relying on alphabetic ordering, roxygen2 provides an explicit way of saying that one file must be loaded before another: `@include`. The `@include` tag gives a space separated list of file names that should be loaded before the current file:
Expand Down
26 changes: 13 additions & 13 deletions vignettes/formatting.Rmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Text formatting}
-->

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
---
title: "Text formatting reference sheet"
author: "Hadley Wickham"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Text formatting reference sheet}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
```

# Text formatting reference sheet

Within roxygen tags, you use `.Rd` syntax to format text. This vignette shows you examples of the most important commands. The full details are described in [R extensions](http://cran.r-project.org/doc/manuals/R-exts.html#Marking-text).

Note that `\` and `%` are special characters. To insert literals, escape with a backslash: `\\`, `\%`.
Expand Down
26 changes: 13 additions & 13 deletions vignettes/namespace.Rmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Managing your NAMESPACE}
-->

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
---
title: "Package namespace"
author: "Hadley Wickham"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Package namespace}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
```

# Package namespace

The package `NAMESPACE` is one of the most confusing parts of building a package. Roxygen2 aims to make it as easy as possible to build a package that is a well-behaved member of the R ecosystem. This is a little frustrating at first, but soon becomes second-nature.

## Exports
Expand Down
26 changes: 13 additions & 13 deletions vignettes/rd.Rmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Generating Rd files}
-->

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE,
collapse = TRUE
)
---
title: "Generating Rd files"
author: "Hadley Wickham"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Generating Rd files}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
```

# Generating Rd files

## Roxygen process

Expand Down
24 changes: 12 additions & 12 deletions vignettes/rdkeywords.Rmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Rd keywords}
-->
---
title: "Rd keywords"
author: "Hadley Wickham"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Rd keywords}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
```{r, include = FALSE}
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
```

# Keywords

```{r}
cat(readLines(file.path(R.home("doc"), "KEYWORDS")), sep = "\n")
```
26 changes: 13 additions & 13 deletions vignettes/roxygen2.Rmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Getting started with Roxygen2}
-->

```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
---
title: "Introduction to roxygen2"
author: "Hadley Wickham"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Introduction to roxygen2}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
```

# Introduction to roxygen2

Documentation is one of the most important aspects of good code. Without it, users won't know how to use your package, and are unlikely to do so. Documentation is also useful for you in the future (so you remember what the heck you were thinking!), and for other developers working on your package. The goal of roxygen2 is to make documenting your code as easy as possible. R provides a standard way of documenting packages: you write `.Rd` files in the `man/` directory. These files use a custom syntax, loosely based on latex. Roxygen2 provides a number of advantages over writing `.Rd` files by hand:

* Code and documentation are adjacent so when you modify your code, it's easy
Expand Down

0 comments on commit 24faf7c

Please sign in to comment.