Skip to content

Commit cde1be8

Browse files
fix: Prefer README.md over README.qmd in Quarto websites too (#354)
1 parent 0803dd6 commit cde1be8

6 files changed

Lines changed: 38 additions & 4 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: altdoc
33
Title: Package Documentation Websites with 'Quarto', 'Docsify', 'Docute', or 'MkDocs'
4-
Version: 0.7.0
4+
Version: 0.7.0.9000
55
Authors@R:
66
c(person(given = "Etienne",
77
family = "Bacher",

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# News
22

3+
## Development version
4+
5+
### Bug fixes
6+
7+
* In 0.5.0, we announced that `README.qmd` wouldn't be automatically rendered,
8+
but this still happened when `output = "quarto_website"`. This is now fixed,
9+
meaning that `altdoc` uses `README.md` over `README.qmd` (#354).
10+
11+
* Figures stored in `man/figures` and used in the README are now properly
12+
displayed (#354).
13+
314
## 0.7.0
415

516
### New features

R/import_man.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
fs::path_join(c(tar_dir, "help", "figures")),
3838
overwrite = TRUE
3939
)
40-
fs::dir_delete(fs::path_join(c(b, "figures")))
40+
# We used to delete the old "fs::path_join(c(b, "figures"))", but
41+
# this prevented images in README to be displayed when they were
42+
# stored in "man/figures". The README is never passed to Rd2HTML(),
43+
# so the paths to the figures were never updated to "../help/figures".
4144
}
4245
}
4346

R/import_readme.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060

6161
# Add the index page which includes README.md
6262
if (tool == "quarto_website") {
63-
if ("README.qmd" %in% readme_files) {
63+
if (
64+
"README.qmd" %in% readme_files && !("README.md" %in% readme_files)
65+
) {
6466
fs::file_copy(
6567
fs::path_join(c(src_dir, "README.qmd")),
6668
fs::path_join(c(tar_dir, "index.qmd"))

tests/testthat/_snaps/docsify/render_docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
plugins: [
3030
function(hook) {
31-
var footer = ["<a > <code> testpkg.altdoc </code> v. 0.1.0 </a> | Documentation made with <a href='https://altdoc.etiennebacher.com/'> <code> altdoc </code> v. 0.7.0</a>"].join('');
31+
var footer = ["<a > <code> testpkg.altdoc </code> v. 0.1.0 </a> | Documentation made with <a href='https://altdoc.etiennebacher.com/'> <code> altdoc </code> v. 0.7.0.9000</a>"].join('');
3232

3333
hook.afterEach(function(html) {
3434
return html + footer;

tests/testthat/test-render_docs.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,24 @@ theme:
342342
)))
343343
})
344344

345+
test_that("quarto_website: ensure that README.md is preferred over README.qmd", {
346+
skip_on_cran()
347+
skip_if(.is_windows() && .on_ci(), "Windows on CI")
348+
skip_if(!.quarto_is_installed())
349+
350+
create_local_package()
351+
352+
cat("hello there", file = "README.md")
353+
cat("---hello there\nhello again", file = "README.qmd")
354+
setup_docs("quarto_website")
355+
render_docs(verbose = .on_ci())
356+
expect_false(any(grepl(
357+
"hello again",
358+
.readlines("docs/index.html"),
359+
fixed = TRUE
360+
)))
361+
})
362+
345363
test_that(".add_pkgdown() works", {
346364
skip_on_cran()
347365
skip_if(.is_windows() && .on_ci(), "Windows on CI")

0 commit comments

Comments
 (0)