Title: | Create Details HTML Tag for Markdown and Package Documentation |
Version: | 0.4.0 |
Description: | Create a details HTML tag around R objects to place in a Markdown, 'Rmarkdown' and 'roxygen2' documentation. |
License: | MIT + file LICENSE |
URL: | https://github.com/yonicd/details |
BugReports: | https://github.com/yonicd/details/issues |
Depends: | R (≥ 4.2.0) |
Imports: | clipr, desc, grid, xfun, htmltools, knitr, png, stats, utils, withr, httr |
Suggests: | covr, rmarkdown, sessioninfo, testthat, tibble |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-02-09 08:56:53 UTC; yoni |
Author: | Jonathan Sidi [aut, cre] |
Maintainer: | Jonathan Sidi <yonicd@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-02-09 09:30:02 UTC |
Create HTML DOM Details
Description
Create HTML DOM Details block for Markdown documents with summary as optional.
Usage
details(
object,
...,
summary = NULL,
tooltip = "Click to Expand",
open = FALSE,
lang = "r",
output = c("console", "clipr", "edit", "character", "html"),
imgur = TRUE,
comment = NA
)
Arguments
object |
object, object to put in details block |
... |
arguments to pass to print method of the object |
summary |
character, text to put in summary block, Default: NULL |
tooltip |
character, text for tooltip on the summary, Default: 'Click to Expand' |
open |
logical, is the details open (TRUE) or closed (FALSE), Default: FALSE |
lang |
character, language of block (for markdown highlighting) Default: 'r' |
output |
character, where to output the file console (Default), clipboard or R file editor, Default: c('console','clipr','file.edit','character') |
imgur |
logical, upload device outputs to imgur, Default: TRUE |
comment |
character, the prefix to be put before source code output, Default: NA |
Details
To remove summary or tooltip set them to NULL. If the object is a file path, it will automatically it's lines will be read in internally.
If lang is 'none' then the output will not be wrapped in a code block and will display the raw output (useful for HTML)
When using details in knitr/rmarkdown documents there is no need to set the results to 'asis', there are already predefined print methods for these environments.
... is passed to objects that do not invoke an image device.
Value
character
See Also
Examples
#basic
details::details('test')
#sessionInfo
details::details(sessionInfo(), summary = 'sessionInfo')
#data.frame
details::details(head(mtcars))
#plots
details(
plot(x = mtcars$mpg, y = mtcars$wt),
summary = 'Plots', imgur = interactive())
#output options
#character
details::details('test', output = 'character')
#clipboard
if(clipr::clipr_available()){
details::details('test', output = 'clipr')
clipr::read_clip()
}
#file.edit
details::details('test', output = 'edit')
Roxygen2 Documentation Folding
Description
Insert more information to function documentation without overwhelming the user by using foldstart and foldend macros.
Usage
foldstart(title = NULL)
foldend()
Arguments
title |
Title of the folded section, Default: NULL |
Details
To enable this feature add to the DESCRIPTION
file
before rendering the roxygen2
:
Roxygen: list(markdown = TRUE)
Value
character
Examples
# With title
"#' \foldstart{This is an example}
#' DOCUMENTATION
#' \foldend"
# With no title
"#' \foldstart{}
#' DOCUMENTATION
#' \foldend"
Use details macros
Description
Call this to import the details Rd macro into your package.
The RdMacros field of the DESCRIPTION file is updated so you can use the
\\foldstart{}
and\\foldend{}
macro in your documentation.
See the Package Documentation vignette of the details package.
Usage
use_details(desc_path = "./DESCRIPTION")
Arguments
desc_path |
character, path to description file to check/edit, Default = './DESCRIPTION' |
Details
This will append three elements to the DESCRIPTION file
Suggests: details
RdMacros: details
Roxygen: list(markdown = TRUE)