Skip to main content

Module engine

Module engine 

Source
Expand description

Document assembly + rule-running engine — mirrors core/engine.py’s parse_document/load_journal/run.

.tex/.ltx/.bib/.rnw/.rmd are all supported. .rnw chunk rewriting lives in crate::rnw; .rmd tokenizing/fragment construction lives in crate::rmd (see that module’s doc comment for the line-offset scheme). Most rules iterate all_tex_like_docs() (tex_files + every .Rmd fragment); a few (GLOBAL_TEX_RULES, below) need every fragment together in one call instead of one call per fragment — see that constant’s doc comment for which and why.

No filesystem I/O here — from_sources takes already-read (path, contents) pairs so every binding (including WASM, which has no filesystem) can drive the same engine.

Structs§

ParsedBibFileDoc
ParsedDocument
ParsedRmdFileDoc
Mirrors api.py::ParsedRmdFile. latex_fragments are the raw-LaTeX islands extracted from prose blocks (spec 005 FR-006) — every rule that iterates all_tex_like_docs() sees these alongside real .tex files. violations are JSS-PARSE-000 findings from the Rmd tokenizer itself (unterminated frontmatter/fence, malformed YAML), not rule findings.
ParsedTexFileDoc

Enums§

EngineError

Functions§

run
Run every registered rule over document, applying the ignore-rules and min-confidence gates, and assemble a ComplianceReport. Mirrors core/engine.py::run’s algorithm (category/rule iteration, SkippedRule bookkeeping, format gating, the synthetic JSS-PARSE-000 “parse” category, compliance_percentage, sorted violations, severity overrides). One thing still deferred: inline suppression comments (% jss-lint: ignore [RULE-IDS]) aren’t implemented — every rule finding is reported regardless. JSS-PARSE-000 findings currently only ever come from .Rmd’s tokenizer (unterminated frontmatter/fence, malformed YAML); the tex tokenizer itself (.tex/.ltx/.rnw) never emits one — it only implements pylatexenc’s tolerant-parsing path, which never raises, unlike Python’s strict-then-tolerant-retry parse_tex_source (see tex::parse_tex_source’s doc comment).
run_with_project
Like run, but also dispatches JSS-PROJECT-001 (cycle) / JSS-PROJECT-002 (missing reference) — the graph-level violations a filesystem-bound resolver (jsslint-cli’s resolver module, mirroring core/resolver.py) already computed by walking document’s \input/\include/\subfile/\bibliography graph. Mirrors core/engine.py::run being handed a ParsedProject instead of a plain ParsedDocument: these two rules only ever run when a project was actually resolved (spec 013’s auto-resolve path); a bare multi-file document (explicit CLI args, --no-resolve, or any other subcommand) uses plain run above and never invokes them — leaving the “project” category at 0 rules applied (SKIPPED), same as Python leaves rule.check_project uncalled for a bare ParsedDocument.