Skip to content

Commit

Permalink
added extension, workshop
Browse files Browse the repository at this point in the history
  • Loading branch information
edavidaja committed Jan 19, 2024
1 parent 6dbb721 commit 38cb26f
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 2 deletions.
9 changes: 9 additions & 0 deletions _extensions/quarto-ext/include-code-files/_extension.yml
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 _extensions/quarto-ext/include-code-files/include-code-files.lua
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 }
}

4 changes: 2 additions & 2 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ project:
title: "you-should-use-renv"
type: website



filters:
- include-code-files
100 changes: 100 additions & 0 deletions workshop.qmd
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)

0 comments on commit 38cb26f

Please sign in to comment.