Index: pkg/analyzer_plugin/tool/spec/to_html.dart |
diff --git a/pkg/analyzer_plugin/tool/spec/to_html.dart b/pkg/analyzer_plugin/tool/spec/to_html.dart |
index f71f98cc6d596327c385e7d0a6908ad5bc158811..d0d133ee250a54752d0604b2b03a5c71a75d0e26 100644 |
--- a/pkg/analyzer_plugin/tool/spec/to_html.dart |
+++ b/pkg/analyzer_plugin/tool/spec/to_html.dart |
@@ -115,9 +115,6 @@ a:focus, a:hover { |
/* Styles for index */ |
-.subindex { |
-} |
- |
.subindex ul { |
padding-left: 0; |
margin-left: 0; |
@@ -142,6 +139,11 @@ final GeneratedFile target = |
return document.outerHtml; |
}); |
+String _toTitleCase(String str) { |
+ if (str.isEmpty) return str; |
+ return str.substring(0, 1).toUpperCase() + str.substring(1); |
+} |
+ |
/** |
* Visitor that records the mapping from HTML elements to various kinds of API |
* nodes. |
@@ -195,14 +197,20 @@ abstract class HtmlMixin { |
void head(void callback()) => element('head', {}, callback); |
void html(void callback()) => element('html', {}, callback); |
void i(void callback()) => element('i', {}, callback); |
- void link(String id, void callback()) { |
- element('a', {'href': '#$id'}, callback); |
+ void li(void callback()) => element('li', {}, callback); |
+ void link(String id, void callback(), [Map<dynamic, String> attributes]) { |
+ attributes ??= {}; |
+ attributes['href'] = '#$id'; |
+ element('a', attributes, callback); |
} |
void p(void callback()) => element('p', {}, callback); |
void pre(void callback()) => element('pre', {}, callback); |
+ void span(String cls, void callback()) => |
+ element('span', {'class': cls}, callback); |
void title(void callback()) => element('title', {}, callback); |
void tt(void callback()) => element('tt', {}, callback); |
+ void ul(void callback()) => element('ul', {}, callback); |
} |
/** |
@@ -269,6 +277,12 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
} |
} |
+ void generateDomainsHeader() { |
+ h1(() { |
+ write('Domains'); |
+ }); |
+ } |
+ |
void generateIndex() { |
h3(() => write('Domains')); |
for (var domain in api.domains) { |
@@ -337,6 +351,35 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
}); |
} |
+ void generateTableOfContents() { |
+ for (var domain in api.domains.where((domain) => !domain.experimental)) { |
+ if (domain.experimental) continue; |
+ |
+ writeln(); |
+ |
+ p(() { |
+ link('domain_${domain.name}', () { |
+ write(_toTitleCase(domain.name)); |
+ }); |
+ }); |
+ |
+ ul(() { |
+ for (Request request in domain.requests) { |
+ if (request.experimental) continue; |
+ |
+ li(() { |
+ link('request_${request.longMethod}', () { |
+ write(request.longMethod); |
+ }, request.deprecated ? {'class': 'deprecated'} : null); |
+ }); |
+ writeln(); |
+ } |
+ }); |
+ |
+ writeln(); |
+ } |
+ } |
+ |
void generateTypesIndex(Set<String> types) { |
h3(() { |
write("Types"); |
@@ -406,6 +449,9 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
continue; |
} |
switch (node.localName) { |
+ case 'domains': |
+ generateDomainsHeader(); |
+ break; |
case 'domain': |
visitDomain(apiMappings.domains[node]); |
break; |
@@ -432,6 +478,9 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
case 'version': |
translateHtml(node, squashParagraphs: squashParagraphs); |
break; |
+ case 'toc': |
+ generateTableOfContents(); |
+ break; |
case 'index': |
generateIndex(); |
break; |
@@ -495,11 +544,6 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
anchor('notification_${notification.longEvent}', () { |
write(notification.longEvent); |
}); |
- write(' ('); |
- link('notification_${notification.longEvent}', () { |
- write('#'); |
- }); |
- write(')'); |
}); |
dd(() { |
box(() { |
@@ -536,15 +580,10 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
if (request.experimental) { |
return; |
} |
- dt('request', () { |
+ dt(request.deprecated ? 'request deprecated' : 'request', () { |
anchor('request_${request.longMethod}', () { |
write(request.longMethod); |
}); |
- write(' ('); |
- link('request_${request.longMethod}', () { |
- write('#'); |
- }); |
- write(')'); |
}); |
dd(() { |
box(() { |
@@ -563,7 +602,10 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
if (typeDefinition.experimental) { |
return; |
} |
- dt('typeDefinition', () { |
+ dt( |
+ typeDefinition.deprecated |
+ ? 'typeDefinition deprecated' |
+ : 'typeDefinition', () { |
anchor('type_${typeDefinition.name}', () { |
write('${typeDefinition.name}: '); |
TypeVisitor typeVisitor = new TypeVisitor(api, short: true); |
@@ -595,7 +637,7 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
break; |
} |
} |
- dt('value', () { |
+ dt(typeEnumValue.deprecated ? 'value deprecated' : 'value', () { |
write(typeEnumValue.value); |
}); |
if (isDocumented) { |
@@ -626,22 +668,24 @@ class ToHtmlVisitor extends HierarchicalApiVisitor |
void visitTypeObjectField(TypeObjectField typeObjectField) { |
dt('field', () { |
b(() { |
- write(typeObjectField.name); |
+ if (typeObjectField.deprecated) { |
+ span('deprecated', () { |
+ write(typeObjectField.name); |
+ }); |
+ } else { |
+ write(typeObjectField.name); |
+ } |
if (typeObjectField.value != null) { |
write(' = ${JSON.encode(typeObjectField.value)}'); |
} else { |
- write(' ('); |
- if (typeObjectField.optional) { |
- gray(() { |
- write('optional'); |
- }); |
- write(' '); |
- } |
+ write(': '); |
TypeVisitor typeVisitor = new TypeVisitor(api, short: true); |
addAll(typeVisitor.collectHtml(() { |
typeVisitor.visitTypeDecl(typeObjectField.type); |
})); |
- write(')'); |
+ if (typeObjectField.optional) { |
+ gray(() => write(' (optional)')); |
+ } |
} |
}); |
}); |