Skip to content

Commit

Permalink
Update vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Oct 28, 2015
1 parent 24faf7c commit 37564bd
Show file tree
Hide file tree
Showing 12 changed files with 695 additions and 1,740 deletions.
10 changes: 3 additions & 7 deletions vignettes/collate.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
## ----, echo = FALSE, message = FALSE-------------------------------------
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)

## ----, eval = FALSE------------------------------------------------------
## ---- eval = FALSE-------------------------------------------------------
# #' @include class-a.r
# setClass("B", contains = "A")

251 changes: 54 additions & 197 deletions vignettes/collate.html

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions vignettes/formatting.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## ----, echo = FALSE, message = FALSE-------------------------------------
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)

## ------------------------------------------------------------------------
#' \enumerate{
Expand Down
339 changes: 91 additions & 248 deletions vignettes/formatting.html

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions vignettes/namespace.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## ----, echo = FALSE, message = FALSE-------------------------------------
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)

261 changes: 48 additions & 213 deletions vignettes/namespace.html

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions vignettes/rd.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
## ---- echo = FALSE, message = FALSE--------------------------------------
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE,
collapse = TRUE
)
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)

## ------------------------------------------------------------------------
#' Add together two numbers
Expand Down
894 changes: 311 additions & 583 deletions vignettes/rd.html

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions vignettes/rdkeywords.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## ----, echo = FALSE, message = FALSE-------------------------------------
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)

## ------------------------------------------------------------------------
cat(readLines(file.path(R.home("doc"), "KEYWORDS")), sep = "\n")
Expand Down
418 changes: 138 additions & 280 deletions vignettes/rdkeywords.html

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions vignettes/roxygen2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## ----, echo = FALSE, message = FALSE-------------------------------------
knitr::opts_chunk$set(
comment = "#>",
error = FALSE,
tidy = FALSE
)
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)

221 changes: 40 additions & 181 deletions vignettes/roxygen2.html
Original file line number Diff line number Diff line change
@@ -1,213 +1,72 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>Introduction to roxygen2</title>
<html xmlns="http://www.w3.org/1999/xhtml">

<script type="text/javascript">
window.onload = function() {
var imgs = document.getElementsByTagName('img'), i, img;
for (i = 0; i < imgs.length; i++) {
img = imgs[i];
// center an image if it is the only element of its parent
if (img.parentElement.childElementCount === 1)
img.parentElement.style.textAlign = 'center';
}
};
</script>
<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />

<meta name="author" content="Hadley Wickham" />

<meta name="date" content="2015-10-28" />

<title>Introduction to roxygen2</title>

<style type="text/css">
body, td {
font-family: sans-serif;
background-color: white;
font-size: 13px;
}

body {
max-width: 800px;
margin: auto;
padding: 1em;
line-height: 20px;
}

tt, code, pre {
font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace;
}

h1 {
font-size:2.2em;
}

h2 {
font-size:1.8em;
}

h3 {
font-size:1.4em;
}

h4 {
font-size:1.0em;
}

h5 {
font-size:0.9em;
}

h6 {
font-size:0.8em;
}

a:visited {
color: rgb(50%, 0%, 50%);
}

pre, img {
max-width: 100%;
}
pre {
overflow-x: auto;
}
pre code {
display: block; padding: 0.5em;
}

code {
font-size: 92%;
border: 1px solid #ccc;
}

code[class] {
background-color: #F8F8F8;
}

table, td, th {
border: none;
}

blockquote {
color:#666666;
margin:0;
padding-left: 1em;
border-left: 0.5em #EEE solid;
}

hr {
height: 0px;
border-bottom: none;
border-top-width: thin;
border-top-style: dotted;
border-top-color: #999999;
}

@media print {
* {
background: transparent !important;
color: black !important;
filter:none !important;
-ms-filter: none !important;
}

body {
font-size:12pt;
max-width:100%;
}

a, a:visited {
text-decoration: underline;
}

hr {
visibility: hidden;
page-break-before: always;
}

pre, blockquote {
padding-right: 1em;
page-break-inside: avoid;
}

tr, img {
page-break-inside: avoid;
}

img {
max-width: 100% !important;
}

@page :left {
margin: 15mm 20mm 15mm 10mm;
}

@page :right {
margin: 15mm 10mm 15mm 20mm;
}

p, h2, h3 {
orphans: 3; widows: 3;
}

h2, h3 {
page-break-after: avoid;
}
}
</style>



