Skip to contents

Checks shell_qmd's YAML frontmatter (and the project's _quarto.yml) against every field this package's Quarto extension and apply-layout step actually read, and prints a cli-formatted report: what's provided, what's missing (required or merely recommended), what else is available and what it does, and any structural conflicts (e.g. both title: and memo: set, or a header-format: placeholder that doesn't resolve). Driven entirely by the shared field registry (see R/header-fields.R), so it stays in sync with the extension by construction rather than by separately-maintained documentation.

Usage

validate_header(shell_qmd, quarto_yml = NULL, quiet = FALSE, strict = FALSE)

Arguments

shell_qmd

Path to the shell .qmd.

quarto_yml

Path to the project's _quarto.yml. NULL (default) looks for one next to shell_qmd.

quiet

Suppress the cli report and just return the result. Default FALSE.

strict

Abort (via cli::cli_abort()) if any required field is missing or any "error"-severity structural check fails. Default FALSE.

Value

Invisibly, a list with ok (logical), provided, missing_required, missing_recommended, available (each a character vector of field keys), and problems (a data frame of id/severity/message from the structural checks).

Examples

# A minimal shell .qmd -- title/format/filters are set, but there's no
# _quarto.yml next to it yet. The printed report below is real output,
# not a curated transcript: it reflects the current field registry
# (R/header-fields.R) exactly, so it can't drift from what
# validate_header() actually checks.
tmp <- tempfile(fileext = ".qmd")
writeLines(
  c(
    "---",
    "title: \"Demo Report\"",
    "filters:",
    "  - quarto-plus",
    "  - quartifyr",
    "format: docx",
    "---",
    "",
    "Body text."
  ),
  tmp
)
validate_header(tmp)
#> 
#> ── quartifyr header validation: /tmp/RtmpD95nr4/file1ab82b5da33f.qmd ───────────
#> 
#> ── Provided ──
#> 
#> → Document structure
#> • format
#> • filters
#> → Title page
#> • title
#> 
#> ── Conflicts / structural issues ──
#> 
#> ✖ No `_quarto.yml` found next to the .qmd -- render_report() requires one
#>   setting `project: {output-dir: report/shell}`.
#> 
#> ── Also available ──
#> 
#> ℹ subtitle: Optional subtitle line under the title.
#> ℹ report-type: Optional label (e.g. "Clinical Study Report") rendered as part
#>   of the title block.
#> ℹ date: Info-table row. Independent of `memo.date`, which is a separate field
#>   for the memo cover.
#> ℹ lead-scientist: Info-table row.
#> ℹ version: Info-table row.
#> ℹ address: YAML list of address lines (not one string) for a sender address row
#>   -- for a fuller To/From/Date/Re cover instead, use `memo:` rather than
#>   stacking this on a title page.
#> ℹ title-page-extra: YAML list of `{label, value}` rows appended after the named
#>   convenience fields, in whatever order written -- a list (not a map) so row
#>   order survives pandoc's Lua metadata table, which doesn't preserve map key
#>   order. Shared with the memo cover (appended after its To/From/Date/Re/Cc
#>   grid).
#> ℹ document-status: Draft/final stamp, always shown (default "DRAFT").
#>   `render_report()` always overrides this via Quarto's `-M document-status:`
#>   from its own `status` argument, so setting it here only has an effect when
#>   rendering directly with `quarto render`. (default: DRAFT)
#> ℹ logo: Path to an image, relative to the .qmd; omitted entirely (no reserved
#>   space) when unset. Shared with the memo cover.
#> ℹ logo-width: Any pandoc-recognized image width. Shared with the memo cover.
#>   (default: 2in)
#> ℹ logo-align: "left"/"center"/"right". Shared with the memo cover, but the
#>   *default* differs: "center" for a title page, "left" for a memo cover.
#>   (default: center (title page) / left (memo cover))
#> ℹ confidentiality: Info-table row on the title page/memo cover, and (via
#>   apply-layout) reused as the rendered footer's confidentiality label.
#> ℹ memo: Nested `to`/`from`/`date`/`re`/`cc` block that renders a
#>   fax-cover-sheet-style memo cover instead of a formal title page. Mutually
#>   exclusive with `title:`.
#> ℹ contributors: Nested `authors`/`reviewers` lists (each entry a `{name,
#>   title}` map). Either key, or the whole block, may be omitted.
#> ℹ approvers: List of `{name, title}` maps. If both `contributors:` and
#>   `approvers:` are omitted, no Signatures page renders at all.
#> ℹ signature-mode: "line" (default, a blank signing box) or "note" (replace it
#>   with `signature-note:` text everywhere) -- e.g. for a validated e-signature
#>   workflow. (default: line)
#> ℹ synopsis: YAML list of `{label, value}` rows (any labels, any order -- not
#>   fixed to Objectives/Methods/Results). A "Title" row is prepended
#>   automatically. Omit entirely to turn the whole section off. `value:` may also
#>   be a list mixing text paragraphs and `{image: ..., width: ...}` entries (bare
#>   filenames within `OUTPUTS/figures/`, resolved via reportifyr's `{rpfy}:`
#>   mechanism).
#> ℹ appendix-numbering: "alphabetic" (default, A/B/C), "arabic" (1/2/3), or
#>   "roman" (I/II/III, uppercase only). An unrecognized value falls back to
#>   "alphabetic" with a render-time warning. (default: alphabetic)
#> ℹ caption-style-figure: Paragraph style name applied to figure captions
#>   (default "Caption"). (default: Caption)
#> ℹ caption-style-table: Paragraph style name applied to table captions (default
#>   "Caption"). (default: Caption)
#> ℹ bibliography: Path to a .bib file. Enables citeproc; standard Quarto/pandoc
#>   frontmatter, nothing quartifyr-specific beyond the `csl:`/`link-citations:`
#>   defaults below.
#> ℹ header-format: `{placeholder}` template resolved against other frontmatter
#>   values plus `{status}`; every placeholder must name a real top-level
#>   frontmatter key. Inert on a plain `quarto render` -- only takes effect via
#>   `apply-layout`/`render_report()`.
#> ℹ crossref-hyperlinks: `true` (default, always hyperlinked), `false` (never),
#>   or `"same-page"` (opt-in, needs the separate `resolve_same_page_crossrefs`
#>   post-processing step -- see `render_report()`). (default: TRUE)
#> ℹ number-sections: Plain pandoc option: numbers real `#`/`##` body headings as
#>   static text ("1.", "1.1", ...). Independent of the raw-OOXML
#>   title/signature/appendix headings this extension injects, which are never
#>   touched by it.
#> ────────────────────────────────────────────────────────────────────────────────
#> ✖ Blocking issues found -- see Missing (required)/Conflicts above.