Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yonicd/details

R Package to Create Details HTML Tag for Markdown and Package Documentation
https://github.com/yonicd/details

html markdown r rmarkdown

Last synced: about 2 months ago
JSON representation

R Package to Create Details HTML Tag for Markdown and Package Documentation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures",
out.width = "100%"
)
```

[![CRAN status](https://www.r-pkg.org/badges/version/details)](https://CRAN.R-project.org/package=details)
[![downloads](http://cranlogs.r-pkg.org/badges/details)](https://CRAN.R-project.org/package=details)
[![R-win build status](https://github.com/yonicd/details/workflows/R-win/badge.svg)](https://github.com/yonicd/details)
[![R-mac build status](https://github.com/yonicd/details/workflows/R-mac/badge.svg)](https://github.com/yonicd/details)
[![R-linux build status](https://github.com/yonicd/details/workflows/R-linux/badge.svg)](https://github.com/yonicd/details)
[![Codecov test coverage](https://codecov.io/gh/yonicd/details/branch/master/graph/badge.svg)](https://app.codecov.io/gh/yonicd/details?branch=master)
[![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2021_01_13-yellowgreen.svg)](http://tinyurl.com/yyodcwc7)

# 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 `` tag is a great solution

```md

Summary Goes Here
...this is hidden, collapsable content...

```

Doing this manually every time is a pain.

`details` is a package lets you create and customize details blocks for [markdown](#markdown) documents and [Roxygen2](#package-documentation) documentation within `R`.

![](https://github.com/yonicd/details/raw/media/input/details.gif)

## Installation

### CRAN

``` r
install.packages("details")
```

### Dev

``` r
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](https://github.com/mdlincoln/clipr)
- [file.editor](https://stat.ethz.ch/R-manual/R-devel/library/utils/html/file.edit.html) 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.

```{r}
library(details)

sessioninfo::session_info()%>%
details::details(summary = 'current session info')
```

You can also use the `knitr` chunk engine that is shipped with `details` to created outputs in `Rmarkdown` documents.

````markdown
`r ''````{details, echo = FALSE, details.summary = 'current session info'}
sessioninfo::session_info()
```
````

```{details, echo = FALSE, details.summary = 'current session info'}
sessioninfo::session_info()
```

There are a [number of objects](https://yonicd.github.io/details/articles/objects.html) 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

```{r}
details(plot(x=mtcars$mpg,y=mtcars$wt), summary = '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)

![](https://github.com/yonicd/details/raw/media/input/folding.gif)

### Setup

To make it easy to set up the DESCRIPTION file of your package so you can use `details` macros run the following :

``` r
use_details('PATH_TO_DESCRIPTION_FILE')
```

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](https://yonicd.github.io/details/) 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](https://github.com/yonicd/details/blob/master/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.