Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instructor notes 505 #509

Merged
merged 9 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Authors@R: c(
family = "Michonneau",
role = c("ctb"),
email = "[email protected]"),
person(given = "Kelly",
family = "Barnes",
role = c("ctb"),
email = "[email protected]"),
person())
Description: We provide tools to build a Carpentries-themed lesson repository
into an accessible standalone static website. These include local tools and
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
version comparisons always use characters and not numbers (which is
ergonomically weird, but whatever) (reported: @zkamvar #487; fixed: @zkamvar
#487)
* Blank instructor notes pages no longer fail to build
(reported: @apirogov, #505; fixed: @klbarnes20, #509)
* Tests for {renv} post 1.0.0 fixed so that they no longer run forever
interactively (reported: @zkamvar #500; fixed: @zkamvar, #501)

Expand Down
2 changes: 2 additions & 0 deletions R/build_instructor_notes.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ build_instructor_notes <- function(pkg, pages = NULL, built = NULL, quiet) {
if (html != '') {
html <- xml2::read_html(html)
fix_nodes(html)
} else {
html <- xml2::read_html("<p></p>")
}

this_dat <- list(
Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test-build_lesson.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,36 @@ test_that("instructor-notes page can be rebuilt", {

})

test_that("empty instructor notes build", {
skip_if_not(rmarkdown::pandoc_available("2.11"))
# 0. Test that the placeholder text exists in the rendered instructor notes
build_instructor_notes(pkg, pages = htmls, quiet = TRUE)
expect_true(any(grepl(
"This is a placeholder file.",
readLines(fs::path(sitepath, "instructor-notes.html"))
)))
# 1. make a copy of the instructor-notes.md to a local tempfile (use tmp <-
# withr::local_tempfile() and fs::file_copy()
tmp <- withr::local_tempfile()
fs::file_copy(fs::path(res, "instructors/instructor-notes.md"), tmp)
# 2. use withr::defer() to do the opposite, copying over the saved file back
# when the test finishes)
withr::defer({
fs::file_copy(tmp, fs::path(res, "instructors/instructor-notes.md"), overwrite = TRUE)
}, priority = "first")
# 3. replace the instructor-notes.md with "---\ntitle: test\n---\n" using the
# writeLines() function
writeLines("---\ntitle: test\n---\n", fs::path(res, "instructors/instructor-notes.md"))
# 4. test that build_instructor_notes() builds the notes and doesn't throw an
# error.
expect_no_error(build_instructor_notes(pkg, pages = htmls, quiet = TRUE))
# 5. test for the absence of placeholder text
expect_false(any(grepl(
"This is a placeholder file.",
readLines(fs::path(sitepath, "instructor-notes.html"))
)))
})

test_that("sitemap exists", {
skip_if_not(rmarkdown::pandoc_available("2.11"))
sitemap <- fs::path(sitepath, "sitemap.xml")
Expand Down
Loading