Skip to main content

Mkdocstrings handler for R.

Project description

mkdocstrings-R

PyPI version License: MIT Python versions

An mkdocstrings handler for R. Write your documentation with roxygen2 comments, and this handler will render them into your MkDocs site.

image

Installation

uv add mkdocstrings-r

Requirements

  • Python 3.10+
  • R (accessible via rpy2)
  • The roxygen2 R package

rpy2 also requires several system libraries (zstd, xz, bzip2, zlib, icu). These are typically already present on most systems.

Quick start

Given an R file at R/math.R:

#' Add two numbers together.
#'
#' A simple function that computes the sum of two numeric inputs.
#'
#' @param x A numeric value.
#' @param y A numeric value.
#'
#' @returns A numeric value, the sum of `x` and `y`.
#'
#' @examples
#' add(1, 2)
#' add(-5, 10)
add <- function(x, y) {
  x + y
}

Configure your mkdocs.yml:

plugins:
  - mkdocstrings:
      default_handler: R

Then reference the file in any Markdown page using dot-separated paths (without the .R extension):

# API Reference

::: R.math

Or reference the handler directly:

# API Reference

::: R.math
    handler: R

This renders documentation for every function in the file, including signature, description, parameters, return value, examples, and a collapsible source code block.

Supported roxygen2 tags

  • @title

  • @description

  • @details

  • @param

  • @return / @returns

  • @examples

Markdown is supported within tag descriptions (e.g., inline code, lists, links).

Configuration

Handler options

Configure the handler in mkdocs.yml under plugins > mkdocstrings > handlers > R:

plugins:
  - mkdocstrings:
      default_handler: R
      handlers:
        R:
          lib_loc: "/path/to/R/library"

lib_loc

Path to the R library directory containing roxygen2. This is only needed if rpy2 can't auto-detect your library location — for example, when using renv and the renv/ folder isn't in the directory where you're running mkdocs.

To find your library paths, run .libPaths() in an R console.

How it works

  1. The handler converts your dot-separated identifier (e.g., R.math) to a file path (R/math.R)
  2. It calls roxygen2::parse_file() via rpy2 to parse the roxygen2 comments
  3. The parsed tags are mapped to a structured data model
  4. A Jinja template renders the data as HTML within your MkDocs site

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocstrings_r-0.1.5.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocstrings_r-0.1.5-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file mkdocstrings_r-0.1.5.tar.gz.

File metadata

  • Download URL: mkdocstrings_r-0.1.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mkdocstrings_r-0.1.5.tar.gz
Algorithm Hash digest
SHA256 cbbbdf3ae72a33b161b0f0aba33c4e3db61fa07c6a9a0a724339dce146207219
MD5 1f87f893e93aa23fd59d236cc5b4e30e
BLAKE2b-256 3643e4e762feee805e504719db60ed9d57543c590e494a33ab2a34e06ee53e7c

See more details on using hashes here.

File details

Details for the file mkdocstrings_r-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: mkdocstrings_r-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mkdocstrings_r-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 98e9d2e144f67dff7d26ac2fb8dd094ff677ccf0ff58d1454efcedf03eb8791a
MD5 f72ff393b74ac865fff484cb2b08df0a
BLAKE2b-256 14e8d1aeadc56f89ca0e97781e223e6626dd93205152e86303016b345ac331fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page