This function is derived from knitr::spin()
for R-scripts and
is adapted to do a similar conversion of bash scripts into Rmd files.
The conversion is done in a simple way and almost no features of the
original are provided. This is just a very crude way to have a look
at documentation of a shell script in a nicer format such as html.
When specified, the generated Rmd is rendered to html using
rmarkdown::render()
.
spin_sh(
ps_sh_hair,
ps_out_rmd = paste0(basename(fs::path_ext_remove(ps_sh_hair)), ".Rmd"),
pb_knit = TRUE,
pobi_output_format = NULL,
pb_keep_rmd = FALSE
)
path to the bash scirpt
output Rmd file
flag whether generated Rmd should be rendered
desired output format passed to rmarkdown::render()
should Rmd source file be kept
s_test_script <- system.file('extdata', 'test_script.sh', package = 'qgert')
s_test_out <- file.path(tempdir(), 'test_script.Rmd')
spin_sh(ps_sh_hair = s_test_script, ps_out_rmd = s_test_out)
#>
#>
#> processing file: test_script.Rmd
#>
|
| | 0%
|
|.. | 3%
#> ordinary text without R code
#>
#>
|
|..... | 7%
#> label: unnamed-chunk-1 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|....... | 10%
#> ordinary text without R code
#>
#>
|
|.......... | 14%
#> label: unnamed-chunk-2 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|............ | 17%
#> ordinary text without R code
#>
#>
|
|.............. | 21%
#> label: unnamed-chunk-3 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|................. | 24%
#> ordinary text without R code
#>
#>
|
|................... | 28%
#> label: unnamed-chunk-4 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|...................... | 31%
#> ordinary text without R code
#>
#>
|
|........................ | 34%
#> label: unnamed-chunk-5 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|........................... | 38%
#> ordinary text without R code
#>
#>
|
|............................. | 41%
#> label: unnamed-chunk-6 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|............................... | 45%
#> ordinary text without R code
#>
#>
|
|.................................. | 48%
#> label: unnamed-chunk-7 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|.................................... | 52%
#> ordinary text without R code
#>
#>
|
|....................................... | 55%
#> label: unnamed-chunk-8 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|......................................... | 59%
#> ordinary text without R code
#>
#>
|
|........................................... | 62%
#> label: unnamed-chunk-9 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|.............................................. | 66%
#> ordinary text without R code
#>
#>
|
|................................................ | 69%
#> label: unnamed-chunk-10 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|................................................... | 72%
#> ordinary text without R code
#>
#>
|
|..................................................... | 76%
#> label: unnamed-chunk-11 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|........................................................ | 79%
#> ordinary text without R code
#>
#>
|
|.......................................................... | 83%
#> label: unnamed-chunk-12 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|............................................................ | 86%
#> ordinary text without R code
#>
#>
|
|............................................................... | 90%
#> label: unnamed-chunk-13 (with options)
#> List of 2
#> $ eval : logi FALSE
#> $ engine: chr "bash"
#>
#>
|
|................................................................. | 93%
#> ordinary text without R code
#>
#>
|
|.................................................................... | 97%
#> label: latest-update (with options)
#> List of 3
#> $ echo : logi FALSE
#> $ eval : logi TRUE
#> $ engine: chr "bash"
#>
#> running: bash -c 'date '
#>
|
|......................................................................| 100%
#> ordinary text without R code
#>
#>
#> output file: test_script.knit.md
#> /Applications/RStudio.app/Contents/MacOS/quarto/bin/pandoc +RTS -K512m -RTS test_script.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output test_script.html --lua-filter /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/mb/t7z5vr594bq1hfpqyzhmpwpr0000gp/T//RtmpIrpQh2/rmarkdown-str128b6b96d223.html
#>
#> Output created: test_script.html
unlink(s_test_out)