Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: pkg/analysis_server/tool/spec/to_html.dart

Issue 1431683002: Refactor analysis server code generation to re-use logic from analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/tool/spec/text_formatter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2164c9fa965755c0407e4ee13bfe61f25fd19bcf..6f55808f6e63df8a6f3f384732ba8479b005bc60 100644
--- a/pkg/analysis_server/tool/spec/to_html.dart
+++ b/pkg/analysis_server/tool/spec/to_html.dart
@@ -11,12 +11,12 @@ library to.html;
import 'dart:convert';
+import 'package:analyzer/src/codegen/html.dart';
+import 'package:analyzer/src/codegen/tools.dart';
import 'package:html/dom.dart' as dom;
import 'api.dart';
-import 'codegen_tools.dart';
import 'from_html.dart';
-import 'html_tools.dart';
/**
* Embedded stylesheet
@@ -81,8 +81,9 @@ dt.typeDefinition {
}
'''.trim();
-final GeneratedFile target = new GeneratedFile('../../doc/api.html', () {
- ToHtmlVisitor visitor = new ToHtmlVisitor(readApi());
+final GeneratedFile target =
+ new GeneratedFile('doc/api.html', (String pkgPath) {
+ ToHtmlVisitor visitor = new ToHtmlVisitor(readApi(pkgPath));
dom.Document document = new dom.Document();
document.append(new dom.DocumentType('html', null, null));
for (dom.Node node in visitor.collectHtml(visitor.visitApi)) {
@@ -92,13 +93,6 @@ final GeneratedFile target = new GeneratedFile('../../doc/api.html', () {
});
/**
- * Translate spec_input.html into api.html.
- */
-main() {
- target.generate();
-}
-
-/**
* Visitor that records the mapping from HTML elements to various kinds of API
* nodes.
*/
@@ -204,6 +198,103 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
}
}
+ void generateDomainIndex(Domain domain) {
+ h4(() {
+ write(domain.name);
+ write(' (');
+ link('domain_${domain.name}', () => write('\u2191'));
+ write(')');
+ });
+ if (domain.requests.length > 0) {
+ element('div', {'class': 'subindex'}, () {
+ generateRequestsIndex(domain.requests);
+ if (domain.notifications.length > 0) {
+ generateNotificationsIndex(domain.notifications);
+ }
+ });
+ } else if (domain.notifications.length > 0) {
+ element('div', {'class': 'subindex'}, () {
+ generateNotificationsIndex(domain.notifications);
+ });
+ }
+ }
+
+ void generateIndex() {
+ h3(() => write('Domains'));
+ for (var domain in api.domains) {
+ if (domain.requests.length == 0 && domain.notifications == 0) continue;
+ generateDomainIndex(domain);
+ }
+
+ generateTypesIndex(definedTypes);
+ generateRefactoringsIndex(api.refactorings);
+ }
+
+ void generateNotificationsIndex(Iterable<Notification> notifications) {
+ h5(() => write("Notifications"));
+ element('div', {'class': 'subindex'}, () {
+ element('ul', {}, () {
+ for (var notification in notifications) {
+ element(
+ 'li',
+ {},
+ () => link('notification_${notification.longEvent}',
+ () => write(notification.event)));
+ }
+ });
+ });
+ }
+
+ void generateRefactoringsIndex(Iterable<Refactoring> refactorings) {
+ h3(() {
+ write("Refactorings");
+ write(' (');
+ link('refactorings', () => write('\u2191'));
+ write(')');
+ });
+ // TODO: Individual refactorings are not yet hyperlinked.
+ element('div', {'class': 'subindex'}, () {
+ element('ul', {}, () {
+ for (var refactoring in refactorings) {
+ element(
+ 'li',
+ {},
+ () => link('refactoring_${refactoring.kind}',
+ () => write(refactoring.kind)));
+ }
+ });
+ });
+ }
+
+ void generateRequestsIndex(Iterable<Request> requests) {
+ h5(() => write("Requests"));
+ element('ul', {}, () {
+ for (var request in requests) {
+ element(
+ 'li',
+ {},
+ () => link(
+ 'request_${request.longMethod}', () => write(request.method)));
+ }
+ });
+ }
+
+ void generateTypesIndex(Set<String> types) {
+ h3(() {
+ write("Types");
+ write(' (');
+ link('types', () => write('\u2191'));
+ write(')');
+ });
+ element('div', {'class': 'subindex'}, () {
+ element('ul', {}, () {
+ for (var type in types) {
+ element('li', {}, () => link('type_$type', () => write(type)));
+ }
+ });
+ });
+ }
+
void javadocParams(TypeObject typeObject) {
if (typeObject != null) {
for (TypeObjectField field in typeObject.fields) {
@@ -493,103 +584,6 @@ class ToHtmlVisitor extends HierarchicalApiVisitor
super.visitTypes(types);
});
}
-
- void generateIndex() {
- h3(() => write('Domains'));
- for (var domain in api.domains) {
- if (domain.requests.length == 0 && domain.notifications == 0) continue;
- generateDomainIndex(domain);
- }
-
- generateTypesIndex(definedTypes);
- generateRefactoringsIndex(api.refactorings);
- }
-
- void generateDomainIndex(Domain domain) {
- h4(() {
- write(domain.name);
- write(' (');
- link('domain_${domain.name}', () => write('\u2191'));
- write(')');
- });
- if (domain.requests.length > 0) {
- element('div', {'class': 'subindex'}, () {
- generateRequestsIndex(domain.requests);
- if (domain.notifications.length > 0) {
- generateNotificationsIndex(domain.notifications);
- }
- });
- } else if (domain.notifications.length > 0) {
- element('div', {'class': 'subindex'}, () {
- generateNotificationsIndex(domain.notifications);
- });
- }
- }
-
- void generateRequestsIndex(Iterable<Request> requests) {
- h5(() => write("Requests"));
- element('ul', {}, () {
- for (var request in requests) {
- element(
- 'li',
- {},
- () => link(
- 'request_${request.longMethod}', () => write(request.method)));
- }
- });
- }
-
- void generateNotificationsIndex(Iterable<Notification> notifications) {
- h5(() => write("Notifications"));
- element('div', {'class': 'subindex'}, () {
- element('ul', {}, () {
- for (var notification in notifications) {
- element(
- 'li',
- {},
- () => link('notification_${notification.longEvent}',
- () => write(notification.event)));
- }
- });
- });
- }
-
- void generateTypesIndex(Set<String> types) {
- h3(() {
- write("Types");
- write(' (');
- link('types', () => write('\u2191'));
- write(')');
- });
- element('div', {'class': 'subindex'}, () {
- element('ul', {}, () {
- for (var type in types) {
- element('li', {}, () => link('type_$type', () => write(type)));
- }
- });
- });
- }
-
- void generateRefactoringsIndex(Iterable<Refactoring> refactorings) {
- h3(() {
- write("Refactorings");
- write(' (');
- link('refactorings', () => write('\u2191'));
- write(')');
- });
- // TODO: Individual refactorings are not yet hyperlinked.
- element('div', {'class': 'subindex'}, () {
- element('ul', {}, () {
- for (var refactoring in refactorings) {
- element(
- 'li',
- {},
- () => link('refactoring_${refactoring.kind}',
- () => write(refactoring.kind)));
- }
- });
- });
- }
}
/**
« no previous file with comments | « pkg/analysis_server/tool/spec/text_formatter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698