b3doc is an R package to create Markdown pages for the B-Cubed documentation website from external R Markdown files, such as vignettes. The package has functionality to set the necessary metadata in the front matter.
To get started, see:
You can install the development version of b3doc from GitHub with:
# install.packages("pak")
# pak::pak("b-cubed-eu/b3doc")
install.packages("b3doc", repos = c('https://b-cubed-eu.r-universe.dev', 'https://cloud.r-project.org'))
Here we use b3doc to read a vignette, run its code and output a Markdown file:
library(b3doc)
# Load packages used in the Rmd file
library(sf)
library(dplyr)
library(ggplot2)
library(tidyterra)
# Convert Rmd to Markdown
rmd_to_md(
rmd_file = "https://raw.githubusercontent.com/b-cubed-eu/gcube/refs/heads/main/vignettes/articles/occurrence-process.Rmd",
md_dir = "output/src/content/docs/software/gcube",
fig_dir = "output/public/software/gcube",
fig_url_dir = "/software/gcube/",
title = "2. Occurrence process",
sidebar_label = "occurrence-process",
sidebar_order = 2
)
# Clean up (don't do this if you want to keep your files)
unlink("output", recursive = TRUE)
In production, this code is run as part of a
script
to update the B-Cubed documentation website.
Its static website generator then builds the site, using the metadata we
provided (such as sidebar_label).
citation("b3doc").This software was developed with funding from the European Union’s Horizon Europe Research and Innovation Programme under grant agreement ID No 101059592.