Fix a crash when using --no-generate-docs (#2137)
* Fix a crash when using --no-generate-docs
* Move check to _parseDocumentation
diff --git a/lib/src/model/documentation.dart b/lib/src/model/documentation.dart
index 8344fdd..41c72b1 100644
--- a/lib/src/model/documentation.dart
+++ b/lib/src/model/documentation.dart
@@ -65,6 +65,9 @@
/// Returns a tuple of List<md.Node> and hasExtendedDocs
Tuple2<List<md.Node>, bool> _parseDocumentation(bool processFullDocs) {
+ if (!_element.hasDocumentation) {
+ return Tuple2([], false);
+ }
String text = _element.documentation;
showWarningsForGenericsOutsideSquareBracketsBlocks(text, _element);
MarkdownDocument document =
diff --git a/lib/src/render/documentation_renderer.dart b/lib/src/render/documentation_renderer.dart
index 44466ea..a2ddcc7 100644
--- a/lib/src/render/documentation_renderer.dart
+++ b/lib/src/render/documentation_renderer.dart
@@ -13,6 +13,9 @@
class DocumentationRendererHtml extends DocumentationRenderer {
@override
Tuple2<String, String> render(List<md.Node> nodes, bool processFullDocs) {
+ if (nodes.isEmpty) {
+ return Tuple2('', '');
+ }
var rawHtml = md.HtmlRenderer().render(nodes);
var asHtmlDocument = parse(rawHtml);
for (var s in asHtmlDocument.querySelectorAll('script')) {