Skip to content

Commit 6ff5f40

Browse files
committed
added session info and fixed link to source
1 parent b9a3ff3 commit 6ff5f40

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

R/appendix.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
12
# markdown helpers --------------------------------------------------------
23

3-
markdown_appendix <- function(name, content) {
4+
markdown_appendix <- function (name, content) {
45
paste(paste("##", name, "{.appendix}"), " ", content, sep = "\n")
56
}
6-
markdown_link <- function(text, path) {
7+
markdown_link <- function (text, path) {
78
paste0("[", text, "](", path, ")")
89
}
910

@@ -57,7 +58,7 @@ insert_lockfile <- function(repo_spec, name,
5758

5859
# top level function ------------------------------------------------------
5960

60-
insert_appendix <- function(repo_spec, name, collection = "posts") {
61+
insert_appendix <- function (repo_spec, name, collection = "posts") {
6162
appendices <- paste(
6263
markdown_appendix(
6364
name = "Last updated",
@@ -69,8 +70,7 @@ insert_appendix <- function(repo_spec, name, collection = "posts") {
6970
content = paste(
7071
insert_source(repo_spec, name, collection),
7172
insert_lockfile(repo_spec, name, collection),
72-
sep = ", "
73-
)
73+
sep = ", ")
7474
),
7575
sep = "\n"
7676
)

posts/2023-10-30_floating_point/appendix.R

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ insert_source <- function(repo_spec, name,
1515
collection = "posts",
1616
branch = "main",
1717
host = "https://github.com",
18-
text = "source code") {
18+
text = "source code",
19+
file_name) {
1920
path <- paste(
2021
host,
2122
repo_spec,
2223
"tree",
2324
branch,
2425
collection,
2526
name,
26-
"code_sections.qmd",
27+
file_name,
2728
sep = "/"
2829
)
2930
return(markdown_link(text, path))
@@ -47,7 +48,7 @@ insert_lockfile <- function(repo_spec, name,
4748
branch,
4849
collection,
4950
name,
50-
"renv.lock",
51+
"session_info.txt",
5152
sep = "/"
5253
)
5354
return(markdown_link(text, path))
@@ -57,7 +58,11 @@ insert_lockfile <- function(repo_spec, name,
5758

5859
# top level function ------------------------------------------------------
5960

60-
insert_appendix <- function(repo_spec, name, collection = "posts") {
61+
insert_appendix <- function(repo_spec, name, collection = "posts", file_name) {
62+
# write session info to txt
63+
session_info <- sessionInfo()
64+
writeLines(capture.output(session_info), con = "session_info.txt")
65+
6166
appendices <- paste(
6267
markdown_appendix(
6368
name = "Last updated",
@@ -67,7 +72,8 @@ insert_appendix <- function(repo_spec, name, collection = "posts") {
6772
markdown_appendix(
6873
name = "Details",
6974
content = paste(
70-
insert_source(repo_spec, name, collection),
75+
insert_source(repo_spec, name, collection, file_name = file_name),
76+
# get renv information,
7177
insert_lockfile(repo_spec, name, collection),
7278
sep = ", "
7379
)

posts/2023-10-30_floating_point/floating_point.qmd

+3-1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ I.e. `.Machine$double.eps / 1.8` is still detectable, while `.Machine$double.eps
353353
source("appendix.R")
354354
insert_appendix(
355355
repo_spec = "pharmaverse/blog",
356-
name = long_slug
356+
name = long_slug,
357+
# file_name should be the name of your file
358+
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
357359
)
358360
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
R version 4.3.0 (2023-04-21)
2+
Platform: aarch64-apple-darwin20 (64-bit)
3+
Running under: macOS 14.3.1
4+
5+
Matrix products: default
6+
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
7+
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
8+
9+
locale:
10+
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
11+
12+
time zone: Europe/Zurich
13+
tzcode source: internal
14+
15+
attached base packages:
16+
[1] stats graphics grDevices utils datasets methods base
17+
18+
other attached packages:
19+
[1] reactable_0.4.4 dplyr_1.1.4 admiral_0.12.2
20+
21+
loaded via a namespace (and not attached):
22+
[1] jsonlite_1.8.7 compiler_4.3.0 tidyselect_1.2.1
23+
[4] stringr_1.5.1 tidyr_1.3.1 yaml_2.3.7
24+
[7] fastmap_1.1.1 R6_2.5.1 generics_0.1.3
25+
[10] admiraldev_1.0.0.9020 knitr_1.42 htmlwidgets_1.6.2
26+
[13] tibble_3.2.1 lubridate_1.9.3 pillar_1.9.0
27+
[16] rlang_1.1.3 utf8_1.2.4 stringi_1.8.3
28+
[19] reactR_0.5.0 xfun_0.39 timechange_0.3.0
29+
[22] cli_3.6.2 withr_3.0.0 magrittr_2.0.3
30+
[25] crosstalk_1.2.0 digest_0.6.33 rstudioapi_0.14
31+
[28] hms_1.1.3 lifecycle_1.0.4 vctrs_0.6.5
32+
[31] evaluate_0.21 glue_1.7.0 fansi_1.0.6
33+
[34] rmarkdown_2.21 purrr_1.0.2 tools_4.3.0
34+
[37] pkgconfig_2.0.3 ellipsis_0.3.2 htmltools_0.5.5

0 commit comments

Comments
 (0)