Skip to content

Commit

Permalink
fix: does not require README.qmd for Quarto website
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Oct 4, 2024
1 parent 806d2b1 commit a78d9fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ License: MIT + file LICENSE
URL: https://altdoc.etiennebacher.com, https://github.com/etiennebacher/altdoc
BugReports: https://github.com/etiennebacher/altdoc/issues
Imports:
brio,
cli,
desc,
evaluate,
Expand Down
30 changes: 9 additions & 21 deletions R/import_readme.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
"md"
}

if (readme_type != "qmd" && tool == "quarto_website") {
cli::cli_abort(
"Quarto websites require a README.qmd file in the root of the package directory.",
call = NULL
)
}

src_file <- fs::path_join(
c(src_dir, grep(paste0("\\.", readme_type, "$"), readme_files, ignore.case = TRUE, value = TRUE))
)
Expand Down Expand Up @@ -67,14 +60,6 @@
"qmd" = {
pre <- fs::path_join(c(src_dir, "altdoc/preamble_vignettes_qmd.yml"))
pre <- tryCatch(.readlines(pre), warning = function(w) NULL, error = function(e) NULL)
# copy to quarto file
if (tool == "quarto_website") {
fs::file_copy(
src_file,
fs::path_join(c(tar_dir, "index.qmd")),
overwrite = TRUE
)
}
# process in-place for use on Github
# TODO: preambles inserted in the README often break Quarto websites. It's
# not a big problem to omit the preamble, but it would be good to
Expand All @@ -87,16 +72,19 @@
}
)

if (tool == "quarto_website") {
tar_file <- fs::path_join(c(tar_dir, "index.md"))
} else {
tar_file <- fs::path_join(c(tar_dir, "README.md"))
}

tar_file <- fs::path_join(c(tar_dir, "README.md"))
src_file <- fs::path_join(c(src_dir, "README.md"))
fs::file_copy(src_file, tar_file, overwrite = TRUE)
.check_md_structure(tar_file)

# Add the index page which includes README.md
if (tool == "quarto_website") {
brio::write_lines(
"{{< include README.md >}}",
fs::path_join(c(tar_dir, "index.md"))
)
}

tmp <- fs::path_join(c(src_dir, "README.markdown_strict_files"))
if (fs::dir_exists(tmp)) {
cli::cli_alert("We recommend using a `knitr` option to set the path of your images to `man/figures/README-`. This would ensure that images are properly stored and displayed on multiple platforms like CRAN, Github, and on your `altdoc` website.")
Expand Down

0 comments on commit a78d9fb

Please sign in to comment.