xsahil03x / super_enum

Create super-powered dart enums similar to sealed classes in Kotlin
https://pub.dev/packages/super_enum
MIT License
116 stars 13 forks source link

Copy comments to generated file #28

Closed passsy closed 4 years ago

passsy commented 4 years ago

It would be very helpful when comments on the enum values would also be rendered to the generated source

@superEnum
enum _Result {
  /// Comment #1
  @generic
  @Data(fields: [
    DataField('data', Generic),
    DataField('message', String),
  ])
  Success,

  @object
  Error,
}
abstract class Result<T> extends Equatable {
  const Result(this._type);

   /// Comment #1
  factory Result.success({@required T data, @required String message}) =
      Success<T>;

  // ...
}

/// Comment #1
class Success<T> extends Result<T> {
  /// Comment #1
  const Success({@required this.data, @required this.message})
      : super(_Result.Success);
astralstriker commented 4 years ago

Great idea, I will update here once I verify its feasibility.

xsahil03x commented 4 years ago

@astralstriker I just did a quick google and I think it's feasible to implement.

Here's a quick link: https://github.com/dart-lang/source_gen/issues/409

xsahil03x commented 4 years ago

parking this as there was some issue with dart analyzer package which now has been fixed in bleeding edge. We will implement this as soon as it releases in the stable branch.

https://github.com/dart-lang/source_gen/issues/456 https://github.com/dart-lang/sdk/issues/40865