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

Side by Side Diff: tools/dom/docs/lib/docs.dart

Issue 119913002: Align source mirrors with runtime mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments + small fix. Created 6 years, 10 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 | « tests/utils/source_mirrors_test.dart ('k') | utils/apidoc/apidoc.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 * A library for extracting the documentation from the various HTML libraries 6 * A library for extracting the documentation from the various HTML libraries
7 * ([dart:html], [dart:svg], [dart:web_audio], [dart:indexed_db]) and saving 7 * ([dart:html], [dart:svg], [dart:web_audio], [dart:indexed_db]) and saving
8 * those documentation comments to a JSON file. 8 * those documentation comments to a JSON file.
9 */ 9 */
10 10
11 library docs; 11 library docs;
12 12
13 import '../../../../sdk/lib/_internal/dartdoc/lib/src/dart2js_mirrors.dart'; 13 import '../../../../sdk/lib/_internal/dartdoc/lib/src/dart2js_mirrors.dart';
14 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.da rt'; 14 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mir rors.dart';
15 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_ut il.dart'; 15 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_ut il.dart';
16 import '../../../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart'; 16 import '../../../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart';
17 import '../../../../sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart'; 17 import '../../../../sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart';
18 import '../../../../utils/apidoc/lib/metadata.dart'; 18 import '../../../../utils/apidoc/lib/metadata.dart';
19 import 'dart:async'; 19 import 'dart:async';
20 import 'dart:io'; 20 import 'dart:io';
21 21
22 /// The various HTML libraries. 22 /// The various HTML libraries.
23 const List<String> HTML_LIBRARY_NAMES = const ['dart:html', 23 const List<String> HTML_LIBRARY_NAMES = const ['dart:html',
24 'dart:indexed_db', 24 'dart:indexed_db',
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 (e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0)) 86 (e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
87 ..sort((x, y) => 87 ..sort((x, y) =>
88 x.uri.toString().toUpperCase().compareTo( 88 x.uri.toString().toUpperCase().compareTo(
89 y.uri.toString().toUpperCase())); 89 y.uri.toString().toUpperCase()));
90 90
91 for (LibraryMirror libMirror in sortedLibraries) { 91 for (LibraryMirror libMirror in sortedLibraries) {
92 print('Extracting documentation from ${libMirror.simpleName}.'); 92 print('Extracting documentation from ${libMirror.simpleName}.');
93 93
94 var libraryJson = {}; 94 var libraryJson = {};
95 var sortedClasses = _sortAndFilterMirrors( 95 var sortedClasses = _sortAndFilterMirrors(
96 libMirror.classes.values.toList(), ignoreDocsEditable: true); 96 classesOf(libMirror.declarations).toList(), ignoreDocsEditable: true);
97 97
98 for (ClassMirror classMirror in sortedClasses) { 98 for (ClassMirror classMirror in sortedClasses) {
99 print(' class: $classMirror');
99 var classJson = {}; 100 var classJson = {};
100 var sortedMembers = _sortAndFilterMirrors( 101 var sortedMembers = _sortAndFilterMirrors(
101 classMirror.members.values.toList()); 102 membersOf(classMirror.declarations).toList());
102 103
103 var membersJson = {}; 104 var membersJson = {};
104 for (var memberMirror in sortedMembers) { 105 for (var memberMirror in sortedMembers) {
106 print(' member: $memberMirror');
105 var memberDomName = domNames(memberMirror)[0]; 107 var memberDomName = domNames(memberMirror)[0];
106 var memberComment = _splitCommentsByNewline( 108 var memberComment = _splitCommentsByNewline(
107 computeUntrimmedCommentAsList(memberMirror)); 109 computeUntrimmedCommentAsList(memberMirror));
108 110
109 // Remove interface name from Dom Name. 111 // Remove interface name from Dom Name.
110 if (memberDomName.indexOf('.') >= 0) { 112 if (memberDomName.indexOf('.') >= 0) {
111 memberDomName = 113 memberDomName =
112 memberDomName.substring(memberDomName.indexOf('.') + 1); 114 memberDomName.substring(memberDomName.indexOf('.') + 1);
113 } 115 }
114 116
(...skipping 14 matching lines...) Expand all
129 membersJson); 131 membersJson);
130 } 132 }
131 133
132 if (!classJson.isEmpty) { 134 if (!classJson.isEmpty) {
133 libraryJson.putIfAbsent(domNames(classMirror)[0], () => 135 libraryJson.putIfAbsent(domNames(classMirror)[0], () =>
134 classJson); 136 classJson);
135 } 137 }
136 } 138 }
137 139
138 if (!libraryJson.isEmpty) { 140 if (!libraryJson.isEmpty) {
139 convertedJson.putIfAbsent(libMirror.simpleName, () => 141 convertedJson.putIfAbsent(nameOf(libMirror), () =>
140 libraryJson); 142 libraryJson);
141 } 143 }
142 } 144 }
143 145
144 return convertedJson; 146 return convertedJson;
145 } 147 }
146 148
147 /// Filter out mirrors that are private, or which are not part of this docs 149 /// Filter out mirrors that are private, or which are not part of this docs
148 /// process. That is, ones without the DocsEditable annotation. 150 /// process. That is, ones without the DocsEditable annotation.
149 /// If [ignoreDocsEditable] is true, relax the restriction on @DocsEditable(). 151 /// If [ignoreDocsEditable] is true, relax the restriction on @DocsEditable().
(...skipping 25 matching lines...) Expand all
175 177
176 return out; 178 return out;
177 } 179 }
178 180
179 /// Given the class mirror, returns the names found or an empty list. 181 /// Given the class mirror, returns the names found or an empty list.
180 List<String> domNames(DeclarationMirror mirror) { 182 List<String> domNames(DeclarationMirror mirror) {
181 var domNameMetadata = findMetadata(mirror.metadata, 'DomName'); 183 var domNameMetadata = findMetadata(mirror.metadata, 'DomName');
182 184
183 if (domNameMetadata != null) { 185 if (domNameMetadata != null) {
184 var domNames = <String>[]; 186 var domNames = <String>[];
185 var tags = domNameMetadata.getField('name'); 187 var tags = domNameMetadata.getField(#name);
186 for (var s in tags.reflectee.split(',')) { 188 for (var s in tags.reflectee.split(',')) {
187 domNames.add(s.trim()); 189 domNames.add(s.trim());
188 } 190 }
189 191
190 if (domNames.length == 1 && domNames[0] == 'none') return <String>[]; 192 if (domNames.length == 1 && domNames[0] == 'none') return <String>[];
191 return domNames; 193 return domNames;
192 } else { 194 } else {
193 return <String>[]; 195 return <String>[];
194 } 196 }
195 } 197 }
OLDNEW
« no previous file with comments | « tests/utils/source_mirrors_test.dart ('k') | utils/apidoc/apidoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698