isacjunior / doc_widget

An easier way that documents your widgets.

Home Page:https://pub.dev/packages/doc_widget

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation parse fail

LaurentiuSimionescu opened this issue · comments

Describe the bug
If there is more the one line documentation line for fields then parsing fails.

/// Title description
final String title;

The above will pass.

  /// Title description
  /// Second line of description
  final String title;

The above will not pass.

To Reproduce
Steps to reproduce the behavior:

/// ```dart
/// final description = Description('Text');
/// ```
@docWidget
class Description extends StatelessWidget {
  Description(this.title);

  /// Title description
  /// Second line of description
  final String title;

  @override
  Widget build(BuildContext context) => const Text('Test');
}

Expected behavior
Documentation should be parsed for the field title.

Additional context
Error that is returned:

`  Could not format because the source could not be parsed:
  
  line 5, column 31 of .: Unterminated string literal.
    ╷
  5 │ description: 'Title description
    │                               ^
    ╵
  line 6, column 33 of .: Unterminated string literal.
    ╷
  6 │  Second line of description',),];
    │                                 ^
`
String? getDescription(String name, List<FieldElement> fields) {
  final hasField = fields.any((field) => field.name == name);
  if (hasField) {
    final field = fields.firstWhere((element) => element.name == name);
    final hasDocumentation = field.documentationComment != null;
    if (hasDocumentation)
      return hasDocumentation
          ? removeDocumentationComment(field.documentationComment)
          : null;
  }
  return null;
}

All my search leads me to this method

Has the same problem