OLD | NEW |
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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:args/args.dart'; | 7 import 'package:args/args.dart'; |
8 import 'package:logging/logging.dart'; | 8 import 'package:logging/logging.dart'; |
9 | 9 |
10 import '../lib/docgen.dart'; | 10 import '../lib/docgen.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 var startPage = options['start-page']; | 28 var startPage = options['start-page']; |
29 if (_singlePackage(_files) && startPage == null) { | 29 if (_singlePackage(_files) && startPage == null) { |
30 startPage = _defaultStartPage; | 30 startPage = _defaultStartPage; |
31 print("Using default options for documenting a single package: " | 31 print("Using default options for documenting a single package: " |
32 "--start-page=$startPage"); | 32 "--start-page=$startPage"); |
33 } | 33 } |
34 var includeSdk = options['parse-sdk'] || options['include-sdk']; | 34 var includeSdk = options['parse-sdk'] || options['include-sdk']; |
35 var scriptDir = path.dirname(Platform.script.toFilePath()); | 35 var scriptDir = path.dirname(Platform.script.toFilePath()); |
36 var introduction = includeSdk ? '' : options['introduction']; | 36 var introduction = includeSdk ? '' : options['introduction']; |
37 | 37 |
| 38 var pubScript = options['sdk'] != null ? |
| 39 path.join(options['sdk'], 'bin', 'pub') : 'pub'; |
| 40 |
| 41 var dartBinary = options['sdk'] != null ? |
| 42 path.join(options['sdk'], 'bin', 'dart') : 'dart'; |
| 43 |
38 docgen(_files, | 44 docgen(_files, |
39 packageRoot: options['package-root'], | 45 packageRoot: options['package-root'], |
40 outputToYaml: !options['json'], | 46 outputToYaml: !options['json'], |
41 includePrivate: options['include-private'], | 47 includePrivate: options['include-private'], |
42 includeSdk: includeSdk, | 48 includeSdk: includeSdk, |
43 parseSdk: options['parse-sdk'], | 49 parseSdk: options['parse-sdk'], |
44 append: options['append'] && new Directory(options['out']).existsSync(), | 50 append: options['append'] && new Directory(options['out']).existsSync(), |
45 introFileName: introduction, | 51 introFileName: introduction, |
46 out: options['out'], | 52 out: options['out'], |
47 excludeLibraries: excludedLibraries, | 53 excludeLibraries: excludedLibraries, |
48 includeDependentPackages: options['include-dependent-packages'], | 54 includeDependentPackages: options['include-dependent-packages'], |
| 55 compile: options['compile'], |
49 serve: options['serve'], | 56 serve: options['serve'], |
| 57 dartBinary: dartBinary, |
| 58 pubScript: pubScript, |
50 noDocs: options['no-docs'], | 59 noDocs: options['no-docs'], |
51 startPage: startPage); | 60 startPage: startPage); |
52 } | 61 } |
53 | 62 |
54 /** | 63 /** |
55 * Print help if we are passed the help option or invalid arguments. | 64 * Print help if we are passed the help option or invalid arguments. |
56 */ | 65 */ |
57 void _printHelpAndExit() { | 66 void _printHelpAndExit() { |
58 print(_initArgParser().getUsage()); | 67 print(_initArgParser().getUsage()); |
59 print('Usage: dart docgen.dart [OPTIONS] fooDir/barFile'); | 68 print('Usage: dart docgen.dart [OPTIONS] fooDir/barFile'); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 defaultsTo: true, | 118 defaultsTo: true, |
110 negatable: true); | 119 negatable: true); |
111 parser.addFlag('parse-sdk', | 120 parser.addFlag('parse-sdk', |
112 help: 'Parses the SDK libraries only.', | 121 help: 'Parses the SDK libraries only.', |
113 defaultsTo: false, negatable: false); | 122 defaultsTo: false, negatable: false); |
114 parser.addOption('package-root', | 123 parser.addOption('package-root', |
115 help: 'Sets the package root of the library being analyzed.'); | 124 help: 'Sets the package root of the library being analyzed.'); |
116 parser.addFlag('append', | 125 parser.addFlag('append', |
117 help: 'Append to the docs folder, library_list.json and index.txt', | 126 help: 'Append to the docs folder, library_list.json and index.txt', |
118 defaultsTo: false, negatable: false); | 127 defaultsTo: false, negatable: false); |
| 128 parser.addFlag('compile', help: 'Clone the documentation viewer repo locally ' |
| 129 '(if not already present) and compile with dart2js', defaultsTo: false, |
| 130 negatable: false); |
119 parser.addFlag('serve', help: 'Clone the documentation viewer repo locally ' | 131 parser.addFlag('serve', help: 'Clone the documentation viewer repo locally ' |
120 '(if not already present) and start a simple server', defaultsTo: false, | 132 '(if not already present), compile with dart2js, ' |
121 negatable: false); | 133 'and start a simple server', |
| 134 defaultsTo: false, negatable: false); |
122 parser.addFlag('no-docs', help: 'Do not generate any new documentation', | 135 parser.addFlag('no-docs', help: 'Do not generate any new documentation', |
123 defaultsTo: false, negatable: false); | 136 defaultsTo: false, negatable: false); |
124 parser.addOption('introduction', | 137 parser.addOption('introduction', |
125 help: 'Adds the provided markdown text file as the introduction' | 138 help: 'Adds the provided markdown text file as the introduction' |
126 ' for the generated documentation.', defaultsTo: ''); | 139 ' for the generated documentation.', defaultsTo: ''); |
127 parser.addOption('out', | 140 parser.addOption('out', |
128 help: 'The name of the output directory.', | 141 help: 'The name of the output directory.', |
129 defaultsTo: 'docs'); | 142 defaultsTo: 'docs'); |
130 parser.addOption('exclude-lib', | 143 parser.addOption('exclude-lib', |
131 help: 'Exclude the library by this name from the documentation', | 144 help: 'Exclude the library by this name from the documentation', |
132 allowMultiple: true, | 145 allowMultiple: true, |
133 callback: (libs) => excludedLibraries.addAll(libs)); | 146 callback: (libs) => excludedLibraries.addAll(libs)); |
134 parser.addFlag('include-dependent-packages', | 147 parser.addFlag('include-dependent-packages', |
135 help: 'Assumes we are documenting a single package and are running ' | 148 help: 'Assumes we are documenting a single package and are running ' |
136 'in the directory with its pubspec. Includes documentation for all ' | 149 'in the directory with its pubspec. Includes documentation for all ' |
137 'of its dependent packages.', | 150 'of its dependent packages.', |
138 defaultsTo: true, negatable: true); | 151 defaultsTo: true, negatable: true); |
| 152 parser.addOption('sdk', |
| 153 help: 'SDK directory', |
| 154 defaultsTo: null); |
139 parser.addOption('start-page', | 155 parser.addOption('start-page', |
140 help: 'By default the viewer will start at the SDK introduction page.' | 156 help: 'By default the viewer will start at the SDK introduction page.' |
141 'To start at some other page, e.g. for a package, provide the name ' | 157 'To start at some other page, e.g. for a package, provide the name ' |
142 'of the package in this argument, e.g. --start-page=intl will make ' | 158 'of the package in this argument, e.g. --start-page=intl will make ' |
143 'the start page of the viewer be the intl package.', | 159 'the start page of the viewer be the intl package.', |
144 defaultsTo: null); | 160 defaultsTo: null); |
145 | 161 |
146 return parser; | 162 return parser; |
147 } | 163 } |
OLD | NEW |