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

Side by Side Diff: pkg/analysis_server/tool/spec/to_html.dart

Issue 461283002: Improve spec style and minor changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/tool/spec/spec_input.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Code for displaying the API as HTML. This is used both for generating a 6 * Code for displaying the API as HTML. This is used both for generating a
7 * full description of the API as a web page, and for generating doc comments 7 * full description of the API as a web page, and for generating doc comments
8 * in generated code. 8 * in generated code.
9 */ 9 */
10 library to.html; 10 library to.html;
11 11
12 import 'dart:convert'; 12 import 'dart:convert';
13 import 'dart:io'; 13 import 'dart:io';
14 14
15 import 'package:html5lib/dom.dart' as dom; 15 import 'package:html5lib/dom.dart' as dom;
16 16
17 import 'api.dart'; 17 import 'api.dart';
18 import 'codegen_tools.dart'; 18 import 'codegen_tools.dart';
19 import 'from_html.dart'; 19 import 'from_html.dart';
20 import 'html_tools.dart'; 20 import 'html_tools.dart';
21 21
22 /** 22 /**
23 * Embedded stylesheet 23 * Embedded stylesheet
24 */ 24 */
25 final String stylesheet = ''' 25 final String stylesheet = '''
26 body {
27 font-family: sans-serif, serif;
28 padding-left: 5%;
29 padding-right: 5%;
30 }
26 h1 { 31 h1 {
27 text-align: center; 32 text-align: center;
28 } 33 }
34 h2.domain {
35 border-bottom: 3px solid rgb(160, 160, 160);
36 }
29 pre { 37 pre {
30 margin: 0px; 38 margin: 0px;
31 } 39 }
32 div.box { 40 div.box {
33 border: 1px solid rgb(0, 0, 0); 41 border: 1px solid rgb(0, 0, 0);
34 background-color: rgb(207, 226, 243); 42 background-color: rgb(207, 226, 243);
35 padding: 0.5em; 43 padding: 0.5em;
36 } 44 }
45 div.hangingIndent {
46 padding-left: 3em;
47 text-indent: -3em;
48 }
37 dt { 49 dt {
38 margin-top: 1em; 50 margin-top: 1em;
39 margin-bottom: 1em; 51 margin-bottom: 1em;
40 } 52 }
41 div.hangingIndent { 53 dt.notification {
42 padding-left: 3em; 54 font-weight: bold;
43 text-indent: -3em; 55 }
56 dt.refactoring {
57 font-weight: bold;
58 }
59 dt.request {
60 font-weight: bold;
61 }
62 dt.typeDefinition {
63 font-weight: bold;
44 } 64 }
45 '''.trim(); 65 '''.trim();
46 66
47 /** 67 /**
48 * Helper methods for creating HTML elements. 68 * Helper methods for creating HTML elements.
49 */ 69 */
50 abstract class HtmlMixin { 70 abstract class HtmlMixin {
51 void element(String name, Map<dynamic, String> attributes, [void callback()]); 71 void element(String name, Map<dynamic, String> attributes, [void callback()]);
52 72
53 void anchor(String id, void callback()) { 73 void anchor(String id, void callback()) {
(...skipping 16 matching lines...) Expand all
70 void body(void callback()) => element('body', {}, callback); 90 void body(void callback()) => element('body', {}, callback);
71 void dd(void callback()) => element('dd', {}, callback); 91 void dd(void callback()) => element('dd', {}, callback);
72 void dl(void callback()) => element('dl', {}, callback); 92 void dl(void callback()) => element('dl', {}, callback);
73 void dt(String cls, void callback()) => element('dt', { 93 void dt(String cls, void callback()) => element('dt', {
74 'class': cls 94 'class': cls
75 }, callback); 95 }, callback);
76 void gray(void callback()) => element('span', { 96 void gray(void callback()) => element('span', {
77 'style': 'color:#999999' 97 'style': 'color:#999999'
78 }, callback); 98 }, callback);
79 void h1(void callback()) => element('h1', {}, callback); 99 void h1(void callback()) => element('h1', {}, callback);
80 void h2(void callback()) => element('h2', {}, callback); 100 void h2(String cls, void callback()) {
101 if (cls == null) {
102 return element('h2', {}, callback);
103 }
104 return element('h2', {
105 'class': cls
106 }, callback);
107 }
81 void h3(void callback()) => element('h3', {}, callback); 108 void h3(void callback()) => element('h3', {}, callback);
82 void h4(void callback()) => element('h4', {}, callback); 109 void h4(void callback()) => element('h4', {}, callback);
83 void hangingIndent(void callback()) => element('div', { 110 void hangingIndent(void callback()) => element('div', {
84 'class': 'hangingIndent' 111 'class': 'hangingIndent'
85 }, callback); 112 }, callback);
86 void head(void callback()) => element('head', {}, callback); 113 void head(void callback()) => element('head', {}, callback);
87 void html(void callback()) => element('html', {}, callback); 114 void html(void callback()) => element('html', {}, callback);
88 void i(void callback()) => element('i', {}, callback); 115 void i(void callback()) => element('i', {}, callback);
89 void p(void callback()) => element('p', {}, callback); 116 void p(void callback()) => element('p', {}, callback);
90 void pre(void callback()) => element('pre', {}, callback); 117 void pre(void callback()) => element('pre', {}, callback);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 @override 290 @override
264 void visitTypes(Types types) { 291 void visitTypes(Types types) {
265 translateHtml(types.html); 292 translateHtml(types.html);
266 dl(() { 293 dl(() {
267 super.visitTypes(types); 294 super.visitTypes(types);
268 }); 295 });
269 } 296 }
270 297
271 @override 298 @override
272 void visitDomain(Domain domain) { 299 void visitDomain(Domain domain) {
273 h2(() { 300 h2('domain', () {
274 anchor('domain_${domain.name}', () { 301 anchor('domain_${domain.name}', () {
275 write('Domain: ${domain.name}'); 302 write('Domain: ${domain.name}');
276 }); 303 });
277 }); 304 });
278 translateHtml(domain.html); 305 translateHtml(domain.html);
279 if (domain.requests.isNotEmpty) { 306 if (domain.requests.isNotEmpty) {
280 h3(() { 307 h3(() {
281 write('Requests'); 308 write('Requests');
282 }); 309 });
283 dl(() { 310 dl(() {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 */ 561 */
535 main() { 562 main() {
536 ToHtmlVisitor visitor = new ToHtmlVisitor(readApi()); 563 ToHtmlVisitor visitor = new ToHtmlVisitor(readApi());
537 dom.Document document = new dom.Document(); 564 dom.Document document = new dom.Document();
538 for (dom.Node node in visitor.collectHtml(visitor.visitApi)) { 565 for (dom.Node node in visitor.collectHtml(visitor.visitApi)) {
539 document.append(node); 566 document.append(node);
540 } 567 }
541 File outputFile = new File('../../doc/api.html'); 568 File outputFile = new File('../../doc/api.html');
542 outputFile.writeAsStringSync(document.outerHtml); 569 outputFile.writeAsStringSync(document.outerHtml);
543 } 570 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/tool/spec/spec_input.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698