Package 'Rd2md'

Title: Markdown Reference Manuals
Description: Native R only allows PDF exports of reference manuals. The 'Rd2md' package converts the package documentation files into markdown files and combines them into a markdown version of the package reference manual.
Authors: Julian Busch [aut, cre]
Maintainer: Julian Busch <[email protected]>
License: GPL
Version: 1.0.1
Built: 2025-02-12 04:11:25 UTC
Source: https://github.com/quantsch/rd2md

Help Index


Reference Manual in Markdown

Description

Functions to parse and convert Rd files to markdown format reference manual.

Author(s)

Julian Busch [email protected]

See Also

knitr


Parse into Markdown

Description

S3 Methods to parse different classes into Markdown.

Usage

as_markdown(x, ...)

Arguments

x

Object

...

Further arguments passed to methods


Output Format Markdown

Description

Specifies markdown output format parameters.

Usage

md_document(
  file_ext = ".md",
  section_level = 1,
  date_format = "%F",
  toc = FALSE
)

Arguments

file_ext

File extension, if default output_file name

section_level

Initial section level, subsection level n will consequently be section_level + n

date_format

See format argument of base::strptime()

toc

Currently not implemented. If table of contents should be included in reference manual.


Output Format Definition

Description

Specifies output format parameters.

Usage

output_format(output_class_suffix, file_ext, parse_fun, ...)

Arguments

output_class_suffix

Suffix to class name. E.g. md for output_format_md.

file_ext

File extension, if default output_file name.

parse_fun

Parsing function, should be a generic S3 method.

...

Named arguments inserted into list structure output and eventually passed as arguments to parse_fun.


Translate an Rd string to markdown

Description

Note that this will always end in one newline \n.

Usage

rd_str_to_md(x, fragment = TRUE, ...)

Arguments

x

Rd string. Backslashes must be double-escaped ("\\").

fragment

logical indicating whether this represents a complete Rd file

...

additional arguments for as_markdown

Examples

rd_str_to_md("a\n%b\nc")

rd_str_to_md("a & b")

rd_str_to_md("\\strong{\\emph{x}}")

rd_str_to_md("\\enumerate{\\item test 1\n\n\\item test 2}")
rd_str_to_md("wrapped \\itemize{\\item test 1\n\\item test 2} in text")

Read .Rd file

Description

And return object of class rdfile

Usage

read_rdfile(path, subclass = NULL)

Arguments

path

File path of ⁠*.Rd⁠-file

subclass

Potential subclass of returned rdfile object


Create Markdown Reference Manual

Description

This is a wrapper to combine the Rd files of a package source or binary into a reference manual in markdown format.

Usage

render_refman(pkg = getwd(), output_file = NULL, output_format = md_document())

Arguments

pkg

Full path to package directory. Default value is the current working directory. Alternatively, a package name can be passed as string. If this is the case, base::find.package() is applied.

output_file

Specify outputfile, including file extension

output_format

Output format function. See output_format(). Default is md_document(), but one could provide a custom output format.

References

Murdoch, D. (2010). Parsing Rd files

See Also

  • Package Rd2markdown, on which the original version was based on.

  • Package pkgdown, on which the current (refactored) version is based on.

Examples

## give source directory of your package
pkg_dir = "~/git/MyPackage"

## create reference manual
## render_refman(pkg_dir)