-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #931 from r-lib/issue-931
support qmd file format, and treat it internally as R markdown
- Loading branch information
Showing
26 changed files
with
384 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
output: | ||
github_document: | ||
html_preview: true | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
Some text | ||
```{r} | ||
# Some R code | ||
f <- function(x) { | ||
x | ||
} | ||
``` | ||
Final text | ||
```{r} | ||
1 + 2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Package: xyzpackage | ||
Title: What the Package Does (one line, title case) | ||
Version: 0.0.0.9000 | ||
Authors@R: person("First", "Last", email = "[email protected]", role = c("aut", "cre")) | ||
Description: What the package does (one paragraph). | ||
Depends: R (>= 3.3.2) | ||
License: What license is it under? | ||
Encoding: UTF-8 | ||
LazyData: true | ||
Suggests: testthat | ||
LinkingTo: | ||
Rcpp | ||
Imports: | ||
Rcpp | ||
RoxygenNote: 6.0.1.9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Generated by roxygen2: do not edit by hand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
timesTwo <- function(x) { | ||
.Call("_xyzpackage_timesTwo", PACKAGE = "xyzpackage", x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hello_world <- function() { | ||
print("hello, world") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
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-" | ||
) | ||
``` | ||
# styler | ||
|
||
The goal of styler is to ... | ||
|
||
## Installation | ||
|
||
You can install styler from github with: | ||
|
||
```{r gh-installation, eval = FALSE} | ||
# install.packages("devtools") | ||
devtools::install_github("jonmcalder/styler") | ||
``` | ||
|
||
## Example | ||
|
||
This is a basic example which shows you how to solve a common problem: | ||
|
||
```{r example} | ||
## basic example code | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
output: | ||
github_document: | ||
html_preview: true | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
Some text | ||
```{r} | ||
# Some R code | ||
f <- function(x) { | ||
x | ||
} | ||
``` | ||
Final text | ||
```{r} | ||
1 + 2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.dll | ||
*.o | ||
*.so |
28 changes: 28 additions & 0 deletions
28
tests/testthat/public-api/xyzpackage-qmd/src/RcppExports.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
#include <Rcpp.h> | ||
|
||
using namespace Rcpp; | ||
|
||
// timesTwo | ||
NumericVector timesTwo(NumericVector x); | ||
RcppExport SEXP _xyzpackage_timesTwo(SEXP xSEXP) { | ||
BEGIN_RCPP | ||
Rcpp::RObject rcpp_result_gen; | ||
Rcpp::RNGScope rcpp_rngScope_gen; | ||
Rcpp::traits::input_parameter< NumericVector >::type x(xSEXP); | ||
rcpp_result_gen = Rcpp::wrap(timesTwo(x)); | ||
return rcpp_result_gen; | ||
END_RCPP | ||
} | ||
|
||
static const R_CallMethodDef CallEntries[] = { | ||
{"_xyzpackage_timesTwo", (DL_FUNC) &_xyzpackage_timesTwo, 1}, | ||
{NULL, NULL, 0} | ||
}; | ||
|
||
RcppExport void R_init_xyzpackage(DllInfo *dll) { | ||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); | ||
R_useDynamicSymbols(dll, FALSE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <Rcpp.h> | ||
using namespace Rcpp; | ||
|
||
// This is a simple example of exporting a C++ function to R. You can | ||
// source this function into an R session using the Rcpp::sourceCpp | ||
// function (or via the Source button on the editor toolbar). Learn | ||
// more about Rcpp at: | ||
// | ||
// http://www.rcpp.org/ | ||
// http://adv-r.had.co.nz/Rcpp.html | ||
// http://gallery.rcpp.org/ | ||
// | ||
|
||
// [[Rcpp::export]] | ||
NumericVector timesTwo(NumericVector x) { | ||
return x * 2; | ||
} | ||
|
||
|
||
// You can include R code blocks in C++ files processed with sourceCpp | ||
// (useful for testing and development). The R code will be automatically | ||
// run after the compilation. | ||
// | ||
|
||
/*** R | ||
timesTwo(42) | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(xyzpackage) | ||
|
||
test_check("xyzpackage") |
5 changes: 5 additions & 0 deletions
5
tests/testthat/public-api/xyzpackage-qmd/tests/testthat/test-package-xyz.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
context("testing styler on package") | ||
|
||
test_that("hi there", { | ||
I(am(a(package(x)))) | ||
}) |
58 changes: 58 additions & 0 deletions
58
tests/testthat/public-api/xyzpackage-qmd/vignettes/random.Rmarkdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: "Vignette Title" | ||
author: "Vignette Author" | ||
date: "`r Sys.Date()`" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Vignette Title} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format: | ||
|
||
- Never uses retina figures | ||
- Has a smaller default figure size | ||
- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style | ||
|
||
## Vignette Info | ||
|
||
Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette. | ||
|
||
## Styles | ||
|
||
The `html_vignette` template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows: | ||
|
||
output: | ||
rmarkdown::html_vignette: | ||
css: mystyles.css | ||
|
||
## Figures | ||
|
||
The figure sizes have been customised so that you can easily put two images side-by-side. | ||
|
||
```{r, fig.show='hold'} | ||
plot(1:10) | ||
plot(10:1) | ||
``` | ||
|
||
You can enable figure captions by `fig_caption: yes` in YAML: | ||
|
||
output: | ||
rmarkdown::html_vignette: | ||
fig_caption: yes | ||
|
||
Then you can use the chunk option `fig.cap = "Your figure caption."` in **knitr**. | ||
|
||
## More Examples | ||
|
||
You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using `knitr::kable()`. | ||
|
||
```{r, echo=FALSE, results='asis'} | ||
knitr::kable(head(mtcars, 10)) | ||
``` | ||
|
||
Also a quote using `>`: | ||
|
||
> "He who gives up [code] safety for [code] speed deserves neither." | ||
([via](https://twitter.com/hadleywickham/status/504368538874703872)) |
Oops, something went wrong.