Skip to content

Consume results programmatically

A gate that only passes or fails is the floor. Once docmeta is running, the same data behind the pass/fail decision can feed dashboards, PR bots, content catalogs, and custom checks — without re-parsing documents yourself.

docmeta exposes its results three ways, each suited to a different integration style:

  • --format json — a single structured object per run, for pipelines that shell out and parse stdout.
  • The get command — pull specific metadata field values out of files, for scripts that need a few values rather than a full validation report.
  • The TypeScript API — call docmeta’s command cores directly from Node.js, for tools built on top of it.

docmeta validate --format json prints one JSON object to stdout describing the whole run. It is the path for any tool that runs docmeta as a subprocess and reads its output.

Terminal window
npx -y docmeta validate "docs/**/*.md" --format json

The object has a summary and a results array:

{
"summary": {
"files": 1,
"passed": 0,
"failed": 1,
"errors": 1
},
"results": [
{
"file": "bad-timestamp.md",
"format": "markdown",
"ok": false,
"schemas": ["google:okf:0.1"],
"errors": [
{
"schema": "google:okf:0.1",
"instancePath": "/timestamp",
"message": "must match format \"date-time\"",
"line": 4
}
]
}
]
}

The fields:

  • summary — run-wide counts: files checked, passed, failed, and the total errors across all files.
  • results — one object per file: file (the path as docmeta saw it), format (the extractor that read it), ok, schemas (the resolved schema set), and errors.
  • Each errorschema (the schema id that produced it), instancePath (a JSON Pointer to the field, "" for the document root), message, and line (1-based, when docmeta can locate it).

The output is plain (never colorized) and goes to stdout, so it pipes cleanly into jq. List the files that failed:

Terminal window
npx -y docmeta validate "docs/**/*.md" --format json \
| jq -r '.results[] | select(.ok == false) | .file'

Flatten every error into a file:line message line for a log:

Terminal window
npx -y docmeta validate "docs/**/*.md" --format json \
| jq -r '.results[] | .file as $f
| .errors[] | "\($f):\(.line // "?") \(.message)"'

Read just the summary counts:

Terminal window
npx -y docmeta validate "docs/**/*.md" --format json | jq '.summary'
  1. A subprocess in any language? Use --format json and parse stdout. It is language-agnostic and the most stable surface.

  2. A shell script that needs a few field values? Use get — it is purpose-built for pulling named fields without a full validation report.

  3. A Node.js or TypeScript tool? Call the API. You skip process spawning and stdout parsing, and you get typed results.