Skip to content
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
7 changes: 2 additions & 5 deletions lib/src/markdown_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,12 @@ class MarkdownDocument extends md.Document {
var textContent = _htmlEscape.convert(referenceText);
var linkedElement = result.commentReferable;
if (linkedElement != null) {
if (linkedElement.href != null) {
if (linkedElement.href case var href?) {
var anchor = md.Element.text('a', textContent);
if (linkedElement is ModelElement && linkedElement.isDeprecated) {
anchor.attributes['class'] = 'deprecated';
}
var href = linkedElement.href;
if (href != null) {
anchor.attributes['href'] = href;
}
anchor.attributes['href'] = href;
return anchor;
} else {
// Otherwise this would be `linkedElement.linkedName`, but link bodies
Expand Down
5 changes: 5 additions & 0 deletions lib/src/model/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ class Category
String get linkedName {
final unbrokenName = name.replaceAll(' ', ' ');
if (isDocumented) {
final href = this.href;
if (href == null) {
throw StateError("Requesting the 'linkedName' of a non-canonical "
"category: '$name'");
}
return '<a href="$href">$unbrokenName</a>';
} else {
return unbrokenName;
Expand Down
1 change: 1 addition & 0 deletions lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ abstract class ModelElement
element.kind == ElementKind.NEVER ||
this is ModelFunction);

final href = this.href;
if (href == null) {
if (isPublicAndPackageDocumented) {
warn(PackageWarning.noCanonicalFound);
Expand Down