Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
91aa9ca
docs: add runnable examples for Allows reference page
khajavi Mar 6, 2026
f19b525
docs: embed example files via SourceFile.print in allows.md
khajavi Mar 6, 2026
52267e3
Update zio-blocks-docs/src/main/scala/SourceFile.scala
khajavi Mar 6, 2026
1125035
Documentation of Structural Types (#1171)
khajavi Mar 6, 2026
c61e4f2
fix(Allows): harden Scala 2 macro type extraction and add regression …
jdegoes Mar 6, 2026
c97beaf
docs(allows): add structural type definition
khajavi Mar 6, 2026
9548af8
docs(allows): add Creating Instances section
khajavi Mar 6, 2026
8697b7a
docs(allows): add Core Operations section
khajavi Mar 6, 2026
4392469
docs(allows): add Integration section with Schema
khajavi Mar 6, 2026
d81765c
docs(allows): fix prose introduction for error message and code blocks
khajavi Mar 6, 2026
64d0a72
docs(allows): remove redundancy from Motivation section
khajavi Mar 6, 2026
6a67406
docs(allows): fix mdoc modifiers and Scala 2/3 syntax consistency
khajavi Mar 6, 2026
e121865
docs(allows): fix code block compilation errors (escape and imports)
khajavi Mar 6, 2026
8cabc8c
docs: integrate allows.md into sidebar and documentation index
khajavi Mar 6, 2026
3217cd3
docs: add scalafmt lint step to documentation skills
khajavi Mar 7, 2026
3f938a2
docs(allows): apply scalafmt to examples
khajavi Mar 7, 2026
f3569f2
docs(skills): stage example files before lint check to catch untracke…
khajavi Mar 7, 2026
8d30f53
docs(allows): clarify compile-only examples and remove misleading sbt…
khajavi Mar 7, 2026
fc8c1d3
fix(docs): improve SourceFile resource management and error handling
khajavi Mar 7, 2026
fa972db
Merge main into allow-examples: resolve step numbering conflict
khajavi Mar 7, 2026
240f91b
docs(allows): explain capability token concept
khajavi Mar 7, 2026
02d42f6
docs(allows): explain structural preconditions vs runtime checks
khajavi Mar 7, 2026
af41164
docs(allows): replace 'ZIO Schema 2' with 'ZIO Blocks' and explain da…
khajavi Mar 7, 2026
d7bae0c
docs(allows): explain DynamicValue in JSON context
khajavi Mar 7, 2026
39e2c21
docs(allows): explain upper bound semantics rationale
khajavi Mar 7, 2026
11ea3f4
docs(allows): improve upper bound code example with UserRow cases
khajavi Mar 7, 2026
35a3a6a
docs(allows): remove tabbed code blocks comment
khajavi Mar 7, 2026
eb3dbb8
docs(allows): restructure grammar nodes table into three groups
khajavi Mar 7, 2026
d8951dc
docs(allows): clarify 'catch-all Primitive' terminology
khajavi Mar 7, 2026
8e77319
docs(allows): add MDX Tabs imports
khajavi Mar 7, 2026
dbcfc6c
docs(allows): convert 'Creating Instances' examples to tabs
khajavi Mar 7, 2026
7c3bcc1
docs(allows): convert 'Union Syntax' examples to tabs
khajavi Mar 7, 2026
5cc8a18
docs(skills): add Scala 2/3 tabs pattern to docs-mdoc-conventions
khajavi Mar 7, 2026
8b6d95c
docs(skills): update Scala version rule to allow tabs for version-spe…
khajavi Mar 7, 2026
e9ed137
Update .claude/skills/docs-data-type-ref/SKILL.md
khajavi Mar 7, 2026
0b93ec2
Update docs/reference/allows.md
khajavi Mar 7, 2026
e8e3aa9
docs(skills): fix nested fence in tabbed code example
khajavi Mar 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 76 additions & 2 deletions .claude/skills/docs-data-type-ref/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,56 @@ Rules for this section:
- The bolded description must be a short plain-English description of what that specific `App` demonstrates — not the object name rephrased.
- Keep the two numbered steps (clone, run individually) in that order; do not add or remove steps.
- If no example `App` objects were written (rare), omit this section entirely.
- When the full example source is also **embedded earlier in the document** via `SourceFile.print`,
the `([source](...))` link in this section serves as a convenient shortcut to the GitHub file;
there is no need to embed the source again here.

### Embedding Example Files with `SourceFile`

When the documentation needs to show a **full example file** from the `schema-examples` project
(written in Step 3), **do not copy-paste the code inline**. Instead, use `mdoc:passthrough` with
the `SourceFile.print` helper to include it by reference. This keeps the doc and the example in
sync — any change to the example file automatically appears in the rendered docs on the next
mdoc build.

Use this pattern:

````markdown
```scala mdoc:passthrough
import docs.SourceFile

SourceFile.print("schema-examples/src/main/scala/<package>/<ExampleFile>.scala")
```
````

**Important:** Import as `import docs.SourceFile` and call `SourceFile.print(...)` — do NOT use
`import docs.SourceFile._` with bare `print(...)` because `print` conflicts with `Predef.print`
inside mdoc sessions.

`SourceFile.print(path)` reads the file at mdoc compile time and emits a fenced code block with
the file path shown as the title. The path is relative to the repository root (the helper tries
`../<path>` first, then `<path>`).

**When to use `SourceFile.print`:**
- Showing a complete, runnable `App` example from `schema-examples/`
- Showing a large, self-contained example that would be unwieldy to maintain in two places

**When NOT to use it — use regular mdoc blocks instead:**
- Short inline snippets (< 20 lines) that illustrate a single method or concept
- Code that needs `mdoc` evaluated output (e.g., `// res0: Int = 42`)
- Code that is documentation-specific and doesn't exist as a standalone file

**Optional parameters:**
- `lines = Seq((from, to))` — include only specific line ranges (1-indexed):
````markdown
```scala mdoc:passthrough
import docs.SourceFile

SourceFile.print("schema-examples/src/main/scala/into/IntoNumericExample.scala", lines = Seq((10, 25)))
```
````
- `showLineNumbers = true` — render with line numbers in the output
- `showTitle = false` — suppress the file path title

### Compile-Checked Code Blocks with mdoc

Expand Down Expand Up @@ -335,15 +385,39 @@ object IntoSchemaEvolutionExample extends App {
}
```

## Step 4: Integrate
## Step 4: Lint Check (Mandatory Before Integration)

After creating all example files, stage them in git first, then ensure all Scala files pass the CI formatting gate:

```bash
git add schema-examples/src/main/scala/**/*.scala
sbt fmtChanged
```

If any files were reformatted, commit the changes immediately:

```bash
git add -A
git commit -m "docs(<type>): apply scalafmt to examples"
```

Verify the CI lint gate locally:

```bash
sbt check
```

**Success criterion:** zero formatting violations reported.

## Step 5: Integrate

See the **`docs-integrate`** skill for the complete integration checklist (sidebars.js, index.md,
cross-references, link verification).

Additional note for reference pages: if creating a new file, place it in the appropriate
`docs/reference/` subdirectory based on where it logically belongs.

## Step 5: Review and Verify Compilation
## Step 6: Review and Verify Compilation

After writing, re-read the document and verify:
- All method signatures match the actual source code
Expand Down
29 changes: 29 additions & 0 deletions .claude/skills/docs-document-pr/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,34 @@ Once documentation is written, tell the user:

---

## Phase 6: Verify Lint (If Examples Created)

If documentation involved creating or modifying `.scala` example files in `schema-examples/`, stage them in git first, then verify that all Scala code passes the CI formatting gate before reporting completion:

```bash
git add schema-examples/src/main/scala/**/*.scala
sbt fmtChanged
```

If any files were reformatted, commit the changes:

```bash
git add -A
git commit -m "docs(<topic>): apply scalafmt to examples"
```

Then verify the CI lint gate locally:

```bash
sbt check
```

**Success criterion:** zero formatting violations reported.

**If no `.scala` files were created or modified**, skip this phase.

---

## Implementation Checklist

When you invoke this skill:
Expand All @@ -285,6 +313,7 @@ When you invoke this skill:
- [ ] **Phase 3c:** If subsection → manually edit existing page, consult `docs-writing-style` and `docs-mdoc-conventions` skills
- [ ] **Phase 4:** If new page → invoke `docs-integrate` skill to update sidebar
- [ ] **Phase 5:** Report findings and file paths to user
- [ ] **Phase 6:** If `.scala` examples were created, run `sbt fmt` and `sbt check` to verify lint compliance

---

Expand Down
24 changes: 24 additions & 0 deletions .claude/skills/docs-how-to-guide/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,30 @@ sbt "schema-examples/compile"

If any example fails to compile, fix it before proceeding. The examples must compile successfully.

### 4f. Lint Check (Mandatory Before Integration)

After all examples compile, stage them in git first, then run Scalafmt to ensure all Scala files pass the CI formatting gate:

```bash
git add schema-examples/src/main/scala/**/*.scala
sbt fmtChanged
```

If any files were reformatted, commit the changes immediately:

```bash
git add -A
git commit -m "docs(<guide-id>): apply scalafmt to examples"
```

Verify the CI lint gate locally:

```bash
sbt check
```

**Success criterion:** zero formatting violations reported.

---

## Step 5: Integrate
Expand Down
53 changes: 53 additions & 0 deletions .claude/skills/docs-mdoc-conventions/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,59 @@ modifiers are used more than in reference pages:

---

## Tabbed Scala 2 / Scala 3 Examples

When a section shows syntax that differs between Scala 2 and Scala 3, use Docusaurus tabs
instead of sequential prose blocks. This lets readers pick their version once and have all
tab groups on the page sync together.

### Required MDX imports

Add these two lines at the top of any `.md` file that uses tabs (right after the closing
`---` of the frontmatter, before any prose):

```mdx
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
```

### Tab structure

````mdx
<Tabs groupId="scala-version" defaultValue="scala2">
<TabItem value="scala2" label="Scala 2">

```scala mdoc:compile-only
// Scala 2 syntax here
```

</TabItem>
<TabItem value="scala3" label="Scala 3">

```scala mdoc:compile-only
// Scala 3 syntax here
```

</TabItem>
</Tabs>
````

### Rules

- Always use `groupId="scala-version"` — this syncs all tab groups on the page when the
reader picks a version.
- Always use `defaultValue="scala2"` — Scala 2 is shown first by default.
- Blank lines inside `<TabItem>` are required for mdoc to process fenced code blocks
correctly.
- `mdoc:compile-only` is the correct modifier for code inside tabs (same as everywhere
else).
- mdoc passes JSX components through unchanged — only fenced `scala mdoc:*` blocks are
rewritten.
- Do **not** use tabs for examples that are identical in both versions — only use them
when the syntax genuinely differs.

---

## Docusaurus Admonitions

Use Docusaurus admonition syntax for callouts:
Expand Down
9 changes: 7 additions & 2 deletions .claude/skills/docs-writing-style/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ Apply these conventions consistently in all prose, section headings, and inline

## Scala Version

All code in documentation and companion example files **must use Scala 2.13.x syntax**. When in
doubt, check the companion example files — they are the source of truth for syntax style.
All code in documentation and companion example files **defaults to Scala 2.13.x syntax**.
When in doubt, check the companion example files — they are the source of truth for syntax style.

When a section shows syntax that genuinely differs between Scala 2 and Scala 3 (e.g., `using`
vs `implicit`, native union types vs backtick infix), use tabbed code blocks instead of
sequential prose. See `docs-mdoc-conventions` for the exact tab structure. Scala 2 is always
the default tab (`defaultValue="scala2"`).

---
4 changes: 4 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ com.github.sbt.git.SbtGit.useReadableConsoleGit
addCommandAlias("build", "; fmt; coverage; root/test; coverageReport")
addCommandAlias("fmt", "all root/scalafmtSbt root/scalafmtAll")
addCommandAlias("fmtCheck", "all root/scalafmtSbtCheck root/scalafmtCheckAll")
addCommandAlias(
"fmtChanged",
"; set scalafmtFilter in ThisBuild := \"diff-ref=main\"; scalafmtAll; set scalafmtFilter in ThisBuild := \"\""
)
addCommandAlias("check", "; scalafmtSbtCheck; scalafmtCheckAll")
addCommandAlias("mimaChecks", "all schemaJVM/mimaReportBinaryIssues")
addCommandAlias(
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ ZIO Blocks supports **Scala 2.13** and **Scala 3.x** with full source compatibil
### Core Schema Concepts

- [Schema](./reference/schema.md) - Core schema definitions and derivation
- [Allows](./reference/allows.md) - Compile-time structural grammar constraints
- [Reflect](./reference/reflect.md) - Structural reflection API
- [Binding](./reference/binding.md) - Runtime constructors and deconstructors
- [BindingResolver](./reference/binding-resolver.md) - Binding lookup and schema rebinding
Expand Down
Loading