diff --git a/.claude/docs/adr/0009-tutorial-code-from-examples-via-region-includes.md b/.claude/docs/adr/0009-tutorial-code-from-examples-via-region-includes.md index 4d414677..c7e3988b 100644 --- a/.claude/docs/adr/0009-tutorial-code-from-examples-via-region-includes.md +++ b/.claude/docs/adr/0009-tutorial-code-from-examples-via-region-includes.md @@ -1,3 +1,3 @@ -# Tutorial code is single-sourced from `examples/` via docfx region includes; template pack strips the markers +# Tutorial code is single-sourced from `examples/` via `#region docs:` markers, synced into docs by a snippet pipeline -Tutorial markdown contains no inline C# snippets for load-bearing code; instead it embeds `[!code-csharp[](#docs:)]` includes that pull `#region docs: ... #endregion` ranges out of the canonical example projects under `examples/starter/`. The example files are the source of truth — touching the example changes the tutorial mechanically, and touching the tutorial requires touching the example, so the two cannot drift. The `docs:` prefix is the contract: only regions named `docs:*` are doc-relevant, and the example's own `#region`s (e.g., `#region Constructors`) are left alone. Because `examples/starter/*` projects also ship as `dotnet new` templates, a private nx subtarget `_strip-doc-regions` runs before pack and deletes every `^\s*#(region|endregion)\s+docs:.*$` line into a `pack-staging/` dir; the pack target consumes the staging dir, not the source tree, so contributors and the docs build see the real example with regions intact while template instantiators get a clean copy. The rejected alternatives were (A) inline ```csharp blocks compiled in isolation by a CI extractor — caught syntactic drift but not semantic mismatch against `examples/`, and required per-snippet scaffolding — and (C) a hybrid convention where small blocks stay inline and only "load-bearing" code uses includes; the line between the two was fuzzy enough that we expect convention drift, so we picked the all-includes rule for tutorials specifically. Guides and Explanation pages still allow inline blocks because their snippets are illustrative-of-a-concept rather than prescriptive-code-the-reader-will-copy. See [ADR-0008](./0008-documentation-honesty-three-error-phases.md) for the broader honesty framework this fits into. +Tutorial markdown contains no hand-written load-bearing C#; the canonical example projects under `examples/starter/` own that code and mark the doc-relevant ranges with `#region docs: