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

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

Issue 16915007: docgen working with a temporary link hack. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/docgen/bin/docgen.dart ('k') | pkg/docgen/packages/hack » ('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 * The docgen tool takes in a library as input and produces documentation 6 * The docgen tool takes in a library as input and produces documentation
7 * for the library as well as all libraries it imports and uses. The tool can 7 * for the library as well as all libraries it imports and uses. The tool can
8 * be run by passing in the path to a .dart file like this: 8 * be run by passing in the path to a .dart file like this:
9 * 9 *
10 * dart docgen.dart [OPTIONS] [FILE/DIR] 10 * dart docgen.dart [OPTIONS] [FILE/DIR]
11 * 11 *
12 * This outputs information about all classes, variables, functions, and 12 * This outputs information about all classes, variables, functions, and
13 * methods defined in the library and its imported libraries. 13 * methods defined in the library and its imported libraries.
14 */ 14 */
15 library docgen; 15 library docgen;
16 16
17 import 'dart:io'; 17 import 'dart:io';
18 import 'dart:json'; 18 import 'dart:json';
19 import 'dart:async'; 19 import 'dart:async';
20 import 'package:markdown/markdown.dart' as markdown; 20 import 'package:markdown/markdown.dart' as markdown;
21 import 'package:args/args.dart'; 21 import 'package:args/args.dart';
22 import 'dart2yaml.dart'; 22 import 'dart2yaml.dart';
23 import 'package:compiler_unsupported/compiler.dart' as api; 23 import 'package:hack/compiler/compiler.dart' as api;
Emily Fortuna 2013/06/21 20:27:37 Can you add a TODO(janicejl/amouravski) saying som
24 import 'package:compiler_unsupported/implementation/filenames.dart'; 24 import 'package:hack/compiler/implementation/filenames.dart';
25 import 'package:compiler_unsupported/implementation/mirrors/dart2js_mirror.dart' 25 import 'package:hack/compiler/implementation/mirrors/dart2js_mirror.dart'
26 as dart2js; 26 as dart2js;
27 import 'package:compiler_unsupported/implementation/mirrors/mirrors.dart'; 27 import 'package:hack/compiler/implementation/mirrors/mirrors.dart';
28 import 'package:compiler_unsupported/implementation/mirrors/mirrors_util.dart'; 28 import 'package:hack/compiler/implementation/mirrors/mirrors_util.dart';
29 import 'package:compiler_unsupported/implementation/source_file_provider.dart'; 29 import 'package:hack/compiler/implementation/source_file_provider.dart';
30 import 'package:logging/logging.dart'; 30 import 'package:logging/logging.dart';
31 31
32 /// Logger for Dart Doc Generator. 32 /// Logger for Dart Doc Generator.
33 var logger = new Logger("Docgen"); 33 var logger = new Logger("Docgen");
34 34
35 /// Unique ID, will get incremented everytime an ID is requested. 35 /// Unique ID, will get incremented everytime an ID is requested.
36 int _uid = 0; 36 int _uid = 0;
37 37
38 int getID() => _uid++; 38 int getID() => _uid++;
39 39
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool outputToYaml; 135 bool outputToYaml;
136 /// Should the output file type be JSON? 136 /// Should the output file type be JSON?
137 bool outputToJson; 137 bool outputToJson;
138 /// Should the output file hide private declarations? 138 /// Should the output file hide private declarations?
139 bool hidePrivate; 139 bool hidePrivate;
140 /// Should the output include SDK libraries? 140 /// Should the output include SDK libraries?
141 bool sdk; 141 bool sdk;
142 142
143 /** 143 /**
144 * Docgen constructor initializes the link resolver for markdown parsing. 144 * Docgen constructor initializes the link resolver for markdown parsing.
145 * Also initializes the command line arguments. 145 * Also initializes the command line arguments.
Bob Nystrom 2013/06/21 20:32:53 You can use "///" style doc comments for multiline
146 */ 146 */
147 Docgen({ArgResults argResults}) { 147 Docgen({ArgResults argResults}) {
148 outputToYaml = argResults["yaml"]; 148 if (argResults != null) {
149 outputToJson = argResults["json"]; 149 outputToYaml = argResults["yaml"];
150 hidePrivate = argResults["hide-private"]; 150 outputToJson = argResults["json"];
151 sdk = argResults["sdk"]; 151 hidePrivate = argResults["hide-private"];
152 sdk = argResults["sdk"];
153 } else {
154 outputToYaml = true;
Emily Fortuna 2013/06/21 20:27:37 if you're already specifying default values from t
Bob Nystrom 2013/06/21 20:32:53 Alternatively, just pass these arguments directly
janicejl 2013/06/21 21:02:39 Done.
155 outputToJson = false;
156 hidePrivate = false;
157 sdk = true;
158 }
152 159
153 this.linkResolver = (name) => 160 this.linkResolver = (name) =>
154 fixReference(name, _currentLibrary, _currentClass, _currentMember); 161 fixReference(name, _currentLibrary, _currentClass, _currentMember);
155 } 162 }
156 163
157 /** 164 /**
158 * Analyzes set of libraries by getting a mirror system and triggers the 165 * Analyzes set of libraries by getting a mirror system and triggers the
159 * documentation of the libraries. 166 * documentation of the libraries.
160 */ 167 */
161 void analyze(List<Path> libraries) { 168 void analyze(List<Path> libraries) {
162 /// Assuming the dart executable is from the Dart SDK folder. 169 /// Assuming the dart executable is from the Dart SDK folder.
Bob Nystrom 2013/06/21 20:32:53 Just use a normal "//" comment here, not "///".
163 var sdkRoot = new Path(new Options().executable).directoryPath 170
164 .directoryPath; 171 var sdkRoot = Platform.environment["DART_SDK"];
Emily Fortuna 2013/06/21 20:27:37 I'd be inclined to keep it the way you had it befo
janicejl 2013/06/21 21:02:39 I have kept it with a comment. I have also modifie
165 logger.info("SDK Root: ${sdkRoot.toString()}"); 172 if (sdkRoot != null) {
173 logger.info("Using DART_SDK to find SDK at $sdkRoot");
174 sdkRoot = new Path(sdkRoot);
175 } else {
176 sdkRoot = new Path(new Options().executable).directoryPath
177 .append("dart-sdk");
178 logger.info("SDK Root: ${sdkRoot.toString()}");
179 }
180
166 Path packageDir = libraries.last.directoryPath.append("packages"); 181 Path packageDir = libraries.last.directoryPath.append("packages");
167 logger.info("Package Root: ${packageDir.toString()}"); 182 logger.info("Package Root: ${packageDir.toString()}");
168 getMirrorSystem(libraries, sdkRoot, 183 getMirrorSystem(libraries, sdkRoot,
169 packageRoot: packageDir).then((MirrorSystem mirrorSystem) { 184 packageRoot: packageDir).then((MirrorSystem mirrorSystem) {
170 if (mirrorSystem.libraries.values.isEmpty) { 185 if (mirrorSystem.libraries.values.isEmpty) {
171 throw new UnsupportedError("No Library Mirrors."); 186 throw new UnsupportedError("No Library Mirrors.");
172 } 187 }
173 this.libraries = mirrorSystem.libraries.values; 188 this.libraries = mirrorSystem.libraries.values;
174 documentLibraries(); 189 documentLibraries();
175 }); 190 });
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (!dir.existsSync()) { 544 if (!dir.existsSync()) {
530 dir.createSync(); 545 dir.createSync();
531 } 546 }
532 File file = new File('docs/$filename'); 547 File file = new File('docs/$filename');
533 if (!file.existsSync()) { 548 if (!file.existsSync()) {
534 file.createSync(); 549 file.createSync();
535 } 550 }
536 file.openSync(); 551 file.openSync();
537 file.writeAsString(text); 552 file.writeAsString(text);
538 } 553 }
OLDNEW
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/packages/hack » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698