Skip to content

Commit

Permalink
Merge pull request #626 from carpentries/frog-ins-notes-1
Browse files Browse the repository at this point in the history
Improve instructor notes warnings
  • Loading branch information
ErinBecker authored Dec 6, 2024
2 parents 6d995c8 + a915388 commit 74ef69f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions R/build_instructor_notes.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ build_instructor_notes <- function(pkg, pages = NULL, built = NULL, quiet) {
path <- get_source_path() %||% root_path(pkg$src_path)
lsn <- this_lesson(path)
outpath <- fs::path(pkg$dst_path, "instructor-notes.html")

instructor_notes_exists <- any(grepl("instructor-notes[.]R?md$", list.files(path=path_instructors(path))))
if (!instructor_notes_exists) {
cli::cli_alert_danger("WARNING: instructors/instructor-notes.[R]md does not exist!")
return(invisible(NULL))
}

already_built <- template_check$valid() &&
fs::file_exists(outpath) &&
!is.null(built) &&
!"instructor-notes" %in% get_slug(built)
if (!already_built) {
page_globals <- setup_page_globals()
inote <- .resources$get()[["instructors"]]
inote <- inote[get_slug(inote) == "instructor-notes"]
inote_resc <- .resources$get()[["instructors"]]
inote <- inote_resc[get_slug(inote_resc) == "instructor-notes"]
if (length(inote) == 0) {
cli::cli_alert_danger("WARNING: instructors/instructor-notes.[R]md exists but is not referenced in your config.yaml `instructors` section.")
return(invisible(NULL))
}

html <- render_html(inote)
if (html != "") {
html <- xml2::read_html(html)
Expand Down

0 comments on commit 74ef69f

Please sign in to comment.