Skip to content

Commit 65e2759

Browse files
committed
Add new warning to package warning definitions
1 parent 3dc95c0 commit 65e2759

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

lib/src/model/documentation_comment.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ mixin DocumentationComment
697697
if (result.isEmpty) {
698698
warn(PackageWarning.missingCodeBlockLanguage,
699699
message:
700-
'A fenced code block in Markdown should have a language specified.');
700+
'A fenced code block in Markdown should have a language specified');
701701
}
702702
});
703703
}

lib/src/warnings.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ const Map<PackageWarning, PackageWarningDefinition> packageWarningDefinitions =
256256
// Defaults to ignore as this doesn't impact the docs severely but is
257257
// useful for debugging package structure.
258258
defaultWarningMode: PackageWarningMode.ignore),
259+
PackageWarning.missingCodeBlockLanguage: PackageWarningDefinition(
260+
PackageWarning.missingCodeBlockLanguage,
261+
'missing-code-block-language',
262+
'A fenced code block is missing a specified language.',
263+
longHelp: [
264+
'To enable proper syntax highlighting of Markdown code blocks,',
265+
'Dartdoc requires code blocks to specify the language used after',
266+
'the initial declaration. As an example, to specify Dart you would',
267+
'specify ```dart or ~~~dart.'
268+
]),
259269
};
260270

261271
/// Something that package warnings can be called on. Optionally associated

test/documentation_comment_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ Text.
856856
packageGraph.packageWarningCounter.hasWarning(
857857
libraryModel,
858858
PackageWarning.missingCodeBlockLanguage,
859-
'A fenced code block in Markdown should have a language specified.'),
859+
'A fenced code block in Markdown should have a language specified'),
860860
isTrue);
861861
});
862862

@@ -872,7 +872,7 @@ Text.
872872
packageGraph.packageWarningCounter.hasWarning(
873873
libraryModel,
874874
PackageWarning.missingCodeBlockLanguage,
875-
'A fenced code block in Markdown should have a language specified.'),
875+
'A fenced code block in Markdown should have a language specified'),
876876
isTrue);
877877
});
878878

@@ -888,7 +888,7 @@ Text.
888888
packageGraph.packageWarningCounter.hasWarning(
889889
libraryModel,
890890
PackageWarning.missingCodeBlockLanguage,
891-
'A fenced code block in Markdown should have a language specified.'),
891+
'A fenced code block in Markdown should have a language specified'),
892892
isFalse);
893893
});
894894

@@ -902,7 +902,7 @@ Text.
902902
packageGraph.packageWarningCounter.hasWarning(
903903
libraryModel,
904904
PackageWarning.missingCodeBlockLanguage,
905-
'A fenced code block in Markdown should have a language specified.'),
905+
'A fenced code block in Markdown should have a language specified'),
906906
isFalse);
907907
});
908908
}, onPlatform: {

0 commit comments

Comments
 (0)