<link href="data:text/css,body%20%7B%0A%20%20background%2Dcolor%3A%20%23fff%3B%0A%20%20margin%3A%201em%20auto%3B%0A%20%20max%2Dwidth%3A%20700px%3B%0A%20%20overflow%3A%20visible%3B%0A%20%20padding%2Dleft%3A%202em%3B%0A%20%20padding%2Dright%3A%202em%3B%0A%20%20font%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0A%20%20font%2Dsize%3A%2014px%3B%0A%20%20line%2Dheight%3A%201%2E35%3B%0A%7D%0A%0A%23header%20%7B%0A%20%20text%2Dalign%3A%20center%3B%0A%7D%0A%0A%23TOC%20%7B%0A%20%20clear%3A%20both%3B%0A%20%20margin%3A%200%200%2010px%2010px%3B%0A%20%20padding%3A%204px%3B%0A%20%20width%3A%20400px%3B%0A%20%20border%3A%201px%20solid%20%23CCCCCC%3B%0A%20%20border%2Dradius%3A%205px%3B%0A%0A%20%20background%2Dcolor%3A%20%23f6f6f6%3B%0A%20%20font%2Dsize%3A%2013px%3B%0A%20%20line%2Dheight%3A%201%2E3%3B%0A%7D%0A%20%20%23TOC%20%2Etoctitle%20%7B%0A%20%20%20%20font%2Dweight%3A%20bold%3B%0A%20%20%20%20font%2Dsize%3A%2015px%3B%0A%20%20%20%20margin%2Dleft%3A%205px%3B%0A%20%20%7D%0A%0A%20%20%23TOC%20ul%20%7B%0A%20%20%20%20padding%2Dleft%3A%2040px%3B%0A%20%20%20%20margin%2Dleft%3A%20%2D1%2E5em%3B%0A%20%20%20%20margin%2Dtop%3A%205px%3B%0A%20%20%20%20margin%2Dbottom%3A%205px%3B%0A%20%20%7D%0A%20%20%23TOC%20ul%20ul%20%7B%0A%20%20%20%20margin%2Dleft%3A%20%2D2em%3B%0A%20%20%7D%0A%20%20%23TOC%20li%20%7B%0A%20%20%20%20line%2Dheight%3A%2016px%3B%0A%20%20%7D%0A%0Atable%20%7B%0A%20%20margin%3A%201em%20auto%3B%0A%20%20border%2Dwidth%3A%201px%3B%0A%20%20border%2Dcolor%3A%20%23DDDDDD%3B%0A%20%20border%2Dstyle%3A%20outset%3B%0A%20%20border%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0A%20%20border%2Dwidth%3A%202px%3B%0A%20%20padding%3A%205px%3B%0A%20%20border%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0A%20%20border%2Dwidth%3A%201px%3B%0A%20%20border%2Dstyle%3A%20inset%3B%0A%20%20line%2Dheight%3A%2018px%3B%0A%20%20padding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0A%20%20border%2Dleft%2Dstyle%3A%20none%3B%0A%20%20border%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0A%20%20background%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0A%0Ap%20%7B%0A%20%20margin%3A%200%2E5em%200%3B%0A%7D%0A%0Ablockquote%20%7B%0A%20%20background%2Dcolor%3A%20%23f6f6f6%3B%0A%20%20padding%3A%200%2E25em%200%2E75em%3B%0A%7D%0A%0Ahr%20%7B%0A%20%20border%2Dstyle%3A%20solid%3B%0A%20%20border%3A%20none%3B%0A%20%20border%2Dtop%3A%201px%20solid%20%23777%3B%0A%20%20margin%3A%2028px%200%3B%0A%7D%0A%0Adl%20%7B%0A%20%20margin%2Dleft%3A%200%3B%0A%7D%0A%20%20dl%20dd%20%7B%0A%20%20%20%20margin%2Dbottom%3A%2013px%3B%0A%20%20%20%20margin%2Dleft%3A%2013px%3B%0A%20%20%7D%0A%20%20dl%20dt%20%7B%0A%20%20%20%20font%2Dweight%3A%20bold%3B%0A%20%20%7D%0A%0Aul%20%7B%0A%20%20margin%2Dtop%3A%200%3B%0A%7D%0A%20%20ul%20li%20%7B%0A%20%20%20%20list%2Dstyle%3A%20circle%20outside%3B%0A%20%20%7D%0A%20%20ul%20ul%20%7B%0A%20%20%20%20margin%2Dbottom%3A%200%3B%0A%20%20%7D%0A%0Apre%2C%20code%20%7B%0A%20%20background%2Dcolor%3A%20%23f7f7f7%3B%0A%20%20border%2Dradius%3A%203px%3B%0A%20%20color%3A%20%23333%3B%0A%7D%0Apre%20%7B%0A%20%20white%2Dspace%3A%20pre%2Dwrap%3B%20%20%20%20%2F%2A%20Wrap%20long%20lines%20%2A%2F%0A%20%20border%2Dradius%3A%203px%3B%0A%20%20margin%3A%205px%200px%2010px%200px%3B%0A%20%20padding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0A%20%20background%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0A%0Acode%20%7B%0A%20%20font%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0A%20%20font%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0A%20%20padding%3A%202px%200px%3B%0A%7D%0A%0Adiv%2Efigure%20%7B%0A%20%20text%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0A%20%20background%2Dcolor%3A%20%23FFFFFF%3B%0A%20%20padding%3A%202px%3B%0A%20%20border%3A%201px%20solid%20%23DDDDDD%3B%0A%20%20border%2Dradius%3A%203px%3B%0A%20%20border%3A%201px%20solid%20%23CCCCCC%3B%0A%20%20margin%3A%200%205px%3B%0A%7D%0A%0Ah1%20%7B%0A%20%20margin%2Dtop%3A%200%3B%0A%20%20font%2Dsize%3A%2035px%3B%0A%20%20line%2Dheight%3A%2040px%3B%0A%7D%0A%0Ah2%20%7B%0A%20%20border%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0A%20%20padding%2Dtop%3A%2010px%3B%0A%20%20padding%2Dbottom%3A%202px%3B%0A%20%20font%2Dsize%3A%20145%25%3B%0A%7D%0A%0Ah3%20%7B%0A%20%20border%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0A%20%20padding%2Dtop%3A%2010px%3B%0A%20%20font%2Dsize%3A%20120%25%3B%0A%7D%0A%0Ah4%20%7B%0A%20%20border%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0A%20%20margin%2Dleft%3A%208px%3B%0A%20%20font%2Dsize%3A%20105%25%3B%0A%7D%0A%0Ah5%2C%20h6%20%7B%0A%20%20border%2Dbottom%3A%201px%20solid%20%23ccc%3B%0A%20%20font%2Dsize%3A%20105%25%3B%0A%7D%0A%0Aa%20%7B%0A%20%20color%3A%20%230033dd%3B%0A%20%20text%2Ddecoration%3A%20none%3B%0A%7D%0A%20%20a%3Ahover%20%7B%0A%20%20%20%20color%3A%20%236666ff%3B%20%7D%0A%20%20a%3Avisited%20%7B%0A%20%20%20%20color%3A%20%23800080%3B%20%7D%0A%20%20a%3Avisited%3Ahover%20%7B%0A%20%20%20%20color%3A%20%23BB00BB%3B%20%7D%0A%20%20a%5Bhref%5E%3D%22http%3A%22%5D%20%7B%0A%20%20%20%20text%2Ddecoration%3A%20underline%3B%20%7D%0A%20%20a%5Bhref%5E%3D%22https%3A%22%5D%20%7B%0A%20%20%20%20text%2Ddecoration%3A%20underline%3B%20%7D%0A%0A%2F%2A%20Class%20described%20in%20https%3A%2F%2Fbenjeffrey%2Ecom%2Fposts%2Fpandoc%2Dsyntax%2Dhighlighting%2Dcss%0A%20%20%20Colours%20from%20https%3A%2F%2Fgist%2Egithub%2Ecom%2Frobsimmons%2F1172277%20%2A%2F%0A%0Acode%20%3E%20span%2Ekw%20%7B%20color%3A%20%23555%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%2F%2A%20Keyword%20%2A%2F%0Acode%20%3E%20span%2Edt%20%7B%20color%3A%20%23902000%3B%20%7D%20%2F%2A%20DataType%20%2A%2F%0Acode%20%3E%20span%2Edv%20%7B%20color%3A%20%2340a070%3B%20%7D%20%2F%2A%20DecVal%20%28decimal%20values%29%20%2A%2F%0Acode%20%3E%20span%2Ebn%20%7B%20color%3A%20%23d14%3B%20%7D%20%2F%2A%20BaseN%20%2A%2F%0Acode%20%3E%20span%2Efl%20%7B%20color%3A%20%23d14%3B%20%7D%20%2F%2A%20Float%20%2A%2F%0Acode%20%3E%20span%2Ech%20%7B%20color%3A%20%23d14%3B%20%7D%20%2F%2A%20Char%20%2A%2F%0Acode%20%3E%20span%2Est%20%7B%20color%3A%20%23d14%3B%20%7D%20%2F%2A%20String%20%2A%2F%0Acode%20%3E%20span%2Eco%20%7B%20color%3A%20%23888888%3B%20font%2Dstyle%3A%20italic%3B%20%7D%20%2F%2A%20Comment%20%2A%2F%0Acode%20%3E%20span%2Eot%20%7B%20color%3A%20%23007020%3B%20%7D%20%2F%2A%20OtherToken%20%2A%2F%0Acode%20%3E%20span%2Eal%20%7B%20color%3A%20%23ff0000%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%2F%2A%20AlertToken%20%2A%2F%0Acode%20%3E%20span%2Efu%20%7B%20color%3A%20%23900%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%2F%2A%20Function%20calls%20%2A%2F%20%0Acode%20%3E%20span%2Eer%20%7B%20color%3A%20%23a61717%3B%20background%2Dcolor%3A%20%23e3d2d2%3B%20%7D%20%2F%2A%20ErrorTok%20%2A%2F%0A%0A" rel="stylesheet" type="text/css" />

