Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #58 fixed appendix #152

Merged
merged 18 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
xportr
pharmaverseadam
link

sessioninfo


- name: Install tinytex
run: quarto install tool tinytex
Expand Down
10 changes: 5 additions & 5 deletions R/appendix.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

# markdown helpers --------------------------------------------------------

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

Expand Down Expand Up @@ -57,7 +58,7 @@ insert_lockfile <- function(repo_spec, name,

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

insert_appendix <- function(repo_spec, name, collection = "posts") {
insert_appendix <- function (repo_spec, name, collection = "posts") {
appendices <- paste(
markdown_appendix(
name = "Last updated",
Expand All @@ -69,8 +70,7 @@ insert_appendix <- function(repo_spec, name, collection = "posts") {
content = paste(
insert_source(repo_spec, name, collection),
insert_lockfile(repo_spec, name, collection),
sep = ", "
)
sep = ", ")
),
sep = "\n"
)
Expand Down
2 changes: 2 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ website:
- icon: github
aria-label: github
href: https://github.com/pharmaverse/blog
- text: "Session Info"
href: session_info.html
format:
html:
theme:
Expand Down
4 changes: 2 additions & 2 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ posts <- list.dirs(
)

# extract the slugs
slugs <- gsub("^.*_", "", posts)
slugs <- sub(".*?_", "", posts)

# lines to insert to a netlify _redirect file
post_redirects <- paste0("/", slugs, " ", "/posts/", posts)

# function to extract post categories from index.qmd files
get_post_categories <- function(post) {
file <- here::here("posts", post) |> fs::path("index.qmd")
file <- here::here("posts", post) |> list.files(pattern = ".qmd", full.names = TRUE)
if (!fs::file_exists(file)) {
return(character(0))
}
Expand Down
25 changes: 11 additions & 14 deletions posts/2023-10-30_floating_point/appendix.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@ insert_source <- function(repo_spec, name,
collection = "posts",
branch = "main",
host = "https://github.com",
text = "source code") {
path <- paste(
host,
repo_spec,
"tree",
branch,
collection,
name,
"code_sections.qmd",
sep = "/"
)
text = "Session info",
file_name) {
path <- "https://pharmaverse.github.io/blog/_site/session_info.html"
return(markdown_link(text, path))
}

Expand All @@ -47,7 +39,7 @@ insert_lockfile <- function(repo_spec, name,
branch,
collection,
name,
"renv.lock",
"session_info.txt",
sep = "/"
)
return(markdown_link(text, path))
Expand All @@ -57,7 +49,11 @@ insert_lockfile <- function(repo_spec, name,

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

insert_appendix <- function(repo_spec, name, collection = "posts") {
insert_appendix <- function(repo_spec, name, collection = "posts", file_name) {
# write session info to txt
session_info <- sessionInfo()
writeLines(capture.output(session_info), con = "session_info.txt")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure this overwrites!


appendices <- paste(
markdown_appendix(
name = "Last updated",
Expand All @@ -67,7 +63,8 @@ insert_appendix <- function(repo_spec, name, collection = "posts") {
markdown_appendix(
name = "Details",
content = paste(
insert_source(repo_spec, name, collection),
insert_source(repo_spec, name, collection, file_name = file_name),
# get renv information,
insert_lockfile(repo_spec, name, collection),
sep = ", "
)
Expand Down
4 changes: 3 additions & 1 deletion posts/2023-10-30_floating_point/floating_point.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ I.e. `.Machine$double.eps / 1.8` is still detectable, while `.Machine$double.eps
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()
)
```
25 changes: 25 additions & 0 deletions posts/2023-10-30_floating_point/session_info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8
[8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices datasets utils methods base

other attached packages:
[1] dplyr_1.1.3

loaded via a namespace (and not attached):
[1] utf8_1.2.3 R6_2.5.1 lubridate_1.9.3 tidyselect_1.2.0 xfun_0.40 magrittr_2.0.3 glue_1.6.2 stringr_1.5.0 tibble_3.2.1 knitr_1.44 pkgconfig_2.0.3
[12] timechange_0.2.0 generics_0.1.3 lifecycle_1.0.3 cli_3.6.1 fansi_1.0.5 sessioninfo_1.2.2 vctrs_0.6.3 renv_1.0.3 compiler_4.3.1 rprojroot_2.0.3 here_1.0.1
[23] purrr_1.0.2 rstudioapi_0.15.0 tools_4.3.1 pillar_1.9.0 yaml_2.3.7 rlang_1.1.1 fs_1.6.3 stringi_1.7.12
9 changes: 9 additions & 0 deletions session_info.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Session Info"
description: "This page displays the session information for the site."
---

```{r}
library(sessioninfo)
session_info()
```
Loading