Code Monkey home page Code Monkey logo

rd2mdmkdocs's Introduction

CRAN_Status_Badge codecov

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())

rd2mdmkdocs's People

Contributors

quantsch avatar compstats avatar friedue avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.