diff --git a/_extensions/quarto-ext/include-code-files/_extension.yml b/_extensions/quarto-ext/include-code-files/_extension.yml new file mode 100644 index 0000000..13c4960 --- /dev/null +++ b/_extensions/quarto-ext/include-code-files/_extension.yml @@ -0,0 +1,9 @@ +title: Include Code Files +author: Bruno Beaufils +version: 1.0.0 +quarto-required: ">=1.2" +contributes: + filters: + - include-code-files.lua + + diff --git a/_extensions/quarto-ext/include-code-files/include-code-files.lua b/_extensions/quarto-ext/include-code-files/include-code-files.lua new file mode 100644 index 0000000..c5f5cbf --- /dev/null +++ b/_extensions/quarto-ext/include-code-files/include-code-files.lua @@ -0,0 +1,63 @@ +--- include-code-files.lua – filter to include code from source files +--- +--- Copyright: © 2020 Bruno BEAUFILS +--- License: MIT – see LICENSE file for details + +--- Dedent a line +local function dedent (line, n) + return line:sub(1,n):gsub(" ","") .. line:sub(n+1) +end + +--- Filter function for code blocks +local function transclude (cb) + if cb.attributes.include then + local content = "" + local fh = io.open(cb.attributes.include) + if not fh then + io.stderr:write("Cannot open file " .. cb.attributes.include .. " | Skipping includes\n") + else + local number = 1 + local start = 1 + + -- change hyphenated attributes to PascalCase + for i,pascal in pairs({"startLine", "endLine"}) + do + local hyphen = pascal:gsub("%u", "-%0"):lower() + if cb.attributes[hyphen] then + cb.attributes[pascal] = cb.attributes[hyphen] + cb.attributes[hyphen] = nil + end + end + + if cb.attributes.startLine then + cb.attributes.startFrom = cb.attributes.startLine + start = tonumber(cb.attributes.startLine) + end + for line in fh:lines ("L") + do + if cb.attributes.dedent then + line = dedent(line, cb.attributes.dedent) + end + if number >= start then + if not cb.attributes.endLine or number <= tonumber(cb.attributes.endLine) then + content = content .. line + end + end + number = number + 1 + end + fh:close() + end + -- remove key-value pair for used keys + cb.attributes.include = nil + cb.attributes.startLine = nil + cb.attributes.endLine = nil + cb.attributes.dedent = nil + -- return final code block + return pandoc.CodeBlock(content, cb.attr) + end +end + +return { + { CodeBlock = transclude } +} + diff --git a/_quarto.yml b/_quarto.yml index 5474afb..a8fc0c9 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -2,5 +2,5 @@ project: title: "you-should-use-renv" type: website - - +filters: + - include-code-files diff --git a/workshop.qmd b/workshop.qmd new file mode 100644 index 0000000..497b941 --- /dev/null +++ b/workshop.qmd @@ -0,0 +1,100 @@ +--- +format: + revealjs: + transition: fade + theme: night + mermaid-format: svg + navigation-mode: linear + controls: false +from: markdown+emoji +--- + +# {background-image="images/julia-joppien-XFUqd0u5U7w-unsplash.jpg"} + +::: columns +::: {.column width="30%"} +::: {.r-fit-text color="white"} +You
should
use
renv. +::: +::: + +::: {.column width="70%"} +::: +::: + +::: fragment +workshop +::: + +# agenda + +::: columns + +::: {.column width="50%"} +::: {.r-fit-text .fragment} +why +::: +::: + + +::: {.column width="50%"} +::: {.r-fit-text .fragment} +how +::: +::: + +::: + +# why + +## sermon + +[you should use renv.](https://www.youtube.com/watch?v=GwVx_pf2uz4) + +## commandment + +_projects_ should be _reproducible._ + +::: notes +projects, for the purpose of this workshop, are anything you want to share that isn't an R package--shiny app, plumber API, quarto doc +reproducibility is a [layered, spectral](https://ropensci-archive.github.io/reproducibility-guide/sections/introduction/) concept rather than a binary +the goal is for the project to be reproducible to the maximum extent possible +::: + +# how + +## [on repositories](https://rstudio.github.io/renv/articles/package-sources.html#custom-r-package-repositories) + +```bash +> options("repos") +$repos + CRAN +"https://packagemanager.posit.co/cran/latest" +``` + +::: notes +renv will +::: + +## fetch examples + +```{.r} +usethis::use_zip("https://gitlab.com/edavidaja/renv-workshop/-/archive/main/renv-workshop-main.zip") +``` +or + +```bash +git clone https://gitlab.com/edavidaja/renv-workshop +``` + +## new project + +## existing project + +## old project + +[an old shiny app](https://github.com/edavidaja/clippers) + +## R version migration + +[rig](https://github.com/r-lib/rig) \ No newline at end of file