Skip to content

docs: Improve TypeId reference documentation with mdoc and examples#1189

Open
khajavi wants to merge 2 commits intozio:mainfrom
khajavi:typeid-doc
Open

docs: Improve TypeId reference documentation with mdoc and examples#1189
khajavi wants to merge 2 commits intozio:mainfrom
khajavi:typeid-doc

Conversation

@khajavi
Copy link
Member

@khajavi khajavi commented Mar 7, 2026

Summary

Significantly improved the TypeId reference documentation to comply with ZIO Blocks standards:

  • Code blocks: Converted 40+ inline result comments to live mdoc evaluation using mdoc:silent + mdoc pattern
  • Structure: Removed redundant # TypeId h1 heading (Docusaurus uses frontmatter)
  • Motivation: Added Overview section with ASCII diagram showing TypeId's role in the ZIO Blocks stack
  • Comparison: New "TypeId vs Related Concepts" section comparing to ClassTag, Class, TypeTag
  • Examples: Added "Running the Examples" section with commands for all three apps
  • Runnable examples: Created three self-contained App objects in schema-examples/src/main/scala/typeid/:
    • TypeIdBasicExample: Basic derivation and property access
    • TypeIdSubtypingExample: Inheritance relationships and variance-aware subtyping
    • TypeIdNormalizationExample: Type aliases, normalization, and erased TypeIds

All examples use ShowExpr.show() for self-documenting output that displays both source code and results.

Verification

  • ✅ sbt docs/mdoc: 0 errors, 50 warnings (unrelated)
  • ✅ sbt schema-examples/compile: All examples compile successfully
  • ✅ All three examples run and produce correct output

Test plan

  • Verify documentation renders correctly in the website
  • Run each example manually to confirm output
  • Check that mdoc examples stay in sync with API changes

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 7, 2026 18:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the TypeId reference documentation by replacing static “expected output” comments with mdoc-evaluated snippets, adding clearer conceptual sections, and providing runnable Scala example apps to demonstrate TypeId behavior.

Changes:

  • Updated docs/reference/typeid.md with mdoc-backed examples, an overview diagram, conceptual comparisons, and instructions for running examples.
  • Added three new runnable TypeId example apps under schema-examples/src/main/scala/typeid/.
  • Introduced a new derivation override example app plus additional repo artifacts (default.nix, .zio-sbt/.../.last_fetch).

Reviewed changes

Copilot reviewed 7 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
docs/reference/typeid.md Expanded TypeId reference page with mdoc blocks, new sections, and run instructions.
schema-examples/src/main/scala/typeid/TypeIdBasicExample.scala New runnable example covering derivation and basic TypeId properties.
schema-examples/src/main/scala/typeid/TypeIdSubtypingExample.scala New runnable example demonstrating subtype/supertype checks and variance-aware applied type checks.
schema-examples/src/main/scala/typeid/TypeIdNormalizationExample.scala New runnable example demonstrating alias normalization and erased TypeIds for registries.
schema-examples/src/main/scala/deriveroverrides/CompleteExample.scala New runnable example showing derivation instance override resolution order.
default.nix Adds a Nix dev shell configuration.
.zio-sbt/github-data/.last_fetch Adds a tooling state timestamp file.

- Fix code blocks to use mdoc evaluation instead of inline result comments
- Add Overview section with ASCII diagram showing TypeId's role in ZIO Blocks stack
- Add TypeId vs Related Concepts section comparing to ClassTag, Class, TypeTag
- Add Running the Examples section with runnable app references
- Create TypeIdBasicExample: derivation and property access
- Create TypeIdSubtypingExample: inheritance and variance-aware subtyping
- Create TypeIdNormalizationExample: type aliases and erased TypeIds
- All examples use ShowExpr for self-documenting source+result output
- Documentation now compiles with mdoc (0 errors)
- All examples run successfully

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Fix TypeId structural type signature: change from case class to sealed trait with AnyKind bound
- Fix Deriver trait signature: mark as simplified example and note actual API has additional parameters
- Fix TypeId.alias parameterization: use alias type (UserId) instead of underlying type (Long)
- Remove accidentally committed files: default.nix, .zio-sbt/ artifacts
- These changes address Copilot and khajavi review comments on PR zio#1189

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@khajavi
Copy link
Member Author

khajavi commented Mar 7, 2026

Fixed in 790d81d - changed to sealed trait TypeId[A <: AnyKind] to accurately reflect the actual API structure.

@khajavi
Copy link
Member Author

khajavi commented Mar 7, 2026

Fixed in 790d81d - marked as simplified example with note about actual API having additional parameters (binding, doc, modifiers).

@khajavi
Copy link
Member Author

khajavi commented Mar 7, 2026

Fixed in 790d81d - updated to use TypeId.alias[UserId] for proper phantom type parameterization and type-safety.

@khajavi
Copy link
Member Author

khajavi commented Mar 7, 2026

Fixed in 790d81d - removed default.nix and .zio-sbt/ generated files. These were accidentally committed and are not part of the TypeId documentation scope. These changes address feedback from both Copilot and khajavi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants