MyNixOS website logo
Description

Markdown Reference Manuals.

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.

CRAN_Status_Badge codecov

ko-fi

Installation

To install the Rd2md package, you can either use the official CRAN repository or install directly from github.

From CRAN:

install.packages("Rd2md")

From Github:

devtools::install_github("quantsch/Rd2md")

The package does not have any third-party package dependencies as I wanted to keep things simple. However, it heavily borrows ideas and code from pkgdown, so big thanks to the great work there!

Introduction

See the introduction vignette:

vignette("introduction")

Roadmap

  • significantly expand and improve unit tests
  • fail early: introduce input validations for exposed functions
  • add header content in output_format to pass date_format, etc.
  • toc "<\!-- toc -->\n\n" and a front_matter implementation for markdown

Extension

You can "easily" extend the parsing functionality by implementing your own parser. Without further details, an (almost) minimal example for text reference manual:

# required: a generic parsing function
as_txt <- function(x, ...) UseMethod("as_txt")
# required: introduces recursion
process_txt_contents <- function(x, ...) {
  # traverse through list and concatenate to string
  if (is.list(x)) x[] <- lapply(x, as_txt, ...)
  paste(as.character(x), collapse = "")
}
# required: a fallback as not all tags might have an `as_txt` method
as_txt.default <- function(x, ...) {
  process_txt_contents(x, ...)
}
# not required but improves output significantly:
# we add a section title and a separator for readability
as_txt.rdsection <- function(x, ...) {
  paste0(
    Rd2md:::tag_to_title(x),
    "\n----------------\n\n",
    process_txt_contents(x, ...), "\n\n"
  )
}
# not required but improves output significantly:
# we add a paragraph after the description file
as_txt.DESCRIPTION <- function(x, ...) paste0(x, "\n\n")
# not required but looks better: we drop the comments
as_txt.COMMENT <- function(x, ...) ""

# required: the output_format definition
txt_document <- function() output_format("txt", ".txt", as_txt)

# now we can render our new text refman:
render_refman(output_format = txt_document())
Metadata

Version

1.0.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows