Skip to content

Commit dacee61

Browse files
committed
Project specific readme.Rmd
Fixes #85
1 parent e1e3328 commit dacee61

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

R/helpers.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ is_package <- function(base_path = proj_get()) {
4444
file.exists(file.path(base_path, "DESCRIPTION"))
4545
}
4646

47+
project_data <- function(base_path = proj_get()) {
48+
if (is_package(base_path)) {
49+
package_data(base_path)
50+
} else {
51+
list(Project = basename(base_path))
52+
}
53+
}
54+
4755
package_data <- function(base_path = proj_get()) {
4856
desc <- desc::description$new(base_path)
4957

R/readme.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
use_readme_rmd <- function(open = TRUE) {
2222
check_installed("rmarkdown")
2323

24-
data <- package_data()
24+
data <- project_data()
2525
data$Rmd <- TRUE
2626

2727
use_template(
28-
"omni-README",
28+
if (is_package()) "omni-README" else "project-README.Rmd",
2929
"README.Rmd",
3030
data = data,
3131
ignore = TRUE,

inst/templates/project-README.Rmd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
output: github_document
3+
---
4+
5+
<!-- README.md is generated from README.Rmd. Please edit that file -->
6+
7+
```{r setup, include = FALSE}
8+
knitr::opts_chunk$set(
9+
collapse = TRUE,
10+
comment = "#>"
11+
)
12+
```
13+
14+
# {{{ Project }}}
15+
16+
The goal of {{{ Project }}} is to ...
17+
18+
What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so:
19+
20+
```{r cars}
21+
summary(cars)
22+
```
23+
24+
You can also embed plots, for example:
25+
26+
```{r pressure, echo = FALSE}
27+
plot(pressure)
28+
```
29+
30+
In that case, don't forget to commit and push the resulting figure files, so they display on GitHub!

0 commit comments

Comments
 (0)