Skip to content

Commit f8cf0ed

Browse files
cscheidclaude
andcommitted
build(error-reporting): gate json wire shape behind a default-off json feature (bd-egcyeym9)
The json.rs wire shape (JsonDiagnostic etc.) carries `schemars` and Quarto's `quarto.org` schema URLs — both Quarto policy. Make it opt-in so the soon-to-be-published quarto-error-reporting is lean for non-Quarto consumers: - `schemars` becomes `optional = true`; new `[features] json = ["dep:schemars"]`. - `lib.rs`: `pub mod json` + its re-export gated behind `#[cfg(feature = "json")]`. - `tests/schema_drift.rs`: `#![cfg(feature = "json")]` (empty test binary when off). - The 4 crates that use the wire symbols (quarto, quarto-core, quarto-preview, wasm-quarto-hub-client) enable `features = ["json"]`. `cargo tree` confirms `schemars` is absent under default features and present with `--features json`. `to_json` (uses serde_json::json!, not the module) and coalesce.rs stay unconditional. In the q2 workspace json is on via feature unification, so the wire shape and schema_drift test build as before. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ea0333a commit f8cf0ed

7 files changed

Lines changed: 29 additions & 12 deletions

File tree

crates/quarto-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ quarto-system-runtime.workspace = true
3838
quarto-pandoc-types.workspace = true
3939
quarto-source-map.workspace = true
4040
quarto-doctemplate.workspace = true
41-
quarto-error-reporting.workspace = true
41+
quarto-error-reporting = { workspace = true, features = ["json"] }
4242
quarto-config.workspace = true
4343
quarto-yaml.workspace = true
4444
quarto-ast-reconcile.workspace = true

crates/quarto-error-reporting/Cargo.toml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@ serde = { workspace = true }
2020
serde_json = { workspace = true }
2121

2222
# JSON Schema generation for the wire format (bd-iey8o). Scoped to
23-
# this crate: `schemars` documents machine-to-machine JSON shapes
24-
# emitted by Quarto. Do NOT add it to other crates for the purpose
25-
# of validating user-authored YAML config — that's the job of
26-
# `quarto-yaml-validation`, which speaks Quarto's own dialect. See
27-
# `claude-notes/plans/2026-05-22-q2-render-json-errors.md` §
28-
# "Coexistence with quarto-yaml-validation".
29-
schemars = { workspace = true }
23+
# this crate AND to the `json` feature: `schemars` documents the
24+
# machine-to-machine JSON shapes in `json.rs`. Do NOT add it to other
25+
# crates for the purpose of validating user-authored YAML config —
26+
# that's the job of `quarto-yaml-validation`, which speaks Quarto's own
27+
# dialect. See `claude-notes/plans/2026-05-22-q2-render-json-errors.md`
28+
# § "Coexistence with quarto-yaml-validation".
29+
schemars = { workspace = true, optional = true }
3030

3131
# URL handling for file:// hyperlinks
3232
url = "2.5"
3333

34+
[features]
35+
# The `json.rs` wire shape (JsonDiagnostic etc.) and its `schemars`
36+
# dependency are opt-in: the q2 consumers (quarto, quarto-core,
37+
# quarto-preview, wasm-quarto-hub-client) enable `json`, while a
38+
# standalone non-Quarto consumer gets a leaner build with no schemars.
39+
# Default-off so the published crate stays minimal.
40+
json = ["dep:schemars"]
41+
3442
[dev-dependencies]
3543
# No dev dependencies yet
3644

crates/quarto-error-reporting/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ pub mod builder;
6262
// (WASM render bridge) and quarto-preview (server-side diagnostics
6363
// endpoint). Lifted from wasm-quarto-hub-client under bd-b9kzg so
6464
// the q2-preview SPA can consume both feeds without a translation
65-
// layer.
65+
// layer. Behind the default-off `json` feature (carries `schemars`
66+
// and Quarto's `quarto.org` schema URLs) so the published crate stays
67+
// minimal for non-Quarto consumers.
68+
#[cfg(feature = "json")]
6669
pub mod json;
6770

6871
// Macros for convenient error creation
@@ -85,6 +88,7 @@ pub use coalesce::{CoalescedDiagnostic, coalesce_by_source};
8588
pub use diagnostic::{
8689
DetailItem, DetailKind, DiagnosticKind, DiagnosticMessage, MessageContent, TextRenderOptions,
8790
};
91+
#[cfg(feature = "json")]
8892
pub use json::{
8993
JsonDiagnostic, JsonDiagnosticDetail, JsonPass1Failure, diagnostic_to_json, with_source_file,
9094
};

crates/quarto-error-reporting/tests/schema_drift.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
//! # Regenerate after editing JsonDiagnostic / JsonPass1Failure:
2626
//! QUARTO_REGEN_SCHEMAS=1 cargo nextest run -p quarto-error-reporting --test schema_drift
2727
//! ```
28+
//!
29+
//! Gated on the `json` feature (the wire shapes live behind it); compiles to an
30+
//! empty test binary when `json` is off. In the q2 workspace the feature is on
31+
//! (enabled by `quarto`/`quarto-core`/… via unification).
32+
#![cfg(feature = "json")]
2833

2934
use std::path::PathBuf;
3035

crates/quarto-preview/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ automerge = { version = "0.8.0", features = ["utf16-indexing"] }
2626
samod = { version = "0.9.0", git = "https://github.com/quarto-dev/samod.git", branch = "q2", features = ["tokio"] }
2727

2828
quarto-core.workspace = true
29-
quarto-error-reporting.workspace = true
29+
quarto-error-reporting = { workspace = true, features = ["json"] }
3030
quarto-hub.workspace = true
3131
quarto-pandoc-types.workspace = true
3232
quarto-source-map.workspace = true

crates/quarto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tokio.workspace = true
2424

2525
quarto-core = { workspace = true, features = ["clap"] }
2626
quarto-error-catalog.workspace = true
27-
quarto-error-reporting.workspace = true
27+
quarto-error-reporting = { workspace = true, features = ["json"] }
2828
quarto-source-map.workspace = true
2929
quarto-trace.workspace = true
3030
quarto-trace-server.workspace = true

crates/wasm-quarto-hub-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ quarto-core = { path = "../quarto-core" }
1616
# NOTE: `quarto-error-catalog` is intentionally NOT a dependency here — the WASM
1717
# bridge never surfaces docs URLs, so installing the catalog would only bloat the
1818
# bundle past the PWA precache limit. See the comment in `init()` in src/lib.rs.
19-
quarto-error-reporting = { path = "../quarto-error-reporting" }
19+
quarto-error-reporting = { path = "../quarto-error-reporting", features = ["json"] }
2020
# Direct dep so the test-only `quarto_highlight_for_test` export can
2121
# call the Registry-backed highlight path. Same crate quarto-core uses
2222
# via CodeHighlightStage — ensuring WASM tests exercise the same code

0 commit comments

Comments
 (0)