Skip to content

Commit

Permalink
Merge pull request #157 from jbelmiro/master
Browse files Browse the repository at this point in the history
Changing Readme Rmd to qmd
  • Loading branch information
benmarwick authored Jun 6, 2024
2 parents c536a72 + 6f5ec0b commit 68d0831
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 38 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Authors@R: c(person("Ben", "Marwick", role = c("aut", "cre"), email = "benmarwic
person("Wojciech", "Francuzik", role = "ctb"),
person("Charles", "Gray", role = "ctb"),
person("Joseph de la Torre", "Dwyer", role = "ctb"),
person("Max", "Czapanskiy", role = "ctb"))
person("Max", "Czapanskiy", role = "ctb"),
person("Joana","Belmiro", role = "ctb"))
Maintainer: Ben Marwick <[email protected]>
Description: Instructions, templates, and functions for making a basic
compendium suitable for doing reproducible research with R.
Expand All @@ -36,6 +37,6 @@ LazyData: true
URL: https://github.com/benmarwick/rrtools
BugReports: https://github.com/benmarwick/rrtools/issues
Suggests: testthat, quarto, knitr
RoxygenNote: 7.2.1
RoxygenNote: 7.3.1
VignetteBuilder: knitr
Date: 2019-01-15
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export(create_compendium)
export(use_analysis)
export(use_compendium)
export(use_dockerfile)
export(use_readme_rmd)
export(use_readme_qmd)
import(devtools)
import(here)
import(usethis)
Expand Down
4 changes: 2 additions & 2 deletions R/core_create_compendium.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ create_compendium <- function(
# run additional commands
paste0("usethis::use_mit_license(copyright_holder = '", get_git_config('user.name', global = TRUE), "')"),
"cat('\n')",
"rrtools::use_readme_rmd(render_readme = FALSE)",
"rrtools::use_readme_qmd(render_readme = FALSE)",
"cat('\n')",
paste0("rrtools::use_analysis(data_in_git = ", data_in_git, ")"),
"cat('\n')",
Expand Down Expand Up @@ -79,7 +79,7 @@ create_compendium <- function(
# run additional commands
usethis::use_mit_license(copyright_holder = get_git_config('user.name', global = TRUE))
cat('\n')
rrtools::use_readme_rmd(render_readme = FALSE)
rrtools::use_readme_qmd(render_readme = FALSE)
cat('\n')
rrtools::use_analysis(data_in_git = data_in_git)
cat('\n')
Expand Down
20 changes: 10 additions & 10 deletions R/core_use_readme_rmd.R → R/core_use_readme_qmd.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Creates skeleton README files
#'
#' @description
#' \code{README.Rmd} will be automatically
#' \code{README.qmd} will be automatically
#' added to \code{.Rbuildignore}. The resulting README is populated with default
#' YAML frontmatter and R fenced code chunks (\code{Rmd}).
#' YAML frontmatter and R fenced code chunks (\code{qmd}).
#' Your readme should contain:
#' \itemize{
#' \item a high-level description of the package and its goals
Expand All @@ -13,16 +13,16 @@
#'
#' @param pkg package description, can be path or package name. See
#' \code{\link{as.package}} for more information
#' @param render_readme should the README.Rmd be directly rendered to
#' @param render_readme should the README.qmd be directly rendered to
#' a github markdown document? default: TRUE
#' @importFrom rmarkdown render
#' @export
#' @examples
#' \dontrun{
#' use_readme_rmd()
#' use_readme_qmd()
#' }
#' @family infrastructure
use_readme_rmd <- function(pkg = ".", render_readme = TRUE) {
use_readme_qmd <- function(pkg = ".", render_readme = TRUE) {
pkg <- as.package(pkg)
data <- pkg

Expand All @@ -31,11 +31,11 @@ use_readme_rmd <- function(pkg = ".", render_readme = TRUE) {
gh <- github_info(pkg$path)
data = c(pkg, gh)
}
pkg$Rmd <- TRUE
pkg$qmd <- TRUE


use_template("omni-README",
save_as = "README.Rmd",
save_as = "README.qmd",
data = data,
ignore = TRUE,
open = TRUE,
Expand All @@ -46,12 +46,12 @@ use_readme_rmd <- function(pkg = ".", render_readme = TRUE) {

if (uses_git(pkg$path)) {
message("* Adding pre-commit hook")
use_git_hook("pre-commit", render_template("readme-rmd-pre-commit.sh"))
use_git_hook("pre-commit", render_template("readme-qmd-pre-commit.sh"))
}

if (render_readme) {
usethis::ui_done("\nRendering README.Rmd to README.md for GitHub.")
rmarkdown::render("README.Rmd", quiet = TRUE)
usethis::ui_done("\nRendering README.qmd to README.md for GitHub.")
rmarkdown::render("README.qmd", quiet = TRUE)
unlink("README.html")
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ To create a reproducible research compendium step-by-step using the rrtools appr
- this adds a reference to the MIT license in the [DESCRIPTION](DESCRIPTION) file and generates a [LICENSE](LICENSE) file listing the name provided as the copyright holder
- to use a different license, replace this line with any of the licenses mentioned here: `?usethis::use_mit_license()`

#### 3\. `rrtools::use_readme_rmd()`
#### 3\. `rrtools::use_readme_qmd()`

- this generates [README.Rmd](README.Rmd) and renders it to [README.md](README.md), ready to display on GitHub. It contains:
- this generates [README.qmd](README.qmd) and renders it to [README.md](README.md), ready to display on GitHub. It contains:
- a template citation to show others how to cite your project. Edit this to include the correct title and [DOI](https://doi.org).
- license information for the text, figures, code and data in your compendium
- this also adds two other markdown files: a code of conduct for users [CONDUCT.md](CONDUCT.md), and basic instructions for people who want to contribute to your project [CONTRIBUTING.md](CONTRIBUTING.md), including for first-timers to git and GitHub.
Expand Down
8 changes: 4 additions & 4 deletions inst/templates/readme-rmd-pre-commit.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
README=($(git diff --cached --name-only | grep -Ei '^README\.[R]?md$'))
README=($(git diff --cached --name-only | grep -Ei '^README\.[q]?md$'))
MSG="use 'git commit --no-verify' to override this check"

if [[ ${#README[@]} == 0 ]]; then
exit 0
fi

if [[ README.Rmd -nt README.md ]]; then
echo -e "README.md is out of date; please re-knit README.Rmd\n$MSG"
if [[ README.qmd -nt README.md ]]; then
echo -e "README.md is out of date; please re-knit README.qmd\n$MSG"
exit 1
elif [[ ${#README[@]} -lt 2 ]]; then
echo -e "README.Rmd and README.md should be both staged\n$MSG"
echo -e "README.qmd and README.md should be both staged\n$MSG"
exit 1
fi
16 changes: 8 additions & 8 deletions man/use_readme_rmd.Rd → man/use_readme_qmd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
context("use_readme_rmd()")
context("use_readme_qmd()")

#### run function ####

suppressMessages(
rrtools::use_readme_rmd(
rrtools::use_readme_qmd(
package_path,
render_readme = FALSE
)
Expand All @@ -12,10 +12,10 @@ suppressMessages(
#### check results ####

# general
test_that("use_readme_rmd generates the correct files", {
test_that("use_readme_qmd generates the correct files", {
expect_true(
all(
c("CONDUCT.md", "CONTRIBUTING.md", "README.Rmd") %in%
c("CONDUCT.md", "CONTRIBUTING.md", "README.qmd") %in%
list.files(package_path)
)
)
Expand Down Expand Up @@ -83,9 +83,9 @@ test_that("CONTRIBUTING.md could be rendered to html", {
)
})

# README.Rmd
test_that("README.Rmd is a text file and has the correct heading", {
readme <- readLines(file.path(package_path, "README.Rmd"))
# README.qmd
test_that("README.qmd is a text file and has the correct heading", {
readme <- readLines(file.path(package_path, "README.qmd"))
expect_gt(
length(readme),
1
Expand All @@ -95,10 +95,10 @@ test_that("README.Rmd is a text file and has the correct heading", {
)
})

test_that("README.Rmd could be rendered to github markdown and then html", {
test_that("README.qmd could be rendered to github markdown and then html", {
expect_silent(
rmarkdown::render(
input = file.path(package_path, "README.Rmd"),
input = file.path(package_path, "README.qmd"),
output_format = "github_document",
output_file = file.path(package_path, "README.md"),
quiet = TRUE
Expand Down

0 comments on commit 68d0831

Please sign in to comment.