From 571aa725e150cb3fba1e3faf20e82de5a35d59dc Mon Sep 17 00:00:00 2001 From: William Gearty Date: Tue, 1 Oct 2024 10:58:15 -0400 Subject: [PATCH] Use YAML for comment --- vignettes/precompile.R | 13 +++++++------ vignettes/rredlist.Rmd | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/vignettes/precompile.R b/vignettes/precompile.R index 07d9430..90ccec8 100644 --- a/vignettes/precompile.R +++ b/vignettes/precompile.R @@ -15,13 +15,14 @@ build_vignettes() # x = vignette file name including file extension (e.g., "rredlist.Rmd") read_only <- function(x) { + # Create file tmp <- file(x) - nlines <- grep("^---\\s*$", readLines(x))[2] - writeLines( - c(readLines(x)[1:(nlines + 1)], - paste0(""), - readLines(x)[(nlines + 2):length(readLines(x))]), tmp) + # write lines + writeLines(c(c("---"), + c("comment: >"), + c(" Generated by vignettes/precompile.R: do not edit by hand."), + paste0(" Please edit source in vignettes/source/_", x), + readLines(x)[2:length(readLines(x))]), tmp) close(tmp) } # Add read only info diff --git a/vignettes/rredlist.Rmd b/vignettes/rredlist.Rmd index 5e5ea59..e670c46 100644 --- a/vignettes/rredlist.Rmd +++ b/vignettes/rredlist.Rmd @@ -1,4 +1,7 @@ --- +comment: > + Generated by vignettes/precompile.R: do not edit by hand. + Please edit source in vignettes/source/_rredlist.Rmd title: "Introduction to rredlist" author: "William Gearty" date: "2024-10-01" @@ -9,8 +12,6 @@ vignette: > %\VignetteEncoding{UTF-8} --- - `rredlist` is an R client for the IUCN Red List API (https://api.iucnredlist.org/).