Skip to contents

Formats a data dictionary as one Markdown table per database table, ready to paste into a README or to print in a Quarto report (chunk option output: asis).

Usage

schema_markdown(dictionary, tables = NULL, heading_level = 3L)

Arguments

dictionary

A data.table from schema_dictionary().

tables

Character or NULL. Tables to include; NULL for all.

heading_level

Integer. Level of the heading written above each table (0 for no heading).

Value

A character string (print it with cat()).

Examples

schema <- list(document = "
  CREATE TABLE IF NOT EXISTS document (
    doc_id VARCHAR,  -- <source>:<source_id>
    year   INTEGER   -- year of publication
  )")
cat(schema_markdown(schema_dictionary(schema)))
#> ### `document`
#> 
#> | Column | Type | Description |
#> |---|---|---|
#> | `doc_id` | VARCHAR | <source>:<source_id> |
#> | `year` | INTEGER | year of publication |