Skip to contents

Build a list of documentation files rendered out to markdown

Usage

documentation_to_markdown(
  rdfilepaths,
  fragments = c("title", "usage", "description", "details")
)

Arguments

rdfilepaths

A character vector of Rd documentation file paths.

fragments

An optional vector of fragment tag names (such as "description", "details" or "title") to filter the Rd object tags.

Value

A named list of character vectors of length one with the markdown content. The names are dervied from the paths, see the details for more information.

Details

The function provides a vectorized way of extracting multiple documentation objects at once based on paths to the .Rd files sources. The file path will be truncated with basename, and used as a name for the output list. Use fragments parameter whenever you want to limit extracted documentation only to some parts.

See also

Examples


rd_file_example <- system.file("examples", "rd_file_sample.Rd", package = "rd2markdown")
rd_file_example_2 <- system.file("examples", "rd_file_sample_2.Rd", package = "rd2markdown")

# Extract full documentation for two files
rd2markdown::documentation_to_markdown(c(rd_file_example, rd_file_example_2))
#> $rd_file_sample.Rd
#> [1] "# Rd sampler title\n\n```r\nrd_sampler(x, y = TRUE, ...)\n```\n\n## Description\n\nRd sampler description with [Rd sampler link](www.example.com), `Rd sampler in-line code`. And Rd dynamic content, **italics text**, **emphasis text**.\n\n## Details\n\nRd sampler details\n\nRd sampler enumerated list\n\n1. One\n2. Two\n3. Three\n\nRd sampler itemized list\n\n * One\n * Two\n * Three\n\n||||\n|:--|:--|:--|\n|Rd|Sampler|Table|\n|rd|sampler|table|\n\n`Rd + sampler + inline + equation`\n\n`Rd * sampler * block * equation`"
#> 
#> $rd_file_sample_2.Rd
#> [1] "# Rd data sampler\n\n```r\nrd_data_sampler\n```\n\n## Description\n\nAn example of dataset documentation and linking to others `rnorm()`"
#> 

# Limit to particular sections
rd2markdown::documentation_to_markdown(c(rd_file_example, rd_file_example_2),
  fragments = c("details"))
#> $rd_file_sample.Rd
#> [1] "## Details\n\nRd sampler details\n\nRd sampler enumerated list\n\n1. One\n2. Two\n3. Three\n\nRd sampler itemized list\n\n * One\n * Two\n * Three\n\n||||\n|:--|:--|:--|\n|Rd|Sampler|Table|\n|rd|sampler|table|\n\n`Rd + sampler + inline + equation`\n\n`Rd * sampler * block * equation`"
#> 
#> $rd_file_sample_2.Rd
#> [1] ""
#>