Package 'b3doc'

Title: Tools for the B-Cubed Documentation Website
Description: Create Markdown pages for the B-Cubed documentation website (<https://docs.b-cubed.eu>) from external R Markdown files, such as vignettes.
Authors: Sanne Govaert [aut, cre] (ORCID: <https://orcid.org/0000-0002-8939-1305>, affiliation: Research Institute for Nature and Forest (INBO)), Peter Desmet [aut] (ORCID: <https://orcid.org/0000-0002-8442-8025>, affiliation: Research Institute for Nature and Forest (INBO)), Pieter Huybrechts [aut] (ORCID: <https://orcid.org/0000-0002-6658-6062>, affiliation: Research Institute for Nature and Forest (INBO)), Ward Langeraert [aut] (ORCID: <https://orcid.org/0000-0002-5900-8109>, affiliation: Research Institute for Nature and Forest (INBO)), Research Institute for Nature and Forest (INBO) [cph] (ROR: <https://ror.org/00j54wy13>), European Union [fnd] (https://doi.org/10.3030/101059592)
Maintainer: Sanne Govaert <[email protected]>
License: MIT + file LICENSE
Version: 0.3.0.9000
Built: 2026-05-13 14:57:10 UTC
Source: https://github.com/b-cubed-eu/b3doc

Help Index


Convert external R Markdown to Markdown

Description

Converts an R Markdown (.Rmd) file to a Markdown (.md) file. Both local and remote .Rmd files can be handled. The date this function is called upon is added to the beginning of the Markdown file.

Usage

rmd_to_md(
  rmd_file,
  md_dir,
  fig_dir,
  fig_url_dir,
  title = NULL,
  sidebar_label = NULL,
  sidebar_order = NULL,
  replace = NULL
)

Arguments

rmd_file

Path to the R Markdown file, either a local path or a URL.

md_dir

Path to local directory to write the Markdown file to. If it doesn't exist it will be created.

fig_dir

Path to local directory to write the figures to.

fig_url_dir

Link prefix that will be used to refer to figures in Markdown output.

title

Title of the article, to show on top of the page.

sidebar_label

Title in the sidebar.

sidebar_order

Number indicating the order of the article in the sidebar.

replace

Named character vector with c("key" = "value") pairs. All occurrences of "key" in the content of the Markdown file will be replaced by their respective "value" (before updating the front matter).

Value

Markdown file and figures written do disk.

Examples

## Not run: 
# First check and install (or update) packages loaded in the Rmd file

# Then convert Rmd to Markdown
rmd_to_md(
  rmd_file = file.path(
    "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,
  replace = c(
    "### Changing number of occurrences over time" =
    "### How to change the number of occurrences over time",
    "man/figures/logo.png" = "https://b-cubed-eu.github.io/gcube/logo.png"
  )
)

# Clean up (don't do this if you want to keep your files)
unlink("output", recursive = TRUE)

## End(Not run)

Update front matter

Description

Updates the front matter (and optionally content) of a Markdown file on disk.

Usage

update_frontmatter(
  md_file,
  rmd_file,
  title = NULL,
  sidebar_label = NULL,
  sidebar_order = NULL,
  replace = NULL
)

Arguments

md_file

Path to the Markdown file on disk.

rmd_file

Path to the R Markdown file, either a local path or a URL.

title

Title of the article, to show on top of the page.

sidebar_label

Title in the sidebar.

sidebar_order

Number indicating the order of the article in the sidebar.

replace

Named character vector with c("key" = "value") pairs. All occurrences of "key" in the content of the Markdown file will be replaced by their respective "value" (before updating the front matter).

Value

Markdown file with updated front matter (and optionally content), written to disk.

Examples

## Not run: 
update_frontmatter(
  md_file = file.path(
    "output/src/content/docs/software/gcube/occurrence-process.md"
  ),
  rmd_file = file.path(
    "https://raw.githubusercontent.com/b-cubed-eu/gcube/refs/heads/main",
    "vignettes/articles/occurrence-process.Rmd"
  ),
  title = "2. Occurrence process",
  sidebar_label = "Occurrence process",
  sidebar_order = 2,
  replace = c(
    "### Changing number of occurrences over time" =
    "### How to change the number of occurrences over time",
    "man/figures/logo.png" = "https://b-cubed-eu.github.io/gcube/logo.png"
  )
)

## End(Not run)