Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EnumFieldRenderer. #3716

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/src/model/enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:dartdoc/src/model/model.dart';
import 'package:dartdoc/src/model_utils.dart' as model_utils;
import 'package:dartdoc/src/render/enum_field_renderer.dart';
import 'package:meta/meta.dart';

class Enum extends InheritingContainer with Constructable, MixedInTypes {
@override
Expand Down Expand Up @@ -97,7 +97,7 @@ class EnumField extends Field {
String get constantValueBase =>
element.library.featureSet.isEnabled(Feature.enhanced_enums)
? super.constantValueBase
: _fieldRenderer.renderValue(this);
: renderedName;

@override
List<DocumentationComment> get documentationFrom {
Expand All @@ -118,7 +118,10 @@ class EnumField extends Field {
}

@override
String get linkedName => _fieldRenderer.renderLinkedName(this);
String get linkedName {
var cssClass = isDeprecated ? ' class="deprecated"' : '';
return '<a$cssClass href="$href#$htmlId">$name</a>';
}

@override
bool get isCanonical {
Expand All @@ -137,5 +140,10 @@ class EnumField extends Field {
@override
Inheritable? get overriddenElement => null;

EnumFieldRenderer get _fieldRenderer => const EnumFieldRendererHtml();
@visibleForTesting
String get renderedName => name == 'values'
? 'const List&lt;<wbr>'
'<span class="type-parameter">${enclosingElement.name}</span>'
'&gt;'
: constantValue;
}
28 changes: 0 additions & 28 deletions lib/src/render/enum_field_renderer.dart

This file was deleted.

4 changes: 1 addition & 3 deletions test/enum_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'package:dartdoc/src/model/model.dart';
import 'package:dartdoc/src/model_utils.dart';
import 'package:dartdoc/src/render/enum_field_renderer.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';

Expand Down Expand Up @@ -603,8 +602,7 @@ enum E {
var oneValue =
library.enums.named('E').publicEnumValues.named('one') as EnumField;
expect(oneValue.linkedName, '<a href="$linkPrefix/E.html#one">one</a>');
expect(oneValue.constantValue,
equals(EnumFieldRendererHtml().renderValue(oneValue)));
expect(oneValue.constantValue, equals(oneValue.renderedName));
}

void test_values_haveIndices() async {
Expand Down
Loading