Suppose you’re opening an issue in GitHub and there’s a lot noisey logs that may be useful or you want to add the sessionInfo()
to the end of the issue.
Rather than wrecking readability, wrapping it in a <details>
tag is a great solution
<details>
<summary>Summary Goes Here</summary>
...this is hidden, collapsable content...
</details>
Doing this manually every time is a pain.
details
is a package lets you create and customize details blocks for markdown documents and Roxygen2 documentation within R
.
Markdown
Examples
One the most popular uses for details
is to paste the sessioninfo at the bottom of a GitHub issue.
current session info
``` r
─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 3.6.3 (2020-02-29)
os macOS Catalina 10.15.7
system x86_64, darwin15.6.0
ui X11
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz UTC
date 2021-01-14
─ Packages ───────────────────────────────────────────────────────────────────
package * version date lib
assertthat 0.2.1 2019-03-21 [1]
callr 3.5.1 2020-10-13 [1]
cli 2.2.0 2020-11-20 [1]
clipr 0.7.1 2020-10-08 [1]
covr * 3.3.2 2021-01-14 [1]
covrpage 0.1 2021-01-14 [1]
crayon 1.3.4 2017-09-16 [1]
curl 4.3 2019-12-02 [1]
desc 1.2.0 2018-05-01 [1]
details * 0.2.2 2021-01-14 [1]
diffobj 0.3.3 2021-01-07 [1]
digest 0.6.27 2020-10-24 [1]
ellipsis 0.3.1 2020-05-15 [1]
evaluate 0.14 2019-05-28 [1]
fansi 0.4.1 2020-01-08 [1]
git2r 0.28.0 2021-01-10 [1]
glue 1.4.2 2020-08-27 [1]
highr 0.8 2019-03-20 [1]
htmltools 0.5.1 2021-01-12 [1]
httr 1.4.2 2020-07-20 [1]
knitr * 1.30 2020-09-22 [1]
lazyeval 0.2.2 2019-03-15 [1]
lifecycle 0.2.0 2020-03-06 [1]
magrittr * 2.0.1 2020-11-17 [1]
mime 0.9 2020-02-04 [1]
pillar 1.4.7 2020-11-20 [1]
pkgbuild 1.2.0 2020-12-15 [1]
pkgconfig 2.0.3 2019-09-22 [1]
png 0.1-7 2013-12-03 [1]
prettyunits 1.1.1 2020-01-24 [1]
processx 3.4.5 2020-11-30 [1]
ps 1.5.0 2020-12-05 [1]
R6 2.5.0 2020-10-28 [1]
rematch2 2.1.2 2020-05-01 [1]
remotes 2.2.0 2020-07-21 [1]
rex 1.2.0 2020-04-21 [1]
rlang 0.4.10 2020-12-30 [1]
rmarkdown 2.6 2020-12-14 [1]
rprojroot 2.0.2 2020-11-15 [1]
rstudioapi 0.13 2020-11-12 [1]
sessioninfo 1.1.1 2018-11-05 [1]
stringi 1.5.3 2020-09-09 [1]
stringr 1.4.0 2019-02-10 [1]
testthat * 3.0.1 2020-12-17 [1]
tibble 3.0.4 2020-10-12 [1]
vctrs 0.3.6 2020-12-17 [1]
waldo 0.2.3 2020-11-09 [1]
whisker 0.4 2019-08-28 [1]
withr 2.3.0 2020-09-22 [1]
xfun 0.20 2021-01-06 [1]
xml2 1.3.2 2020-04-23 [1]
yaml 2.2.1 2020-02-01 [1]
source
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
Github (r-lib/covr@79a5625)
Github (metrumresearchgroup/covrpage@ce8579a)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
local
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
[1] /Users/runner/work/_temp/Library
[2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
```
You can also use the knitr
chunk engine that is shipped with details
to created outputs in Rmarkdown
documents.
```{details, echo = FALSE, details.summary = 'current session info'}
sessioninfo::session_info()
```
current session info
``` r
─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 3.6.3 (2020-02-29)
os macOS Catalina 10.15.7
system x86_64, darwin15.6.0
ui X11
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz UTC
date 2021-01-14
─ Packages ───────────────────────────────────────────────────────────────────
package * version date lib
assertthat 0.2.1 2019-03-21 [1]
callr 3.5.1 2020-10-13 [1]
cli 2.2.0 2020-11-20 [1]
clipr 0.7.1 2020-10-08 [1]
covr * 3.3.2 2021-01-14 [1]
covrpage 0.1 2021-01-14 [1]
crayon 1.3.4 2017-09-16 [1]
curl 4.3 2019-12-02 [1]
desc 1.2.0 2018-05-01 [1]
details * 0.2.2 2021-01-14 [1]
diffobj 0.3.3 2021-01-07 [1]
digest 0.6.27 2020-10-24 [1]
ellipsis 0.3.1 2020-05-15 [1]
evaluate 0.14 2019-05-28 [1]
fansi 0.4.1 2020-01-08 [1]
git2r 0.28.0 2021-01-10 [1]
glue 1.4.2 2020-08-27 [1]
highr 0.8 2019-03-20 [1]
htmltools 0.5.1 2021-01-12 [1]
httr 1.4.2 2020-07-20 [1]
knitr * 1.30 2020-09-22 [1]
lazyeval 0.2.2 2019-03-15 [1]
lifecycle 0.2.0 2020-03-06 [1]
magrittr * 2.0.1 2020-11-17 [1]
mime 0.9 2020-02-04 [1]
pillar 1.4.7 2020-11-20 [1]
pkgbuild 1.2.0 2020-12-15 [1]
pkgconfig 2.0.3 2019-09-22 [1]
png 0.1-7 2013-12-03 [1]
prettyunits 1.1.1 2020-01-24 [1]
processx 3.4.5 2020-11-30 [1]
ps 1.5.0 2020-12-05 [1]
R6 2.5.0 2020-10-28 [1]
rematch2 2.1.2 2020-05-01 [1]
remotes 2.2.0 2020-07-21 [1]
rex 1.2.0 2020-04-21 [1]
rlang 0.4.10 2020-12-30 [1]
rmarkdown 2.6 2020-12-14 [1]
rprojroot 2.0.2 2020-11-15 [1]
rstudioapi 0.13 2020-11-12 [1]
sessioninfo 1.1.1 2018-11-05 [1]
stringi 1.5.3 2020-09-09 [1]
stringr 1.4.0 2019-02-10 [1]
testthat * 3.0.1 2020-12-17 [1]
tibble 3.0.4 2020-10-12 [1]
vctrs 0.3.6 2020-12-17 [1]
waldo 0.2.3 2020-11-09 [1]
whisker 0.4 2019-08-28 [1]
withr 2.3.0 2020-09-22 [1]
xfun 0.20 2021-01-06 [1]
xml2 1.3.2 2020-04-23 [1]
yaml 2.2.1 2020-02-01 [1]
source
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
Github (r-lib/covr@79a5625)
Github (metrumresearchgroup/covrpage@ce8579a)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
local
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.2)
CRAN (R 3.6.0)
[1] /Users/runner/work/_temp/Library
[2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
```
There are a number of objects that can be placed in a details block other than a character object. An example of a object is a device output such as a plot
details (plot (x= mtcars$ mpg,y= mtcars$ wt), summary = 'My plot' )
My plot
![](https://i.imgur.com/Q8o6VIQ.png)
Package Documentation
Many times in documentation there is a lot to say, but you do not want to overwhelm the user.
To solve this we can use folding blocks in the documentation (which are then rendered into pkgdown website automatically)
Setup
To make it easy to set up the DESCRIPTION file of your package so you can use details
macros run the following :
This will append three elements to the DESCRIPTION file
Imports: details
RdMacros: details
Roxygen: list(markdown = TRUE)
Usage
You can use this feature by wrapping documentation with the macros
\foldstart{[SUMMARY TEXT]}
#' DOCUMENTATION
#' ...
#' DOCUMENTATION
\foldend
The SUMMARY_TEXT
is optional, where the folded block will have a header of SUMMARY TEXT .
The default will display details .
These folded blocks can be inserted anywhere in the documentation, eg @description
, @param
, @details
, @return
, ….
Vignettes
More information can be found in the articles of the package site.
Creating a sessioninfo to paste into Github, Stackoverflow or Community Sites.
Customizing the details output
What R objects details can handle
Using the details knitr chunk engine
Using details in Roxygen2
Code of Conduct
Please note that the ‘details’ project is released with a Contributor Code of Conduct . By contributing to this project, you agree to abide by its terms.