Coder Social home page Coder Social logo

rdocs's Introduction

rdocs: Simple Quarto documentation for R packages

Allows to create quarto markdown documentation (.qmd) from /// and ### tokens in text files. Documentation can be created, for example, from .R, .rs and .cpp files.
The package will search for these tokens in the files and generate a quarto website.

This library's documentation was created using rdocs.

Instalation

Install Quarto and add it to PATH.

Install the package from github: remotes::install_github("daniellga/rdocs", subdir = "rdocs")

or from R-universe: install.packages('rdocs', repos = 'https://daniellga.r-universe.dev')

Usage

An example is showed below, where 2 distinct functions will be documented on the same section, named HFft. It generates a quarto website from lines starting with ### or /// that are right above function declarations.
The website folder is created in the current working directory.
The first line of the block is important, since the name of the variable will be used to group functions into the same one-worded section. This is useful, for example, when working using an OOP approach. For now, to avoid any bugs, it is important that all grouped functions are on the same file.
The user is free to create its headings, line breaks and make use of all other markdown utilities.
All R code identified by r code markdown blocks will be evaluated in a separate R session. If you don't want a certain part of the code to be run, it will be needed to comment it or avoid the code block representation. If you don't want to evaluate the code at all, use run_examples = FALSE, which is the default.

testscript.rs

/// HFft
/// ## fft
///
/// `fft() -> HArray`
///
/// Computes the fast fourier transform of the `HArray`.
///
/// #### Returns
///
/// An `HArray`.
///
/// #### Examples
///
/// ```r
/// arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4))
/// dtype = HDataType$float32
/// HArray$new_from_values(arr, dtype)
/// HFft$fft(harray)
/// ```
///
fn fft(harray: &HArray) -> HArray {
    HArray(harray.0.fft())
}

/// HFft
/// ## fft_mut
///
/// `fft_mut()`
///
/// Computes the fast fourier transform of the `HArray`.
/// The operation is done in-place.
///
/// #### Examples
///
/// ```r
/// arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4))
/// dtype = HDataType$float32
/// HArray$new_from_values(arr, dtype)
/// HFft$fft_mut(harray)
/// ```
///
fn fft_mut(harray: &mut HArray) {
    let inner_mut = harray.get_inner_mut();
    inner_mut.fft_mut()
}
rdocs::generate_docs("./testscript.rs")

The website will be generated on the current working directory.

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.