Skip to content

Commit

Permalink
Revert "Initial commit"
Browse files Browse the repository at this point in the history
This reverts commit d0e41ad.
  • Loading branch information
cesarParra committed Aug 8, 2024
1 parent b370648 commit e69df8f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 130 deletions.
42 changes: 10 additions & 32 deletions lib/src/model/doc_comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ class DocComment {

Map<String, dynamic> toJson() => _$DocCommentToJson(this);

List<String> get descriptionLines {
print('getting description lines ${_descriptionLines.length}');
print('with annotations ${annotations.map((e) => e.toJson())}');
return _descriptionLines.isNotEmpty
? _descriptionLines
: annotations
.firstWhereOrNull((element) => element.name == 'description')
?.bodyLines ??
[];
}
List<String> get descriptionLines => _descriptionLines.isNotEmpty
? _descriptionLines
: annotations
.firstWhereOrNull((element) => element.name == 'description')
?.bodyLines ?? [];

set descriptionLines(List<String> descriptionLines) {
List<String> cleanLines = [];
Expand All @@ -56,33 +51,16 @@ class DocComment {
trimmedLine = '';
}

cleanLines.add(trimmedLine);
}
}

// If the first line is empty, remove it
if (cleanLines.isNotEmpty && cleanLines.first.isEmpty) {
cleanLines.removeAt(0);
}
// If the last line is empty, remove it
if (cleanLines.isNotEmpty && cleanLines.last.isEmpty) {
cleanLines.removeLast();
}

// When there are 2 blank strings back to back, remove one of them
for (int i = 0; i < cleanLines.length - 1; i++) {
if (cleanLines[i].isEmpty && cleanLines[i + 1].isEmpty) {
cleanLines.removeAt(i);
if (trimmedLine.isNotEmpty) {
cleanLines.add(trimmedLine);
}
}
}

_descriptionLines = cleanLines;
}

/// Gets the description as a single line.
String get description => descriptionLines
.map((e) => e == '' ? '\n' : e)
.join('');
String get description => descriptionLines.join(' ');

List<DocCommentAnnotation> annotationsByName(String annotationName) {
return annotations
Expand All @@ -99,7 +77,7 @@ class DocCommentAnnotation {

List<String> bodyLines = [];

String get body => bodyLines.map((e) => e.isEmpty ? '\n' : e).join('');
String get body => bodyLines.join(' ');

DocCommentAnnotation(this.name, body) {
if (body is String) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/node/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ String _parseFromDeclarationBody(String declarationBody) {

void main() {
exports.reflect = allowInterop(
(String declarationBody) => _parseFromDeclarationBody(declarationBody));
(String declarationBody) => _parseFromDeclarationBody(declarationBody));
}
2 changes: 0 additions & 2 deletions lib/src/service/apex_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,8 @@ class ApexClassListener extends ApexParserBaseListener {
// We take and parse the first doc comment, in case it is the
// start of a group.
String potentialDocComment = allDocComments.first;
print('potentialDocComment: $potentialDocComment');
DocComment docCommentObject =
ApexdocParser.parseFromBody(potentialDocComment);
print('docCommentObject: ${docCommentObject.description}');

if (docCommentObject.annotations
.any((element) => element.name.toLowerCase() == 'start-group')) {
Expand Down
35 changes: 3 additions & 32 deletions lib/src/service/apexdoc_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ class ApexdocListener extends ApexdocParserBaseListener {
descriptionLines.add(_sanitizeLineStart(descriptionText));
}

@override
void enterDescriptionNewline(DescriptionNewlineContext ctx) {
descriptionLines.add('');
}

@override
void exitDescriptionLine(DescriptionLineContext ctx) {
generatedDocComment.descriptionLines = descriptionLines;
Expand Down Expand Up @@ -67,35 +62,11 @@ class ApexdocListener extends ApexdocParserBaseListener {
}

List<String> _getContentLines(List<BlockTagContentContext> blockTagContents) {
final contentLines = blockTagContents
.map((e) => e.text)
final rawContent = blockTagContents.map((e) => e.text).join('');
return LineSplitter.split(rawContent)
.map((e) => _sanitizeLineStart(e))
.map((e) => LineSplitter.split(e)
.map((e) => _sanitizeLineStart(e))
.map((e) => e.trim())
.join(''))
.map((e) => e.trim())
.where((element) => element.isNotEmpty)
.toList();

// if there are 2 consecutive empty lines, remove one
for (var i = 0; i < contentLines.length - 1; i++) {
if (contentLines[i].isEmpty && contentLines[i + 1].isEmpty) {
contentLines.removeAt(i);
}
}

// if the first line is empty, remove it
if (contentLines.isNotEmpty && contentLines.first.isEmpty) {
contentLines.removeAt(0);
}

// if the last line is empty, remove it
if (contentLines.isNotEmpty && contentLines.last.isEmpty) {
contentLines.removeLast();
}

print('about to return content lines $contentLines');
return contentLines;
}

String _sanitizeLineStart(String line) {
Expand Down
Loading

0 comments on commit e69df8f

Please sign in to comment.