</head>

<body>
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Getting started with Roxygen2}
-->

<h1>Introduction to roxygen2</h1>

<p>Documentation is one of the most important aspects of good code. Without it, users won&#39;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 <code>.Rd</code> files in the <code>man/</code> directory. These files use a custom syntax, loosely based on latex. Roxygen2 provides a number of advantages over writing <code>.Rd</code> files by hand:</p>

<div id="header">
<h1 class="title">Introduction to roxygen2</h1>
<h4 class="author"><em>Hadley Wickham</em></h4>
<h4 class="date"><em>2015-10-28</em></h4>
</div>


<p>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 <code>.Rd</code> files in the <code>man/</code> directory. These files use a custom syntax, loosely based on latex. Roxygen2 provides a number of advantages over writing <code>.Rd</code> files by hand:</p>
<ul>
<li><p>Code and documentation are adjacent so when you modify your code, it&#39;s easy
to remember that you need to update the documentation.</p></li>
<li><p>Roxygen2 dynamically inspects the objects that it&#39;s documenting, so it
can automatically add data that you&#39;d otherwise have to write by hand.</p></li>
<li><p>It abstracts over the differences in documenting S3 and S4 methods,
generics and classes so you need to learn fewer details.</p></li>
<li><p>Code and documentation are adjacent so when you modify your code, it’s easy to remember that you need to update the documentation.</p></li>
<li><p>Roxygen2 dynamically inspects the objects that it’s documenting, so it can automatically add data that you’d otherwise have to write by hand.</p></li>
<li><p>It abstracts over the differences in documenting S3 and S4 methods, generics and classes so you need to learn fewer details.</p></li>
</ul>

