@@ -99,7 +99,8 @@ class CategoryConfiguration {
99
99
pathContext.canonicalize (documentationMarkdown);
100
100
if (! File (documentationMarkdown).existsSync ()) {
101
101
throw DartdocFileMissing (
102
- 'In categories definition for ${name }, "markdown" resolves to the missing file $documentationMarkdown ' );
102
+ 'In categories definition for ${name }, "markdown" resolves to '
103
+ 'the missing file $documentationMarkdown ' );
103
104
}
104
105
}
105
106
newCategoryDefinitions[name] =
@@ -266,8 +267,8 @@ class DartToolDefinition extends ToolDefinition {
266
267
Future <Tuple2 <String , Function ()>> modifyArgsToCreateSnapshotIfNeeded (
267
268
List <String > args) async {
268
269
assert (args[0 ] == command.first);
269
- // Set up flags to create a new snapshot, if needed, and use the first run as the training
270
- // run.
270
+ // Set up flags to create a new snapshot, if needed, and use the first run
271
+ // as the training run.
271
272
var snapshot = SnapshotCache .instance.getSnapshot (command.first);
272
273
var snapshotFile = snapshot.snapshotFile;
273
274
var needsSnapshot = snapshot.needsSnapshot;
@@ -432,15 +433,18 @@ class _OptionValueWithContext<T> {
432
433
p.Context pathContext;
433
434
434
435
/// Build a _OptionValueWithContext.
435
- /// [path] is the path where this value came from (not required to be canonical)
436
+ ///
437
+ /// [path] is the path where this value came from (not required to be
438
+ /// canonical).
436
439
_OptionValueWithContext (this .value, String path, {String definingFile}) {
437
440
this .definingFile = definingFile;
438
441
canonicalDirectoryPath = p.canonicalize (path);
439
442
pathContext = p.Context (current: canonicalDirectoryPath);
440
443
}
441
444
442
- /// Assume value is a path, and attempt to resolve it. Throws [UnsupportedError]
443
- /// if [T] isn't a [String] or [List<String>] .
445
+ /// Assume value is a path, and attempt to resolve it.
446
+ ///
447
+ /// Throws [UnsupportedError] if [T] isn't a [String] or [List<String>] .
444
448
T get resolvedValue {
445
449
if (value is List <String >) {
446
450
return (value as List <String >)
@@ -462,12 +466,12 @@ class _OptionValueWithContext<T> {
462
466
463
467
/// An abstract class for interacting with dartdoc options.
464
468
///
465
- /// This class and its implementations allow Dartdoc to declare options
466
- /// that are both defined in a configuration file and specified via the
467
- /// command line, with searching the directory tree for a proper file
468
- /// and overriding file options with the command line built-in. A number
469
- /// of sanity checks are also built in to these classes so that file existence
470
- /// can be verified, types constrained, and defaults provided.
469
+ /// This class and its implementations allow Dartdoc to declare options that
470
+ /// are both defined in a configuration file and specified via the command line,
471
+ /// with searching the directory tree for a proper file and overriding file
472
+ /// options with the command line built-in. A number of sanity checks are also
473
+ /// built in to these classes so that file existence can be verified, types
474
+ /// constrained, and defaults provided.
471
475
///
472
476
/// Use via implementations [DartdocOptionSet] , [DartdocOptionArgFile] ,
473
477
/// [DartdocOptionArgOnly] , and [DartdocOptionFileOnly] .
@@ -623,7 +627,8 @@ abstract class DartdocOption<T> {
623
627
/// Direct children of this node, mapped by name.
624
628
final Map <String , DartdocOption <Object >> _children = {};
625
629
626
- /// Return the calculated value of this option, given the directory as context.
630
+ /// Return the calculated value of this option, given the directory as
631
+ /// context.
627
632
///
628
633
/// If [isFile] or [isDir] is set, the returned value will be transformed
629
634
/// into a canonical path relative to the current working directory
@@ -807,13 +812,15 @@ abstract class DartdocSyntheticOption<T> implements DartdocOption<T> {
807
812
_OptionValueWithContext <Object > valueWithContext, String missingPath) {
808
813
var description = 'Synthetic configuration option ${name } from <internal>' ;
809
814
throw DartdocFileMissing (
810
- '$description , computed as ${valueWithContext .value }, resolves to missing path: "${missingPath }"' );
815
+ '$description , computed as ${valueWithContext .value }, resolves to '
816
+ 'missing path: "${missingPath }"' );
811
817
}
812
818
}
813
819
814
820
typedef OptionGenerator = Future <List <DartdocOption <Object >>> Function ();
815
821
816
- /// A [DartdocOption] that only contains other [DartdocOption] s and is not an option itself.
822
+ /// A [DartdocOption] that only contains other [DartdocOption] s and is not an
823
+ /// option itself.
817
824
class DartdocOptionSet extends DartdocOption <Null > {
818
825
DartdocOptionSet (String name)
819
826
: super (name, null , null , false , false , false , null );
@@ -842,15 +849,16 @@ class DartdocOptionSet extends DartdocOption<Null> {
842
849
void _onMissing (_OptionValueWithContext <Object > valueWithContext,
843
850
String missingFilename) {}
844
851
845
- /// Traverse skips this node, because it doesn't represent a real configuration object.
852
+ /// Traverse skips this node, because it doesn't represent a real
853
+ /// configuration object.
846
854
@override
847
855
void traverse (void Function (DartdocOption <Object > option) visitor) {
848
856
_children.values.forEach ((d) => d.traverse (visitor));
849
857
}
850
858
}
851
859
852
- /// A [DartdocOption] that only exists as a command line argument. --help would
853
- /// be a good example.
860
+ /// A [DartdocOption] that only exists as a command line argument. ` --help` is a
861
+ /// good example.
854
862
class DartdocOptionArgOnly <T > extends DartdocOption <T >
855
863
with _DartdocArgOption <T > {
856
864
String _abbr;
@@ -887,7 +895,8 @@ class DartdocOptionArgOnly<T> extends DartdocOption<T>
887
895
bool get splitCommas => _splitCommas;
888
896
}
889
897
890
- /// A [DartdocOption] that works with command line arguments and dartdoc_options files.
898
+ /// A [DartdocOption] that works with command line arguments and
899
+ /// `dartdoc_options` files.
891
900
class DartdocOptionArgFile <T > extends DartdocOption <T >
892
901
with _DartdocArgOption <T >, _DartdocFileOption <T > {
893
902
String _abbr;
@@ -924,8 +933,8 @@ class DartdocOptionArgFile<T> extends DartdocOption<T>
924
933
}
925
934
}
926
935
927
- /// Try to find an explicit argument setting this value, but if not, fall back to files
928
- /// finally, the default.
936
+ /// Try to find an explicit argument setting this value, but if not, fall back
937
+ /// to files finally, the default.
929
938
@override
930
939
T valueAt (Directory dir) {
931
940
var value = _valueAtFromArgs ();
@@ -972,8 +981,9 @@ class DartdocOptionFileOnly<T> extends DartdocOption<T>
972
981
973
982
/// Implements checking for options contained in dartdoc.yaml.
974
983
abstract class _DartdocFileOption <T > implements DartdocOption <T > {
975
- /// If true, the parent directory's value overrides the child's. Otherwise, the child's
976
- /// value overrides values in parents.
984
+ /// If true, the parent directory's value overrides the child's.
985
+ ///
986
+ /// Otherwise, the child's value overrides values in parents.
977
987
bool get parentDirOverridesChild;
978
988
979
989
/// The name of the option, with nested options joined by [.] . For example:
@@ -995,8 +1005,9 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
995
1005
_OptionValueWithContext <Object > valueWithContext, String missingPath) {
996
1006
var dartdocYaml = p.join (
997
1007
valueWithContext.canonicalDirectoryPath, valueWithContext.definingFile);
998
- throw DartdocFileMissing (
999
- 'Field ${fieldName } from ${dartdocYaml }, set to ${valueWithContext .value }, resolves to missing path: "${missingPath }"' );
1008
+ throw DartdocFileMissing ('Field ${fieldName } from ${dartdocYaml }, set to '
1009
+ '${valueWithContext .value }, resolves to missing path: '
1010
+ '"${missingPath }"' );
1000
1011
}
1001
1012
1002
1013
@override
@@ -1025,9 +1036,8 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
1025
1036
return __valueAtFromFiles[key];
1026
1037
}
1027
1038
1028
- /// Searches all dartdoc_options files through parent directories,
1029
- /// starting at [dir] , for the option and returns one once
1030
- /// found.
1039
+ /// Searches all dartdoc_options files through parent directories, starting at
1040
+ /// [dir] , for the option and returns one once found.
1031
1041
_OptionValueWithContext <Object > _valueAtFromFilesFirstFound (Directory dir) {
1032
1042
_OptionValueWithContext <Object > value;
1033
1043
while (true ) {
@@ -1038,8 +1048,8 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
1038
1048
return value;
1039
1049
}
1040
1050
1041
- /// Searches all dartdoc_options files for the option, and returns the
1042
- /// value in the top-most parent directory dartdoc_options.yaml file it is
1051
+ /// Searches all dartdoc_options files for the option, and returns the value
1052
+ /// in the top-most parent directory ` dartdoc_options.yaml` file it is
1043
1053
/// mentioned in.
1044
1054
_OptionValueWithContext <Object > _valueAtFromFilesLastFound (Directory dir) {
1045
1055
_OptionValueWithContext <Object > value;
@@ -1052,7 +1062,7 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
1052
1062
return value;
1053
1063
}
1054
1064
1055
- /// Returns null if not set in the yaml file in this directory (or its
1065
+ /// Returns null if not set in the YAML file in this directory (or its
1056
1066
/// parents).
1057
1067
_OptionValueWithContext <Object > _valueAtFromFile (Directory dir) {
1058
1068
var yamlFileData = _yamlAtDirectory (dir);
@@ -1090,7 +1100,8 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
1090
1100
}
1091
1101
if (_convertYamlToType == null ) {
1092
1102
throw DartdocOptionError (
1093
- 'Unable to convert yaml to type for option: $fieldName , method not defined' );
1103
+ 'Unable to convert yaml to type for option: $fieldName , method not '
1104
+ 'defined' );
1094
1105
}
1095
1106
var canonicalDirectoryPath = p.canonicalize (contextPath);
1096
1107
returnData = _convertYamlToType (
@@ -1138,16 +1149,19 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
1138
1149
1139
1150
/// Mixin class implementing command-line arguments for [DartdocOption] .
1140
1151
abstract class _DartdocArgOption <T > implements DartdocOption <T > {
1141
- /// For [ArgParser] , set to true if the argument can be negated with --no on the command line.
1152
+ /// For [ArgParser] , set to true if the argument can be negated with `--no` on
1153
+ /// the command line.
1142
1154
bool get negatable;
1143
1155
1144
- /// For [ArgParser] , set to true if a single string argument will be broken into a list on commas.
1156
+ /// For [ArgParser] , set to true if a single string argument will be broken
1157
+ /// into a list on commas.
1145
1158
bool get splitCommas;
1146
1159
1147
1160
/// For [ArgParser] , set to true to hide this from the help menu.
1148
1161
bool get hide;
1149
1162
1150
- /// For [ArgParser] , set to a single character to have a short version of the command line argument.
1163
+ /// For [ArgParser] , set to a single character to have a short version of the
1164
+ /// command line argument.
1151
1165
String get abbr;
1152
1166
1153
1167
/// valueAt for arguments ignores the [dir] parameter and only uses command
@@ -1166,7 +1180,8 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
1166
1180
example = '0.76' ;
1167
1181
}
1168
1182
throw DartdocOptionError (
1169
- 'Invalid argument value: --${argName }, set to "${value }", must be a ${T }. Example: --${argName } ${example }' );
1183
+ 'Invalid argument value: --${argName }, set to "${value }", must be a '
1184
+ '${T }. Example: --${argName } ${example }' );
1170
1185
}
1171
1186
1172
1187
/// Returns null if no argument was given on the command line.
@@ -1183,7 +1198,8 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
1183
1198
void _onMissingFromArgs (
1184
1199
_OptionValueWithContext <Object > valueWithContext, String missingPath) {
1185
1200
throw DartdocFileMissing (
1186
- 'Argument --${argName }, set to ${valueWithContext .value }, resolves to missing path: "${missingPath }"' );
1201
+ 'Argument --${argName }, set to ${valueWithContext .value }, resolves to '
1202
+ 'missing path: "${missingPath }"' );
1187
1203
}
1188
1204
1189
1205
/// Generates an _OptionValueWithContext using the value of the argument from
@@ -1194,9 +1210,9 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
1194
1210
if (! _argResults.wasParsed (argName)) return null ;
1195
1211
1196
1212
T retval;
1197
- // Unlike in _DartdocFileOption, we throw here on inputs being invalid rather
1198
- // than silently proceeding. TODO(jcollins-g): throw on input formatting for
1199
- // files too?
1213
+ // Unlike in _DartdocFileOption, we throw here on inputs being invalid
1214
+ // rather than silently proceeding. TODO(jcollins-g): throw on input
1215
+ // formatting for files too?
1200
1216
if (_isBool || _isListString || _isString) {
1201
1217
retval = _argResults[argName];
1202
1218
} else if (_isInt) {
@@ -1289,9 +1305,11 @@ abstract class DartdocOptionContextBase {
1289
1305
}
1290
1306
1291
1307
/// An [DartdocOptionSet] wrapped in nice accessors specific to Dartdoc, which
1292
- /// automatically passes in the right directory for a given context. Usually,
1293
- /// a single [ModelElement] , [Package] , [Category] and so forth has a single context
1294
- /// and so this can be made a member variable of those structures.
1308
+ /// automatically passes in the right directory for a given context.
1309
+ ///
1310
+ /// Usually, a single [ModelElement] , [Package] , [Category] and so forth has a
1311
+ /// single context and so this can be made a member variable of those
1312
+ /// structures.
1295
1313
class DartdocOptionContext extends DartdocOptionContextBase
1296
1314
with
1297
1315
DartdocExperimentOptionContext ,
@@ -1325,7 +1343,8 @@ class DartdocOptionContext extends DartdocOptionContextBase
1325
1343
return DartdocOptionContext (optionSet, File (element.source.fullName));
1326
1344
}
1327
1345
1328
- /// Build a DartdocOptionContext from an existing [DartdocOptionContext] and a new analyzer [Element] .
1346
+ /// Build a DartdocOptionContext from an existing [DartdocOptionContext] and a
1347
+ /// new analyzer [Element] .
1329
1348
factory DartdocOptionContext .fromContextElement (
1330
1349
DartdocOptionContext optionContext, Element element) {
1331
1350
return DartdocOptionContext .fromElement (optionContext.optionSet, element);
@@ -1422,7 +1441,8 @@ class DartdocOptionContext extends DartdocOptionContextBase
1422
1441
/// Output format, e.g. 'html', 'md'
1423
1442
String get format => optionSet['format' ].valueAt (context);
1424
1443
1425
- // TODO(jdkoren): temporary while we confirm href base behavior doesn't break important clients
1444
+ // TODO(jdkoren): temporary while we confirm href base behavior doesn't break
1445
+ // important clients
1426
1446
bool get useBaseHref => optionSet['useBaseHref' ].valueAt (context);
1427
1447
}
1428
1448
@@ -1443,9 +1463,9 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
1443
1463
'in the current package or "include-external"' ,
1444
1464
negatable: true ),
1445
1465
DartdocOptionArgFile <List <String >>('categoryOrder' , [],
1446
- help:
1447
- "A list of categories (not package names) to place first when grouping symbols on dartdoc's sidebar. "
1448
- 'Unmentioned categories are sorted after these.' ),
1466
+ help: 'A list of categories (not package names) to place first when '
1467
+ "grouping symbols on dartdoc's sidebar. Unmentioned categories are "
1468
+ 'sorted after these.' ),
1449
1469
DartdocOptionFileOnly <CategoryConfiguration >(
1450
1470
'categories' , CategoryConfiguration .empty,
1451
1471
convertYamlToType: CategoryConfiguration .fromYamlMap,
@@ -1573,8 +1593,8 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
1573
1593
),
1574
1594
DartdocOptionArgOnly <List <String >>('packageOrder' , [],
1575
1595
help:
1576
- 'A list of package names to place first when grouping libraries in packages. '
1577
- 'Unmentioned packages are sorted after these.' ),
1596
+ 'A list of package names to place first when grouping libraries in '
1597
+ 'packages. Unmentioned packages are sorted after these.' ),
1578
1598
DartdocOptionArgOnly <bool >('sdkDocs' , false ,
1579
1599
help: 'Generate ONLY the docs for the Dart SDK.' ),
1580
1600
DartdocOptionArgSynth <String >('sdkDir' ,
@@ -1606,8 +1626,8 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
1606
1626
DartdocOptionArgOnly <bool >('useCategories' , true ,
1607
1627
help: 'Display categories in the sidebar of packages' ),
1608
1628
DartdocOptionArgOnly <bool >('validateLinks' , true ,
1609
- help:
1610
- 'Runs the built-in link checker to display Dart context aware warnings for broken links (slow)' ,
1629
+ help: 'Runs the built-in link checker to display Dart context aware '
1630
+ 'warnings for broken links (slow)' ,
1611
1631
negatable: true ),
1612
1632
DartdocOptionArgOnly <bool >('verboseWarnings' , true ,
1613
1633
help: 'Display extra debugging information and help with warnings.' ,
@@ -1625,7 +1645,7 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
1625
1645
'Use <base href> in generated files (legacy behavior). This option '
1626
1646
'is temporary and support will be removed in the future. Use only '
1627
1647
'if the default behavior breaks links between your documentation '
1628
- 'pages, and please file an issue on Github .' ,
1648
+ 'pages, and please file an issue on GitHub .' ,
1629
1649
negatable: false ,
1630
1650
hide: true ),
1631
1651
// TODO(jdkoren): Unhide when we have good support for another format.
0 commit comments