-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
63 changes: 63 additions & 0 deletions
63
_extensions/quarto-ext/include-code-files/include-code-files.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ project: | |
title: "you-should-use-renv" | ||
type: website | ||
|
||
|
||
|
||
filters: | ||
- include-code-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <br/> should <br/> use <br/> 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) |