Chromium Code Reviews| Index: pkg/analysis_server/tool/spec/to_html.dart |
| diff --git a/pkg/analysis_server/tool/spec/to_html.dart b/pkg/analysis_server/tool/spec/to_html.dart |
| index 453f96266ce295be402c46225964bfbe86a4dafc..aec93d23323b8cd1a4f82f8228a35ad15ab1cf26 100644 |
| --- a/pkg/analysis_server/tool/spec/to_html.dart |
| +++ b/pkg/analysis_server/tool/spec/to_html.dart |
| @@ -22,8 +22,7 @@ import 'html_tools.dart'; |
| /** |
| * Embedded stylesheet |
| */ |
| -final String stylesheet = |
| - ''' |
| +final String stylesheet = ''' |
| h1 { |
| text-align: center; |
| } |
| @@ -39,8 +38,7 @@ dt { |
| margin-top: 1em; |
| margin-bottom: 1em; |
| } |
| -'''.trim( |
| - ); |
| +'''.trim(); |
| /** |
| * Helper methods for creating HTML elements. |
| @@ -98,8 +96,7 @@ abstract class HtmlMixin { |
| * } |
| * } |
| */ |
| -class TypeVisitor extends HierarchicalApiVisitor with HtmlMixin, |
| - HtmlCodeGenerator { |
| +class TypeVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlCodeGenerator { |
| /** |
| * Set of fields which should be shown in boldface, or null if no field |
| * should be shown in boldface. |
| @@ -200,7 +197,7 @@ class TypeVisitor extends HierarchicalApiVisitor with HtmlMixin, |
| class ApiMappings extends HierarchicalApiVisitor { |
| ApiMappings(Api api) : super(api); |
| - Map<dom.Element, Domain> domains = <dom.Element, Domain> {}; |
| + Map<dom.Element, Domain> domains = <dom.Element, Domain>{}; |
| @override |
| void visitDomain(Domain domain) { |
| @@ -211,8 +208,7 @@ class ApiMappings extends HierarchicalApiVisitor { |
| /** |
| * Visitor that generates HTML documentation of the API. |
| */ |
| -class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| - { |
| +class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator { |
| /** |
| * Set of types defined in the API. |
| */ |
| @@ -298,8 +294,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| }); |
| dd(() { |
| box(() { |
| - showType('notification', notification.notificationType, |
| - notification.params); |
| + showType('notification', notification.notificationType, notification.params); |
| }); |
| translateHtml(notification.html); |
| describePayload(notification.params, 'Parameters'); |
| @@ -310,19 +305,23 @@ class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| * Copy the contents of the given HTML element, translating the special |
| * elements that define the API appropriately. |
| */ |
| - void translateHtml(dom.Element html) { |
| + void translateHtml(dom.Element html, {bool squashParagraphs: false}) { |
| for (dom.Node node in html.nodes) { |
| if (node is dom.Element) { |
| + if (squashParagraphs && node.localName == 'p') { |
| + translateHtml(node, squashParagraphs: squashParagraphs); |
| + break; |
|
Paul Berry
2014/08/12 18:04:02
Should be "continue;"
jwren
2014/08/12 18:23:08
Done.
|
| + } |
| switch (node.localName) { |
| case 'api': |
| - translateHtml(node); |
| + translateHtml(node, squashParagraphs: squashParagraphs); |
| break; |
| case 'domain': |
| visitDomain(apiMappings.domains[node]); |
| break; |
| case 'head': |
| head(() { |
| - translateHtml(node); |
| + translateHtml(node, squashParagraphs: squashParagraphs); |
| element('style', {}, () { |
| writeln(stylesheet); |
| }); |
| @@ -335,12 +334,12 @@ class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| visitTypes(api.types); |
| break; |
| case 'version': |
| - translateHtml(node); |
| + translateHtml(node, squashParagraphs: squashParagraphs); |
| break; |
| default: |
| if (!specialElements.contains(node.localName)) { |
| element(node.localName, node.attributes, () { |
| - translateHtml(node); |
| + translateHtml(node, squashParagraphs: squashParagraphs); |
| }); |
| } |
| } |
| @@ -371,8 +370,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| if (shortDesc != null) { |
| write('$shortDesc: '); |
| } |
| - TypeVisitor typeVisitor = new TypeVisitor(api, fieldsToBold: fieldsToBold |
| - ); |
| + TypeVisitor typeVisitor = new TypeVisitor(api, fieldsToBold: fieldsToBold); |
| addAll(typeVisitor.collectHtml(() { |
| typeVisitor.visitTypeDecl(type); |
| })); |
| @@ -401,6 +399,16 @@ class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| } |
| } |
| + void javadocParams(TypeObject typeObject) { |
| + if (typeObject != null) { |
| + for (TypeObjectField field in typeObject.fields) { |
| + write('@param ${field.name} '); |
| + translateHtml(field.html, squashParagraphs: true); |
| + br(); |
| + } |
| + } |
| + } |
| + |
| @override |
| void visitRequest(Request request) { |
| dt('request', () { |
| @@ -446,8 +454,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor with HtmlMixin, HtmlGenerator |
| void visitTypeEnumValue(TypeEnumValue typeEnumValue) { |
| bool isDocumented = false; |
| for (dom.Node node in typeEnumValue.html.nodes) { |
| - if ((node is dom.Element && node.localName != 'code') || (node is dom.Text |
| - && node.text.trim().isNotEmpty)) { |
| + if ((node is dom.Element && node.localName != 'code') || (node is dom.Text && node.text.trim().isNotEmpty)) { |
| isDocumented = true; |
| break; |
| } |