Skip to content

Replace manual ParseDocument implementations with derive macro#70

Merged
ryo33 merged 4 commits intomainfrom
claude/parsedocument-derive-macro-IwifV
Dec 24, 2025
Merged

Replace manual ParseDocument implementations with derive macro#70
ryo33 merged 4 commits intomainfrom
claude/parsedocument-derive-macro-IwifV

Conversation

@ryo33
Copy link
Member

@ryo33 ryo33 commented Dec 24, 2025

  • Add #[eure(allow_unknown_fields)] container and variant attributes to eure-macros
  • Replace manual ParseDocument implementations in eure-codegen (5 types):
    RootCodegen, CodegenDefaults, UnionCodegen, RecordCodegen, FieldCodegen
  • Replace manual ParseDocument implementations in eure-config (3 types):
    Target, CliConfig, LsConfig
  • Replace manual ParseDocument implementation in eure-schema:
    Description enum now uses derive with rename_all = "lowercase"
  • Add tests for allow_unknown_fields attribute on both structs and enum variants

- Add #[eure(allow_unknown_fields)] container and variant attributes to eure-macros
- Replace manual ParseDocument implementations in eure-codegen (5 types):
  RootCodegen, CodegenDefaults, UnionCodegen, RecordCodegen, FieldCodegen
- Replace manual ParseDocument implementations in eure-config (3 types):
  Target, CliConfig, LsConfig
- Replace manual ParseDocument implementation in eure-schema:
  Description enum now uses derive with rename_all = "lowercase"
- Add tests for allow_unknown_fields attribute on both structs and enum variants
…vert phase

- Add ParseDocument impl for regex::Regex in eure-document using existing
  InvalidPattern error variant
- Create ParsedTextSchema in eure-schema with derive macro, using
  pattern: Option<String> instead of compiled Regex
- Move regex compilation from parse phase to convert phase (convert_text_schema)
- Add #[eure(allow_unknown_extensions)] attribute to derive macro for types
  that don't handle extensions themselves (extensions are handled at a higher
  level like ParsedSchemaNode)
- Add InvalidRegexPattern variant to ConversionError for regex compilation errors
Change InvalidPattern from {pattern, value} to {kind, reason} fields:
- kind: Type of validation (e.g., "regex", "url", "uuid", "type reference")
- reason: Human-readable error message explaining the failure

This makes the error variant suitable for future URL, UUID, and other
validation types that can be added with optional features.
Since Regex implements ParseDocument, Option<Regex> works automatically.
This simplifies the code by:
- Adding derive macro to TextSchema in lib.rs
- Removing intermediate ParsedTextSchema in parse.rs
- Removing convert_text_schema and InvalidRegexPattern in convert.rs
@ryo33 ryo33 merged commit 621f00b into main Dec 24, 2025
1 check passed
@ryo33 ryo33 deleted the claude/parsedocument-derive-macro-IwifV branch December 24, 2025 07:10
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