OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 /// **docgen** is a tool for creating machine readable representations of Dart | |
6 /// code metadata, including: classes, members, comments and annotations. | |
7 /// | |
8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. | |
9 /// | |
10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] | |
11 /// | |
12 /// This creates files called `docs/<library_name>.yaml` in your current | |
13 /// working directory. | |
14 library docgen; | |
15 | |
16 import 'dart:async'; | |
17 | |
18 import 'src/generator.dart' as gen; | |
19 import 'src/viewer.dart' as viewer; | |
20 | |
21 export 'src/generator.dart' show getMirrorSystem; | |
22 export 'src/library_helpers.dart' show getDocgenObject; | |
23 export 'src/models.dart'; | |
24 export 'src/package_helpers.dart' show packageNameFor; | |
25 | |
26 /// Docgen constructor initializes the link resolver for markdown parsing. | |
27 /// Also initializes the command line arguments. | |
28 /// | |
29 /// [packageRoot] is the packages directory of the directory being analyzed. | |
30 /// If [includeSdk] is `true`, then any SDK libraries explicitly imported will | |
31 /// also be documented. | |
32 /// If [parseSdk] is `true`, then all Dart SDK libraries will be documented. | |
33 /// This option is useful when only the SDK libraries are needed. | |
34 /// If [compile] is `true`, then after generating the documents, compile the | |
35 /// viewer with dart2js. | |
36 /// If [serve] is `true`, then after generating the documents we fire up a | |
37 /// simple server to view the documentation. | |
38 /// | |
39 /// Returned Future completes with true if document generation is successful. | |
40 Future<bool> docgen(List<String> files, {String packageRoot, | |
41 bool includePrivate: false, bool includeSdk: false, bool parseSdk: false, | |
42 String introFileName: '', String out: gen.DEFAULT_OUTPUT_DIRECTORY, | |
43 List<String> excludeLibraries: const [], | |
44 bool includeDependentPackages: false, bool compile: false, | |
45 bool serve: false, bool noDocs: false, String startPage, | |
46 String pubScript : 'pub', String dartBinary: 'dart', | |
47 bool indentJSON: false, String sdk}) { | |
48 var result; | |
49 if (!noDocs) { | |
50 viewer.ensureMovedViewerCode(); | |
51 result = gen.generateDocumentation(files, packageRoot: packageRoot, | |
52 includePrivate: includePrivate, | |
53 includeSdk: includeSdk, parseSdk: parseSdk, | |
54 introFileName: introFileName, out: out, | |
55 excludeLibraries: excludeLibraries, | |
56 includeDependentPackages: includeDependentPackages, | |
57 startPage: startPage, pubScriptValue: pubScript, | |
58 dartBinaryValue: dartBinary, indentJSON: indentJSON, sdk: sdk); | |
59 viewer.addBackViewerCode(); | |
60 if (compile || serve) { | |
61 result.then((success) { | |
62 if (success) { | |
63 viewer.createViewer(serve); | |
64 } | |
65 }); | |
66 } | |
67 } else if (compile || serve) { | |
68 gen.pubScript = pubScript; | |
69 gen.dartBinary = dartBinary; | |
70 viewer.createViewer(serve); | |
71 } | |
72 return result; | |
73 } | |
OLD | NEW |