Skip to content

Update docs for Freezed v3#1183

Merged
rrousselGit merged 3 commits intorrousselGit:masterfrom
lishaduck:freezed-v3-docs
Mar 3, 2025
Merged

Update docs for Freezed v3#1183
rrousselGit merged 3 commits intorrousselGit:masterfrom
lishaduck:freezed-v3-docs

Conversation

@lishaduck
Copy link
Copy Markdown
Contributor

@lishaduck lishaduck commented Mar 1, 2025

Hopefully this will help your reputation 😜

The changes in the example got the analyzer to shut up, haven't looked too closely to see if they're actually correct, especially around mixin class.

The _ToString class in diagnosticable.dart doesn't work, I think it's a bug. See #1184.

Closes: #1181.

Summary by CodeRabbit

Summary by CodeRabbit

  • Documentation
    • Improved clarity and consistency in the Freezed package README, including updates on pattern matching and union types.
  • Refactor
    • Streamlined union handling using modern switch expressions and updated method signatures for better usability.
    • Converted several class types to mixin classes for enhanced code composition.
  • Chores
    • Simplified builder configuration by removing unnecessary options.
    • Upgraded the Dart SDK and key dependency versions for a more current development environment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 1, 2025

Walkthrough

The changes update the Freezed package’s documentation, configuration, and Dart code. The README was revised for clarity, removing outdated notes and adding alternative pattern matching options. In configuration files, several builder options were removed, and dependency versions were upgraded alongside an SDK constraint update. Code modifications include adding an override annotation, updating method signatures to accept optional parameters, converting an abstract union class to a sealed class with a switch expression for pattern matching, and changing certain classes to mixin classes.

Changes

File(s) Change Summary
packages/freezed/README.md Updated documentation: adjusted table formatting, removed outdated notes on union types and sealed classes, revised pattern matching details, and introduced an alternative if–case syntax.
packages/freezed/example/{build.yaml, pubspec.yaml} Configuration updates: in build.yaml, removed options format: false, maybe_map: true, and maybe_when: true; in pubspec.yaml, updated Dart SDK constraint from >=2.17.0 <3.0.0 to >=3.6.0 <4.0.0 and upgraded dependency versions for json_annotation and json_serializable.
packages/freezed/example/lib/{diagnosticable.dart, main.dart, non_diagnosticable.dart} Code modifications: in diagnosticable.dart, added @override and updated toString signature to include an optional parameter; in main.dart, changed the union class from abstract to sealed and replaced method-based pattern matching with a switch expression; in non_diagnosticable.dart, converted classes to mixin classes.

Possibly related PRs

  • External factory #1158: The changes in the main PR, particularly the removal of maybeMap and maybeWhen options, are directly related to the breaking changes in the retrieved PR that also involve the removal of map/when and its variants, indicating a shift towards a new pattern matching syntax.

Suggested reviewers

  • rrousselGit

Poem

I'm a rabbit on the run,
Hopping through code under the sun,
With switches and mixins, I cheer with delight,
Simplifying patterns from morning 'til night.
Carrots in hand 🥕, I celebrate the rewrite!
Happy coding, and may your bugs take flight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40b8261 and 10d052f.

📒 Files selected for processing (6)
  • packages/freezed/README.md (4 hunks)
  • packages/freezed/example/build.yaml (0 hunks)
  • packages/freezed/example/lib/diagnosticable.dart (2 hunks)
  • packages/freezed/example/lib/main.dart (2 hunks)
  • packages/freezed/example/lib/non_diagnosticable.dart (1 hunks)
  • packages/freezed/example/pubspec.yaml (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/freezed/example/build.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/freezed/example/lib/diagnosticable.dart
  • packages/freezed/example/lib/main.dart
  • packages/freezed/README.md
  • packages/freezed/example/pubspec.yaml
  • packages/freezed/example/lib/non_diagnosticable.dart
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: freezed (packages/freezed_lint, master, get)
  • GitHub Check: freezed (packages/freezed_annotation, master, get)
  • GitHub Check: freezed (packages/freezed, master, get)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lishaduck
Copy link
Copy Markdown
Contributor Author

lishaduck commented Mar 1, 2025

Also, is this the best way to bootstrap the package: (cd packages/freezed && dart pub get && dart run build_runner build -d) && (cd packages/freezed/example && dart pub get && dart run build_runner build -d) && (cd packages/freezed_annotation && dart pub get) && (cd packages/freezed_lint && dart pub get) && (cd benchmarks && dart pub get)?

If you'd accept a PR to the Melos v7 dev releases (which have seemed stable in my testing, and I think resolves your issues with Melos>3), I'd be happy to oblige. Same with Riverpod.

@lishaduck
Copy link
Copy Markdown
Contributor Author

Found some more outdated docs :)

@lishaduck
Copy link
Copy Markdown
Contributor Author

@rrousselGit, should freezed/example include freezed_lint, or should only the freezed_lint example include it?
Wondering because it's included in the README as of #1153, but it's also very ZeroVer, so I'm unsure how much we want to encourage it's use.

@rrousselGit
Copy link
Copy Markdown
Owner

I don't care either way

@rrousselGit
Copy link
Copy Markdown
Owner

Also, is this the best way to bootstrap the package: (cd packages/freezed && dart pub get && dart run build_runner build -d) && (cd packages/freezed/example && dart pub get && dart run build_runner build -d) && (cd packages/freezed_annotation && dart pub get) && (cd packages/freezed_lint && dart pub get) && (cd benchmarks && dart pub get)?

If you'd accept a PR to the Melos v7 dev releases (which have seemed stable in my testing, and I think resolves your issues with Melos>3), I'd be happy to oblige. Same with Riverpod.

I use melos 2.0 on purpose. I don't want to upgrade

@lishaduck
Copy link
Copy Markdown
Contributor Author

@rrousselGit, can we merge this and leave the other changes for follow ups?

@rrousselGit rrousselGit merged commit 44b3cee into rrousselGit:master Mar 3, 2025
4 checks passed
@rrousselGit
Copy link
Copy Markdown
Owner

Thanks!

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.

Docs need updating for Freezed 3

2 participants