docs generation log# looking non-recursively, only top level folder
rmd_files <- tibble(
type = "RMarkdown",
target_folder = rmd_docs_folder,
source_file = list.files(
path = ".",
pattern = sprintf("(%s)$", paste(rmd_ext, collapse = "|")))
)
nb_files <- tibble(
type = "Jupyter NB",
target_folder = nb_docs_folder,
source_file = list.files(
path = ".",
pattern = sprintf("(%s)$", paste(nb_ext, collapse = "|")))
)
docs_files <-
bind_rows(rmd_files, nb_files) %>%
mutate(
source_copy = file.path(target_folder, source_file),
source_file_hash = tools::md5sum(source_file),
doc_file = str_replace(source_copy, "\\.[^.]+$", ".html")
) %>%
# exclude template files
filter(!source_file %in% c("template.Rmd", "template.ipynb"))
# docs hash
if (file.exists(hash_file)) {
docs_hash <- read_csv(hash_file, col_types = "ccccccc")
} else {
docs_hash <- tibble(
type = character(),
source_file = character(),
source_copy = character(),
source_file_hash = character(),
doc_file = character(),
last_success = character(),
last_fail = character()
)
}
# files with hash
docs_files <-
docs_files %>%
left_join(
rename(docs_hash, existing_source_file_hash = source_file_hash),
by = c("source_file", "source_copy", "doc_file", "type")
) %>%
mutate(
# generate if
# a) the file is new
# b) the source file has changed
# c) it has failed on the last attempt
# d) it has never been succesfully generated
# e) the file does not exist although it should be there
generate =
always_regenerate |
is.na(existing_source_file_hash) |
!map2_lgl(source_file_hash, existing_source_file_hash, identical) |
!is.na(last_fail) |
is.na(last_success) |
!file.exists(doc_file)
) %>%
select(-existing_source_file_hash)
# file info
docs_files %>% select(-target_folder) %>% knitr::kable()
| type | source_file | source_copy | source_file_hash | doc_file | last_success | last_fail | generate |
|---|---|---|---|---|---|---|---|
| RMarkdown | 190208_OM19_DIC.Rmd | docs/rmarkdown/190208_OM19_DIC.Rmd | 6df306329ce4868406d23b1bece781c4 | docs/rmarkdown/190208_OM19_DIC.html | 2020-08-12 18:26:18 MDT | NA | FALSE |
| RMarkdown | 191130_OM19_CH4_dD.Rmd | docs/rmarkdown/191130_OM19_CH4_dD.Rmd | 19296f540296a8b5aac7f880619fa891 | docs/rmarkdown/191130_OM19_CH4_dD.html | 2020-08-12 19:05:50 MDT | NA | FALSE |
| RMarkdown | 191218_OM19_C1-C3-HCs_d13C.Rmd | docs/rmarkdown/191218_OM19_C1-C3-HCs_d13C.Rmd | 0dd4276a91b4766e64a06b179bd75b4d | docs/rmarkdown/191218_OM19_C1-C3-HCs_d13C.html | 2020-08-12 19:01:15 MDT | NA | FALSE |
| RMarkdown | 200813_Oman_14CH4_paper_figs.Rmd | docs/rmarkdown/200813_Oman_14CH4_paper_figs.Rmd | 76d63bec6dc1490e7889c018e85eff67 | docs/rmarkdown/200813_Oman_14CH4_paper_figs.html | 2025-09-27 17:09:14 EDT | NA | TRUE |
| RMarkdown | 200814_Oman_well_logs.Rmd | docs/rmarkdown/200814_Oman_well_logs.Rmd | fb1a981d5b4237d23914d784b07bd95f | docs/rmarkdown/200814_Oman_well_logs.html | NA | NA | TRUE |
| RMarkdown | OM19_16S_processing.Rmd | docs/rmarkdown/OM19_16S_processing.Rmd | 73c634527b310fbfacf63d4ddd896064 | docs/rmarkdown/OM19_16S_processing.html | 2020-09-18 11:26:25 MDT | NA | FALSE |
timestamp <- Sys.time() %>% format("%Y-%m-%d %H:%M:%S %Z")
# find system command
# @param cmd - can be a vector of alternative commands, will return the first valid one it finds, errors if none are valid
find_cmd <- function(cmd) {
cmds <- Sys.which(cmd)
cmds <- cmds[cmds != ""]
if (length(cmds) == 0)
stop("cannot find path to cmd '", paste(cmd, collapse = "' or '"), "'", call. = FALSE)
return(cmds[1])
}
# rendering functions return system2 captured output
render_rmd <- function(source_file, doc_file) {
# works more reliably as an external command instead of triggering from within this knit itself
cmd <- find_cmd(c("Rscript", "Rscript.exe"))
args <- sprintf("-e \"rmarkdown::render('%s', output_file = '%s', output_format = 'html_document')\"", source_file, doc_file)
suppressWarnings(system2(cmd, args = args, stdout = TRUE, stderr = TRUE))
}
render_nb <- function(source_file, target_folder) {
# does not seem to be a way to specify doc_file directly
nbconvert_arg <-
sprintf("nbconvert --to html --execute \"%s\" --output-dir \"%s\"",
source_file, target_folder)
jupyter_cmd <- find_cmd(c("jupyter", "jupyter.exe"))
if (!is.null(py_venv)) {
# not soure how to deal with this on Windows since source is a script, not an OS command...
cmd <- "source"
args <- sprintf("activate %s && %s %s", py_venv, jupyter_cmd, nbconvert_arg)
} else {
cmd <- jupyter_cmd
args <- nbconvert_arg
}
suppressWarnings(system2(cmd, args = args, stdout = TRUE, stderr = TRUE))
}
render_file <- function(generate, type, source_file, source_copy, target_folder, doc_file) {
if (!generate) {
cat("<h1>", source_file, " (NC)</h1>\n")
message("source file has not changed, docs file will not be re-generated (delete file in docs folder to force re-generation)")
return(NA)
}
# copy source file with extra md header to account for jekyll
# stripping it out when generating the github page
if (file.exists(source_copy)) file.remove(source_copy)
write("---\n---", file = source_copy)
file.append(source_copy, source_file)
# render
if (type == "RMarkdown")
out <- render_rmd(source_file = source_file, doc_file = doc_file)
else if (type == "Jupyter NB")
out <- render_nb(source_file = source_file, target_folder = target_folder)
else
stop("unknown file type ", type)
success <- is.null(attr(out, "status")) & file.exists(doc_file)
# info
if (success) cat("<h1>", source_file, " (OK)</h1>\n")
else cat("<h1>", source_file, " (ERROR)</h1>\n")
if (length(out) > 0) message(paste(out, collapse = "\n"))
# file missing message
if (!file.exists(doc_file))
message("File did not get created successfully.")
return(success)
}
# render all
rendered_doc_files <- docs_files %>%
mutate(success = pmap_lgl(
list(
generate = generate,
type = type,
source_file = source_file,
source_copy = source_copy,
target_folder = target_folder,
doc_file = doc_file
),
render_file
))
source file has not changed, docs file will not be re-generated (delete file in docs folder to force re-generation)
source file has not changed, docs file will not be re-generated (delete file in docs folder to force re-generation)
source file has not changed, docs file will not be re-generated (delete file in docs folder to force re-generation)
processing file: 200813_Oman_14CH4_paper_figs.Rmd
| | | 0% | | | 1% [setup] | | | 2% [source] | | | 3% [load-Oman-well-data] | | | 4% | | | 5% [load-lit-data] | |. | 5% | |. | 6% [load-henrys] | |. | 7% [set-plot-aesthetics] | |. | 8% [get-Oman-C1-C2-C3-data] | |. | 9% [get-lit-C1-C2-C3-data] | |. | 10% [C1_C2_C3_plot] | |. | 11% [get-alkane-d13C-data] | |. | 12% | |. | 13% [gather-alkane-d13C-data] | |. | 14% [mutate-alkane-d13C-data-site] | |. | 15% [get-alkane-d13C-lit-data] | |.. | 16% [gather-alkane-d13C-data-lit] | |.. | 17% [alkanes-d13C-oman-wells-and-lit-plot] | |.. | 18% [alkanes-d13C-oman-only-plot] | |.. | 19% | |.. | 20% [get-14CH4-data] | |.. | 21% [filter-14CH4-for-NSHQ14] | |.. | 22% [pivot-longer-14CH4-data] | |.. | 23% [pivot-longer-14CH4-data-again] | |.. | 24% [14CH4-tex] | |.. | 25% | |... | 25% [plot-CH4_F14C-d13C-dD-lab-color] | |... | 26% [plot-CH4_F14C-d13C-dD-year-color-shape] | |... | 27% | |... | 28% [plot-CH4_F14C-d13C-dD-year-color-shape-clean] | |... | 29% [plot-CH4_F14C-d13C-dD-year-color-shape-clean-letter-tagged] | |... | 30% [cor-test-d13C-Fm] | |... | 31% [lm-d13C-Fm] | |... | 32% [predict-d13C] | |... | 33% [plot-d13C-Fm-w-reg] | |... | 34% [cor-test-D-Fm] | |.... | 35% | |.... | 36% [lm-D-Fm] | |.... | 37% [predict-dD] | |.... | 38% [plot-D-Fm-w-reg] | |.... | 39% [cor-test-D-13C-w-paired-14CH4] | |.... | 40% [lm-D-13C-w-paired-14CH4] | |.... | 41% [plot-D-13C-w-reg-w-paired-14CH4] | |.... | 42% | |.... | 43% [data_CD] | |.... | 44% [data_CD_gathered] | |.... | 45% [get-CD-isotope-data-for-NSHQ14] | |..... | 45% | |..... | 46% [CD_NSHQ14_n] | |..... | 47% [cor-test-D-13C-2014-2019] | |..... | 48% [lm-D-13C-2014-2019] | |..... | 49% [plot-D-13C-w-reg-2014-2019] | |..... | 50% | |..... | 51% [unnamed-chunk-1] | |..... | 52% [data_C1_C2_C3_NSHQ14_2017_thru_2019] | |..... | 53% [join_14C_to_C1_C2_C3_data] | |..... | 54% [plot-C1_C2_C3-14CH4-NSHQ14] | |..... | 55% | |...... | 55% [conc-CH4-NSHQ14-2017] | |...... | 56% [F14C-CH4-NSHQ14-2017] | |...... | 57% [conc-modern-CH4-NSHQ14-2017] | |...... | 58% | |...... | 59% [methanogenesis-rates-Fones] | |...... | 60% [min-methanogenesis-time] | |...... | 61% [unnamed-chunk-2] | |...... | 62% [unnamed-chunk-3] | |...... | 63% [unnamed-chunk-4] | |...... | 64% [unnamed-chunk-5] | |...... | 65% | |....... | 66% [unnamed-chunk-6] | |....... | 67% [unnamed-chunk-7] | |....... | 68% [unnamed-chunk-8] | |....... | 69% [unnamed-chunk-9] | |....... | 70% [unnamed-chunk-10] | |....... | 71% [unnamed-chunk-11] | |....... | 72% [unnamed-chunk-12] | |....... | 73% | |....... | 74% [unnamed-chunk-13] | |....... | 75% [unnamed-chunk-14] | |........ | 75% | |........ | 76% [unnamed-chunk-15] | |........ | 77% [unnamed-chunk-16] | |........ | 78% [plot-ASF-NSHQ14] | |........ | 79% [plot-ASF-NSHQ14-2018] [lm-NSHQ14_C2-C6] | |........ | 80% [unnamed-chunk-17] | |........ | 81% | |........ | 82% [lm-NSHQ14_C2-C4] | |........ | 83% [unnamed-chunk-18] | |........ | 84% [plot-ASF-NSHQ14-2018-lms] | |......... | 85% [unnamed-chunk-19] | |......... | 86% [unnamed-chunk-20] | |......... | 87% [unnamed-chunk-21] | |......... | 88% | |......... | 89% [unnamed-chunk-22] | |......... | 90% [unnamed-chunk-23] | |......... | 91% [unnamed-chunk-24] | |......... | 92% [unnamed-chunk-25] | |......... | 93% [unnamed-chunk-26] | |......... | 94% [plot-ASF-Lost-City] | |......... | 95% | |..........| 95% [unnamed-chunk-27] | |..........| 96% | |..........| 97% [plot-ASF-Lost-City-NSHQ14] | |..........| 98% [lm-LCHF_C2-C4] | |..........| 99% [unnamed-chunk-28] | |..........| 100% [plot-ASF-NSHQ14-LCHF-fits]
output file: 200813_Oman_14CH4_paper_figs.knit.md
/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/pandoc +RTS -K512m -RTS 200813_Oman_14CH4_paper_figs.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output docs/rmarkdown/200813_Oman_14CH4_paper_figs.html --lua-filter /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --variable toc_print=1 --template /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --number-sections --variable theme=bootstrap --css stylesheet.css --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/pw/9fk_chms0jl85nfldy5rgfyc0000gn/T//RtmpDg2xPI/rmarkdown-str7950159ec977.html --variable code_folding=show --variable code_menu=1
Output created: docs/rmarkdown/200813_Oman_14CH4_paper_figs.html
processing file: 200814_Oman_well_logs.Rmd
| | | 0% | |. | 2% | |. | 3% [setup] | |.. | 5% | |.. | 7% [source] | |... | 9% | |... | 10% [load-data] | |.... | 12% | |.... | 14% [get-relevant-log-data-NSHQ14] | |..... | 16% | |...... | 17% [subset-and-print-log-NSHQ14] | |...... | 19% | |....... | 21% [plot-Ag-AgCl-SHE-conversion] | |....... | 22% | |........ | 24% [save-lm-Ag-AgCl-SHE] | |........ | 26% | |......... | 28% [save-lm-Ag-AgCl-SHE-slope] | |......... | 29% | |.......... | 31% [save-lm-Ag-AgCl-SHE-int] | |.......... | 33% | |........... | 34% [apply-Ag-AgCl-SHE-conversion-NSHQ14] | |............ | 36% | |............ | 38% [check-vals-20-25m] | |............. | 40% | |............. | 41% [calc-hydrostatic-P-NSHQ14] | |.............. | 43% [convert-hydrostatic-P-to-bar-NSHQ14] | |.............. | 45% | |............... | 47% [prepare-P-plot-NSHQ14] | |............... | 48% | |................ | 50% [P-plot-NSHQ14] | |................. | 52% | |................. | 53% [get-relevant-log-data-BA3A] | |.................. | 55% | |.................. | 57% [subset-and-print-log-BA3A] | |................... | 59% | |................... | 60% [apply-Ag-AgCl-SHE-conversion-BA3A] | |.................... | 62% | |.................... | 64% [calc-hydrostatic-P-BA3A] | |..................... | 66% [convert-hydrostatic-P-to-bar-BA3A] | |...................... | 67% | |...................... | 69% [prepare-P-plot-BA3A] | |....................... | 71% | |....................... | 72% [P-plot-BA3A] | |........................ | 74% | |........................ | 76% [geotherm-NSHQ14-full] | |......................... | 78% | |......................... | 79% [geotherm-NSHQ14-below-100m] | |.......................... | 81% | |.......................... | 83% [lm-T-d-NSHQ14-below-100m] | |........................... | 84% | |............................ | 86% [lm-T-d-NSHQ14-below-100m_inv] | |............................ | 88% | |............................. | 90% [T_lim_life] | |............................. | 91% | |.............................. | 93% [geotherm-BA3A-full] | |.............................. | 95% | |............................... | 97% [geotherm-BA3A-below-100m] | |............................... | 98% | |................................| 100% [lm-T-d-BA3A-below-100m]
output file: 200814_Oman_well_logs.knit.md
/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/pandoc +RTS -K512m -RTS 200814_Oman_well_logs.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output docs/rmarkdown/200814_Oman_well_logs.html --lua-filter /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --template /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/pw/9fk_chms0jl85nfldy5rgfyc0000gn/T//RtmpSWdBrQ/rmarkdown-str7a8c16434679.html
Output created: docs/rmarkdown/200814_Oman_well_logs.html
Warning messages:
1: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
conversion failure on '˚C' in 'mbcsToSbcs': for ˚ (U+02DA)
2: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
conversion failure on '˚C' in 'mbcsToSbcs': for ˚ (U+02DA)
3: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
conversion failure on '˚C' in 'mbcsToSbcs': for ˚ (U+02DA)
4: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
conversion failure on '˚C' in 'mbcsToSbcs': for ˚ (U+02DA)
source file has not changed, docs file will not be re-generated (delete file in docs folder to force re-generation)
summary <- rendered_doc_files %>%
mutate(
last_success = case_when(
generate & success ~ timestamp,
TRUE ~ last_success),
last_fail = case_when(
generate & success ~ NA_character_,
generate & !success ~ timestamp,
TRUE ~ last_fail)
) %>%
select(-target_folder)
write_csv(select(summary, -generate, -success), path = hash_file)
Warning: The `path` argument of `write_csv()` is deprecated as of readr 1.4.0.
ℹ Please use the `file` argument instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.
summary %>% knitr::kable()
| type | source_file | source_copy | source_file_hash | doc_file | last_success | last_fail | generate | success |
|---|---|---|---|---|---|---|---|---|
| RMarkdown | 190208_OM19_DIC.Rmd | docs/rmarkdown/190208_OM19_DIC.Rmd | 6df306329ce4868406d23b1bece781c4 | docs/rmarkdown/190208_OM19_DIC.html | 2020-08-12 18:26:18 MDT | NA | FALSE | NA |
| RMarkdown | 191130_OM19_CH4_dD.Rmd | docs/rmarkdown/191130_OM19_CH4_dD.Rmd | 19296f540296a8b5aac7f880619fa891 | docs/rmarkdown/191130_OM19_CH4_dD.html | 2020-08-12 19:05:50 MDT | NA | FALSE | NA |
| RMarkdown | 191218_OM19_C1-C3-HCs_d13C.Rmd | docs/rmarkdown/191218_OM19_C1-C3-HCs_d13C.Rmd | 0dd4276a91b4766e64a06b179bd75b4d | docs/rmarkdown/191218_OM19_C1-C3-HCs_d13C.html | 2020-08-12 19:01:15 MDT | NA | FALSE | NA |
| RMarkdown | 200813_Oman_14CH4_paper_figs.Rmd | docs/rmarkdown/200813_Oman_14CH4_paper_figs.Rmd | 76d63bec6dc1490e7889c018e85eff67 | docs/rmarkdown/200813_Oman_14CH4_paper_figs.html | 2025-09-30 13:00:29 EDT | NA | TRUE | TRUE |
| RMarkdown | 200814_Oman_well_logs.Rmd | docs/rmarkdown/200814_Oman_well_logs.Rmd | fb1a981d5b4237d23914d784b07bd95f | docs/rmarkdown/200814_Oman_well_logs.html | 2025-09-30 13:00:29 EDT | NA | TRUE | TRUE |
| RMarkdown | OM19_16S_processing.Rmd | docs/rmarkdown/OM19_16S_processing.Rmd | 73c634527b310fbfacf63d4ddd896064 | docs/rmarkdown/OM19_16S_processing.html | 2020-09-18 11:26:25 MDT | NA | FALSE | NA |
if (any(summary$generate) || !file.exists(file.path(docs_folder, "index.html"))) {
out <- render_rmd(
source_file = file.path(docs_folder, "index.Rmd"),
doc_file = file.path("index.html")
)
success <- is.null(attr(out, "status"))
if (success)
message("index updated successfully")
else
message("something went wrong updating the index, please render index.Rmd manually")
} else {
message("No files (re)generated, index stays the same.")
}
index updated successfully