Skip to main content

jsonout.check_document

jsonout.check_document(spec, findings)

The document of a check: the format number, the summary and the findings.

Parameters

Name Type Description Default
spec RegenSpec The loaded spec (its number of units goes into the summary). required
findings list[Finding] The findings of run_checks, in the order of the text output. required

Returns

Name Type Description
dict dict format, summary (units, errors, warnings) and findings, each with path, line, level, id, message and suggestion; line and suggestion are None where there is none. The message does not hold the suggestion.

Examples

import json
from pathlib import Path
from tempfile import TemporaryDirectory

from babregen import load_spec, make_sample_repo, run_checks
from babregen.jsonout import check_document

with TemporaryDirectory() as tmp:
    spec = load_spec(make_sample_repo(Path(tmp) / "demo"))
    print(json.dumps(check_document(spec, run_checks(spec))))
{"format": 1, "summary": {"units": 1, "errors": 0, "warnings": 0}, "findings": []}