From d8908eecfb57b61fed35c6b90ab663d17f82adec Mon Sep 17 00:00:00 2001 From: Jonathan Koren Date: Tue, 21 Jan 2020 13:58:17 -0800 Subject: [PATCH 1/2] Fix a crash when using --no-generate-docs --- lib/src/model/documentation.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/model/documentation.dart b/lib/src/model/documentation.dart index 8344fddd52..53cba5b208 100644 --- a/lib/src/model/documentation.dart +++ b/lib/src/model/documentation.dart @@ -45,6 +45,12 @@ class Documentation { List get commentRefs => _element.commentRefs; void _renderDocumentation(bool processAllDocs) { + if (!_element.hasDocumentation) { + _asHtml = ''; + _asOneLiner = ''; + _hasExtendedDocs = false; + return; + } Tuple2, bool> parseResult = _parseDocumentation(processAllDocs); if (_hasExtendedDocs != null) { From e70731953924ea513ebcbd6117f4e5357a4b4179 Mon Sep 17 00:00:00 2001 From: Jonathan Koren Date: Wed, 22 Jan 2020 12:29:54 -0800 Subject: [PATCH 2/2] Move check to _parseDocumentation --- lib/src/model/documentation.dart | 9 +++------ lib/src/render/documentation_renderer.dart | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/model/documentation.dart b/lib/src/model/documentation.dart index 53cba5b208..41c72b1eda 100644 --- a/lib/src/model/documentation.dart +++ b/lib/src/model/documentation.dart @@ -45,12 +45,6 @@ class Documentation { List get commentRefs => _element.commentRefs; void _renderDocumentation(bool processAllDocs) { - if (!_element.hasDocumentation) { - _asHtml = ''; - _asOneLiner = ''; - _hasExtendedDocs = false; - return; - } Tuple2, bool> parseResult = _parseDocumentation(processAllDocs); if (_hasExtendedDocs != null) { @@ -71,6 +65,9 @@ class Documentation { /// Returns a tuple of List and hasExtendedDocs Tuple2, 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 44466ea426..a2ddcc7234 100644 --- a/lib/src/render/documentation_renderer.dart +++ b/lib/src/render/documentation_renderer.dart @@ -13,6 +13,9 @@ abstract class DocumentationRenderer { class DocumentationRendererHtml extends DocumentationRenderer { @override Tuple2 render(List 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')) {