From 4d6b47d7b8a002009bdd9860884f765fb0061bca Mon Sep 17 00:00:00 2001 From: jbelmiro <44205806+jbelmiro@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:00:02 +0100 Subject: [PATCH 1/3] Changing Readme Rmd to qmd - 1st try --- NAMESPACE | 2 +- R/core_create_compendium.R | 4 ++-- ...use_readme_rmd.R => core_use_readme_qmd.R} | 20 +++++++++---------- README.md | 4 ++-- inst/templates/readme-rmd-pre-commit.sh | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) rename R/{core_use_readme_rmd.R => core_use_readme_qmd.R} (79%) diff --git a/NAMESPACE b/NAMESPACE index 4e2548d..00fb3c3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/core_create_compendium.R b/R/core_create_compendium.R index bd131d8..f3622ef 100644 --- a/R/core_create_compendium.R +++ b/R/core_create_compendium.R @@ -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')", @@ -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') diff --git a/R/core_use_readme_rmd.R b/R/core_use_readme_qmd.R similarity index 79% rename from R/core_use_readme_rmd.R rename to R/core_use_readme_qmd.R index 95186e2..01619b0 100644 --- a/R/core_use_readme_rmd.R +++ b/R/core_use_readme_qmd.R @@ -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 @@ -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 @@ -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, @@ -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") } diff --git a/README.md b/README.md index 11f43fa..485bbc2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/inst/templates/readme-rmd-pre-commit.sh b/inst/templates/readme-rmd-pre-commit.sh index 2a51a16..ae274e1 100644 --- a/inst/templates/readme-rmd-pre-commit.sh +++ b/inst/templates/readme-rmd-pre-commit.sh @@ -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 From ba2cef24882146b5f0721fecc0c859cceea147d5 Mon Sep 17 00:00:00 2001 From: jbelmiro <44205806+jbelmiro@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:01:52 +0100 Subject: [PATCH 2/3] Changed rmd to qmd at test-005 Added name to contributors in description --- DESCRIPTION | 3 ++- ..._readme_rmd.R => test-005-use_readme_qmd.R} | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) rename tests/testthat/{test-005-use_readme_rmd.R => test-005-use_readme_qmd.R} (84%) diff --git a/DESCRIPTION b/DESCRIPTION index 0fe0d48..9fc1d6d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 Description: Instructions, templates, and functions for making a basic compendium suitable for doing reproducible research with R. diff --git a/tests/testthat/test-005-use_readme_rmd.R b/tests/testthat/test-005-use_readme_qmd.R similarity index 84% rename from tests/testthat/test-005-use_readme_rmd.R rename to tests/testthat/test-005-use_readme_qmd.R index d1292db..3c6a522 100644 --- a/tests/testthat/test-005-use_readme_rmd.R +++ b/tests/testthat/test-005-use_readme_qmd.R @@ -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 ) @@ -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) ) ) @@ -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 @@ -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 From 6f5ec0b81a16c5785828d0fcf4f45f08b484a1b5 Mon Sep 17 00:00:00 2001 From: jbelmiro <44205806+jbelmiro@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:46:09 +0100 Subject: [PATCH 3/3] Regenerated help file for use_readme to replace rmd by qmd --- DESCRIPTION | 2 +- man/{use_readme_rmd.Rd => use_readme_qmd.Rd} | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) rename man/{use_readme_rmd.Rd => use_readme_qmd.Rd} (64%) diff --git a/DESCRIPTION b/DESCRIPTION index 9fc1d6d..932c128 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,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 diff --git a/man/use_readme_rmd.Rd b/man/use_readme_qmd.Rd similarity index 64% rename from man/use_readme_rmd.Rd rename to man/use_readme_qmd.Rd index 5c91a57..5e83a27 100644 --- a/man/use_readme_rmd.Rd +++ b/man/use_readme_qmd.Rd @@ -1,22 +1,22 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/core_use_readme_rmd.R -\name{use_readme_rmd} -\alias{use_readme_rmd} +% Please edit documentation in R/core_use_readme_qmd.R +\name{use_readme_qmd} +\alias{use_readme_qmd} \title{Creates skeleton README files} \usage{ -use_readme_rmd(pkg = ".", render_readme = TRUE) +use_readme_qmd(pkg = ".", render_readme = TRUE) } \arguments{ \item{pkg}{package description, can be path or package name. See \code{\link{as.package}} for more information} -\item{render_readme}{should the README.Rmd be directly rendered to +\item{render_readme}{should the README.qmd be directly rendered to a github markdown document? default: TRUE} } \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 @@ -26,7 +26,7 @@ Your readme should contain: } \examples{ \dontrun{ -use_readme_rmd() +use_readme_qmd() } } \concept{infrastructure}