Skip to content

Commit

Permalink
update call to appendix functions
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanThoma committed May 3, 2024
1 parent cd8c88b commit 1cf280a
Show file tree
Hide file tree
Showing 28 changed files with 325 additions and 104 deletions.
6 changes: 4 additions & 2 deletions posts/2023-06-27__hackathon_app/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ editor:
<!--------------- my typical setup ----------------->

```{r setup, include=FALSE}
long_slug <- "2023-06-19_shiny_run_script"
long_slug <- "2023-06-27__hackathon_app"
# renv::use(lockfile = "renv.lock")
```

Expand Down Expand Up @@ -385,6 +385,8 @@ From our perspective, the application provided a great added value to the hackat
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = long_slug,
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```
6 changes: 4 additions & 2 deletions posts/2023-06-27_admiral/valuelevel/derive_param_computed.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ image: "derive_param_computed.jpg"
<!--------------- my typical setup ----------------->

```{r setup1, include=FALSE}
long_slug <- "admiral"
long_slug <- "2023-06-27_admiral"
# renv::use(lockfile = "renv.lock")
```

Expand Down Expand Up @@ -103,6 +103,8 @@ diffdf(adex_expected, adex_admiral, keys = c("USUBJID", "PARAMCD"))
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = paste0(long_slug, "/valuelevel"),
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```
6 changes: 4 additions & 2 deletions posts/2023-06-27_hackathon_writeup/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ image: "community.png"
<!--------------- my typical setup ----------------->

```{r setup, include=FALSE}
long_slug <- "2023-06-19_shiny_run_script"
long_slug <- "2023-06-27_hackathon_writeup"
# renv::use(lockfile = "renv.lock")
```

Expand Down Expand Up @@ -186,6 +186,8 @@ Please reach out to [Edoardo Mancini (product owner)](mailto:edoardo.mancini@roc
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = long_slug,
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```
6 changes: 4 additions & 2 deletions posts/2023-06-28_welcome/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ image: "pharmaverse.PNG"
<!--------------- my typical setup ----------------->

```{r setup, include=FALSE}
long_slug <- "2023-01-09_welcome"
long_slug <- "2023-06-28_welcome"
# renv::use(lockfile = "renv.lock")
```

Expand Down Expand Up @@ -81,7 +81,9 @@ Step 4: Poke us to do a review!
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = long_slug,
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```

Expand Down
4 changes: 3 additions & 1 deletion posts/2023-07-09_falcon/falcon.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ In addition, while currently all templates were built using {rtables}, {tern}, {
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = long_slug,
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```
4 changes: 3 additions & 1 deletion posts/2023-07-10_blanks_and_nas/blanks_and_nas.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ list_all_templates()
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = long_slug,
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```
4 changes: 3 additions & 1 deletion posts/2023-07-14_code_sections/code_sections.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ Code sections are an easy way to navigate long scripts and foster good commentin
source("appendix.R")
insert_appendix(
repo_spec = "pharmaverse/blog",
name = long_slug
name = long_slug,
# file_name should be the name of your file
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```

72 changes: 72 additions & 0 deletions posts/2023-07-20_cross_company_dev/appendix.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# markdown helpers --------------------------------------------------------

markdown_appendix <- function(name, content) {
paste(paste("##", name, "{.appendix}"), " ", content, sep = "\n")
}
markdown_link <- function(text, path) {
paste0("[", text, "](", path, ")")
}



# worker functions --------------------------------------------------------

insert_source <- function(repo_spec, name,
collection = "posts",
branch = "main",
host = "https://github.com",
text = "Source",
file_name) {
path <- paste(
host,
repo_spec,
"tree",
branch,
collection,
name,
file_name,
sep = "/"
)
return(markdown_link(text, path))
}

insert_timestamp <- function(tzone = Sys.timezone()) {
time <- lubridate::now(tzone = tzone)
stamp <- as.character(time, tz = tzone, usetz = TRUE)
return(stamp)
}

insert_lockfile <- function(repo_spec, name,
collection = "posts",
branch = "main",
host = "https://github.com",
text = "Session info") {
path <- path <- "https://pharmaverse.github.io/blog/session_info.html"

return(markdown_link(text, path))
}



# top level function ------------------------------------------------------

insert_appendix <- function(repo_spec, name, collection = "posts", file_name) {
appendices <- paste(
markdown_appendix(
name = "Last updated",
content = insert_timestamp()
),
" ",
markdown_appendix(
name = "Details",
content = paste(
insert_source(repo_spec, name, collection, file_name = file_name),
# get renv information,
insert_lockfile(repo_spec, name, collection),
sep = ", "
)
),
sep = "\n"
)
knitr::asis_output(appendices)
}
Loading

0 comments on commit 1cf280a

Please sign in to comment.