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

Side by Side Diff: pkg/docgen/lib/docgen.dart

Issue 55233002: Work around changes to Platform in docgen (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 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 * **docgen** is a tool for creating machine readable representations of Dart 6 * **docgen** is a tool for creating machine readable representations of Dart
7 * code metadata, including: classes, members, comments and annotations. 7 * code metadata, including: classes, members, comments and annotations.
8 * 8 *
9 * docgen is run on a `.dart` file or a directory containing `.dart` files. 9 * docgen is run on a `.dart` file or a directory containing `.dart` files.
10 * 10 *
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 242
243 /** 243 /**
244 * Analyzes set of libraries by getting a mirror system and triggers the 244 * Analyzes set of libraries by getting a mirror system and triggers the
245 * documentation of the libraries. 245 * documentation of the libraries.
246 */ 246 */
247 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot, 247 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot,
248 bool parseSdk: false}) { 248 bool parseSdk: false}) {
249 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); 249 var libraries = !parseSdk ? _listLibraries(args) : _listSdk();
250 if (libraries.isEmpty) throw new StateError('No Libraries.'); 250 if (libraries.isEmpty) throw new StateError('No Libraries.');
251 // Finds the root of SDK library based off the location of docgen. 251 // Finds the root of SDK library based off the location of docgen.
252 var sdkRoot = Platform.script.resolve('../../../sdk').toFilePath(); 252 var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
253 var sdkRoot = path.relative('../../../sdk', from: scriptDir);
254 sdkRoot = path.normalize(path.absolute(sdkRoot));
253 logger.info('SDK Root: ${sdkRoot}'); 255 logger.info('SDK Root: ${sdkRoot}');
254 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); 256 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot);
255 } 257 }
256 258
257 /** 259 /**
258 * Analyzes set of libraries and provides a mirror system which can be used 260 * Analyzes set of libraries and provides a mirror system which can be used
259 * for static inspection of the source code. 261 * for static inspection of the source code.
260 */ 262 */
261 Future<MirrorSystem> _analyzeLibraries(List<String> libraries, 263 Future<MirrorSystem> _analyzeLibraries(List<String> libraries,
262 String libraryRoot, {String packageRoot}) { 264 String libraryRoot, {String packageRoot}) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return commentText; 473 return commentText;
472 } 474 }
473 475
474 /** 476 /**
475 * Generates MDN comments from database.json. 477 * Generates MDN comments from database.json.
476 */ 478 */
477 void _mdnComment(Indexable item) { 479 void _mdnComment(Indexable item) {
478 //Check if MDN is loaded. 480 //Check if MDN is loaded.
479 if (_mdn == null) { 481 if (_mdn == null) {
480 // Reading in MDN related json file. 482 // Reading in MDN related json file.
481 var mdnDatabase = 483 var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
482 Platform.script.resolve('../../../utils/apidoc/mdn/database.json'); 484 var mdnPath = path.relative('../../../utils/apidoc/mdn/database.json',
483 _mdn = JSON.decode(new File(mdnDatabase.toFilePath()).readAsStringSync()); 485 from: scriptDir);
486 _mdn = JSON.decode(new File(mdnPath).readAsStringSync());
484 } 487 }
485 if (item.comment.isNotEmpty) return; 488 if (item.comment.isNotEmpty) return;
486 var domAnnotation = item.annotations.firstWhere( 489 var domAnnotation = item.annotations.firstWhere(
487 (e) => e.qualifiedName == 'metadata.DomName', orElse: () => null); 490 (e) => e.qualifiedName == 'metadata.DomName', orElse: () => null);
488 if (domAnnotation == null) return; 491 if (domAnnotation == null) return;
489 var domName = domAnnotation.parameters.single; 492 var domName = domAnnotation.parameters.single;
490 var parts = domName.split('.'); 493 var parts = domName.split('.');
491 if (parts.length == 2) item.comment = _mdnMemberComment(parts[0], parts[1]); 494 if (parts.length == 2) item.comment = _mdnMemberComment(parts[0], parts[1]);
492 if (parts.length == 1) item.comment = _mdnTypeComment(parts[0]); 495 if (parts.length == 1) item.comment = _mdnTypeComment(parts[0]);
493 } 496 }
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 String docName(DeclarationMirror m) { 1318 String docName(DeclarationMirror m) {
1316 if (m is LibraryMirror) { 1319 if (m is LibraryMirror) {
1317 return (m as LibraryMirror).qualifiedName.replaceAll('.','-'); 1320 return (m as LibraryMirror).qualifiedName.replaceAll('.','-');
1318 } 1321 }
1319 var owner = m.owner; 1322 var owner = m.owner;
1320 if (owner == null) return m.qualifiedName; 1323 if (owner == null) return m.qualifiedName;
1321 // For the unnamed constructor we just return the class name. 1324 // For the unnamed constructor we just return the class name.
1322 if (m.simpleName == '') return docName(owner); 1325 if (m.simpleName == '') return docName(owner);
1323 return docName(owner) + '.' + m.simpleName; 1326 return docName(owner) + '.' + m.simpleName;
1324 } 1327 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698