Skip to content

Commit

Permalink
Warn if README.qmd does not exist in quarto websites (#287)
Browse files Browse the repository at this point in the history
* issue #280: warn if README.qmd does not exist in quarto websites

* test
  • Loading branch information
vincentarelbundock authored Jul 23, 2024
1 parent 6116ed5 commit eec064e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: altdoc
Title: Package Documentation Websites with 'Quarto', 'Docsify', 'Docute', or 'MkDocs'
Version: 0.3.0.9004
Version: 0.3.0.9005
Authors@R:
c(person(given = "Etienne",
family = "Bacher",
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
the `code-link` line in `altdoc/quarto_website.yml`
* Citation is now formatted with HTML instead of verbatim (#282, Achim Zeileis).
* The `\doi{}` tags in Rd files are now linked once rendered (#282, Achim Zeileis).
* Warn if README.qmd does not exist when calling `setup_docs("quarto_website")`. Issue #280.



Expand Down
10 changes: 8 additions & 2 deletions R/setup_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,15 @@ setup_docs <- function(tool, path = ".", overwrite = FALSE) {
}

# README.md is mandatory
fn <- fs::path_join(c(path, "README.md"))
if (tool == "quarto_website") {
fn <- "README.qmd"
} else {
fn <- "README.md"
}
msg <- sprintf("%s is mandatory. `altdoc` created a dummy README file in the package directory.", fn)
fn <- fs::path_join(c(path, fn))
if (!fs::file_exists(fn)) {
cli::cli_alert_info("README.md is mandatory. `altdoc` created a dummy README file in the package directory.")
cli::cli_alert_info(msg)
writeLines("Hello World!", fn)
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-setup_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ test_that("overwrite=TRUE works: mkdocs", {
txt <- readLines("altdoc/mkdocs.yml", warn = FALSE)
expect_false("Cruft" %in% txt)
})

test_that("quarto: README.qmd", {
create_local_package()
expect_false(file.exists("README.qmd"))
setup_docs("quarto_website", overwrite = TRUE)
expect_true(file.exists("README.qmd"))
})

0 comments on commit eec064e

Please sign in to comment.