Skip to content
R Package to Create Details HTML Tag for Markdown and Package Documentation
R
Branch: master
Clone or download
Latest commit dfc37e4 Sep 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R add: add check for blank png (windows) Sep 10, 2019
input add pkgdown logo [skip ci] Sep 9, 2019
man refactor: use internal env to control device flag Sep 9, 2019
tests docs: add code of conduct to readme Sep 10, 2019
vignettes docs: add code of conduct to readme Sep 10, 2019
.Rbuildignore docs: add code of conduct to readme Sep 10, 2019
.gitignore add travis,covr,covrpage Sep 4, 2019
.travis.yml docs: remove knitr and replace with xml2 and httr Sep 9, 2019
CODE_OF_CONDUCT.md docs: add code of conduct to readme Sep 10, 2019
DESCRIPTION doc: bump version for CRAN submission Sep 10, 2019
LICENSE init commit Mar 13, 2019
LICENSE.md init commit Mar 13, 2019
NAMESPACE add: add check for blank png (windows) Sep 10, 2019
NEWS.md add NEWS.md file Sep 10, 2019
README.Rmd
README.md docs: add code of conduct to readme Sep 10, 2019
_pkgdown.yml add gif links to readme Sep 10, 2019
appveyor.yml add appveyor [skip travis] Sep 10, 2019
codecov.yml add travis,covr,covrpage Sep 4, 2019
cran-comments.md update cran comments [skip ci] Sep 10, 2019

README.md

Travis build status AppVeyor build status Codecov test coverage Covrpage Summary

details

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.

Installation

remotes::install_github("yonicd/details")

Markdown

Input

The function details::details can handle inputs

  • R object with supported classes:
    • character
    • data.frame
    • tibble
    • list
    • device (eg plots)
  • File paths will be identified internally and the lines will be read in automatically.

Output

The function details::details can output the result to

  • console (default)
  • clipboard via clipr
  • file.editor useful when clipr not available

Examples

One the most popular uses for details is to paste the sessioninfo at the bottom of a GitHub issue.

library(details)

sessioninfo::session_info()%>%
  details::details(summary = 'current session info')
current session info
Session info ──────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.1 (2019-07-05)
 os       macOS Mojave 10.14.5        
 system   x86_64, darwin15.6.0        
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2019-09-10Packages ──────────────────────────────────────────────────────────────
 package     * version    date       lib
 assertthat    0.2.1      2019-03-21 [1]
 cli           1.1.0      2019-03-19 [1]
 clipr         0.7.0      2019-07-23 [1]
 crayon        1.3.4      2017-09-16 [1]
 details     * 0.0.9      2019-09-10 [1]
 digest        0.6.20     2019-07-04 [1]
 evaluate      0.14       2019-05-28 [1]
 htmltools     0.3.6.9004 2019-09-08 [1]
 httr          1.4.1      2019-08-05 [1]
 knitr         1.23       2019-05-18 [1]
 magrittr      1.5        2014-11-22 [1]
 png           0.1-7      2013-12-03 [1]
 R6            2.4.0      2019-02-14 [1]
 Rcpp          1.0.2      2019-07-25 [1]
 rlang         0.4.0      2019-06-25 [1]
 rmarkdown     1.14       2019-07-12 [1]
 sessioninfo   1.1.1      2018-11-05 [1]
 stringi       1.4.3      2019-03-12 [1]
 stringr       1.4.0      2019-02-10 [1]
 withr         2.1.2      2018-03-15 [1]
 xfun          0.8        2019-06-25 [1]
 xml2          1.2.2      2019-08-09 [1]
 yaml          2.2.0      2018-07-25 [1]
 source                            
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 local                             
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 Github (rstudio/htmltools@840d786)
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    
 CRAN (R 3.6.0)                    

[1] /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


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)

To enable this feature add Roxygen: list(markdown = TRUE) to the DESCRIPTION file before rendering the roxygen2

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 your 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 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.

You can’t perform that action at this time.