<p>As well as generating <code>.Rd</code> files, roxygen will also create a <code>NAMESPACE</code> for you, and will manage the <code>Collate</code> field in <code>DESCRIPTION</code>.</p>

<p>This vignette provides a high-level description of roxygen2 and how the three main components work. The other vignettes provide more detail on the individual components:</p>

<ul>
<li><p><a href="rd.html">Generating .Rd files</a> and <a href="formatting.html">text formatting</a>
describe how to generate function documentation via <code>.Rd</code> files</p></li>
<li><p><a href="namespace.html">Managing your <code>NAMESPACE</code></a> describes how to generate
a <code>NAMESPACE</code> file, how namespacing works in R, and how you can use Roxygen2 to be
specific about what your package needs and supplies.</p></li>
<li><p><a href="collate.html">Controlling collation order</a> describes how roxygen2
controls file loading order if you need to make sure one file is
loaded before another.</p></li>
<li><p><a href="rd.html">Generating .Rd files</a> and <a href="formatting.html">text formatting</a> describe how to generate function documentation via <code>.Rd</code> files</p></li>
<li><p><a href="namespace.html">Managing your <code>NAMESPACE</code></a> describes how to generate a <code>NAMESPACE</code> file, how namespacing works in R, and how you can use Roxygen2 to be specific about what your package needs and supplies.</p></li>
<li><p><a href="collate.html">Controlling collation order</a> describes how roxygen2 controls file loading order if you need to make sure one file is loaded before another.</p></li>
</ul>

<div id="running-roxygen" class="section level1">
<h1>Running roxygen</h1>

<p>There are three main ways to run roxygen:</p>

<ul>
<li><p><code>roxygen2::roxygenise()</code>, or</p></li>
<li><p><code>devtools::document()</code>, if you&#39;re using devtools, or</p></li>
<li><p><code>Ctrl + Shift + D</code>, if you&#39;re using RStudio.</p></li>
<li><p><code>devtools::document()</code>, if youre using devtools, or</p></li>
<li><p><code>Ctrl + Shift + D</code>, if youre using RStudio.</p></li>
</ul>
<p>As of version 4.0.0, roxygen2 will never overwrite a file it didn’t create. It does this by labelling every file it creates with a comment: “Generated by roxygen2 (version): do not edit by hand”.</p>
</div>

<p>As of version 4.0.0, roxygen2 will never overwrite a file it didn&#39;t create. It does this by labelling every file it creates with a comment: &ldquo;Generated by roxygen2 (version): do not edit by hand&rdquo;.</p>

</body>

<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>

</body>
</html>

0 comments on commit 37564bd

Please sign in to comment.