Skip to content

Commit dfe219c

Browse files
authored
Trim comments and strings to 80 columns (#2306)
1 parent b481d02 commit dfe219c

File tree

1 file changed

+73
-53
lines changed

1 file changed

+73
-53
lines changed

lib/src/dartdoc_options.dart

Lines changed: 73 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ class CategoryConfiguration {
9999
pathContext.canonicalize(documentationMarkdown);
100100
if (!File(documentationMarkdown).existsSync()) {
101101
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');
103104
}
104105
}
105106
newCategoryDefinitions[name] =
@@ -266,8 +267,8 @@ class DartToolDefinition extends ToolDefinition {
266267
Future<Tuple2<String, Function()>> modifyArgsToCreateSnapshotIfNeeded(
267268
List<String> args) async {
268269
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.
271272
var snapshot = SnapshotCache.instance.getSnapshot(command.first);
272273
var snapshotFile = snapshot.snapshotFile;
273274
var needsSnapshot = snapshot.needsSnapshot;
@@ -432,15 +433,18 @@ class _OptionValueWithContext<T> {
432433
p.Context pathContext;
433434

434435
/// 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).
436439
_OptionValueWithContext(this.value, String path, {String definingFile}) {
437440
this.definingFile = definingFile;
438441
canonicalDirectoryPath = p.canonicalize(path);
439442
pathContext = p.Context(current: canonicalDirectoryPath);
440443
}
441444

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>].
444448
T get resolvedValue {
445449
if (value is List<String>) {
446450
return (value as List<String>)
@@ -462,12 +466,12 @@ class _OptionValueWithContext<T> {
462466

463467
/// An abstract class for interacting with dartdoc options.
464468
///
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.
471475
///
472476
/// Use via implementations [DartdocOptionSet], [DartdocOptionArgFile],
473477
/// [DartdocOptionArgOnly], and [DartdocOptionFileOnly].
@@ -623,7 +627,8 @@ abstract class DartdocOption<T> {
623627
/// Direct children of this node, mapped by name.
624628
final Map<String, DartdocOption<Object>> _children = {};
625629

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.
627632
///
628633
/// If [isFile] or [isDir] is set, the returned value will be transformed
629634
/// into a canonical path relative to the current working directory
@@ -807,13 +812,15 @@ abstract class DartdocSyntheticOption<T> implements DartdocOption<T> {
807812
_OptionValueWithContext<Object> valueWithContext, String missingPath) {
808813
var description = 'Synthetic configuration option ${name} from <internal>';
809814
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}"');
811817
}
812818
}
813819

814820
typedef OptionGenerator = Future<List<DartdocOption<Object>>> Function();
815821

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.
817824
class DartdocOptionSet extends DartdocOption<Null> {
818825
DartdocOptionSet(String name)
819826
: super(name, null, null, false, false, false, null);
@@ -842,15 +849,16 @@ class DartdocOptionSet extends DartdocOption<Null> {
842849
void _onMissing(_OptionValueWithContext<Object> valueWithContext,
843850
String missingFilename) {}
844851

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.
846854
@override
847855
void traverse(void Function(DartdocOption<Object> option) visitor) {
848856
_children.values.forEach((d) => d.traverse(visitor));
849857
}
850858
}
851859

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.
854862
class DartdocOptionArgOnly<T> extends DartdocOption<T>
855863
with _DartdocArgOption<T> {
856864
String _abbr;
@@ -887,7 +895,8 @@ class DartdocOptionArgOnly<T> extends DartdocOption<T>
887895
bool get splitCommas => _splitCommas;
888896
}
889897

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.
891900
class DartdocOptionArgFile<T> extends DartdocOption<T>
892901
with _DartdocArgOption<T>, _DartdocFileOption<T> {
893902
String _abbr;
@@ -924,8 +933,8 @@ class DartdocOptionArgFile<T> extends DartdocOption<T>
924933
}
925934
}
926935

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.
929938
@override
930939
T valueAt(Directory dir) {
931940
var value = _valueAtFromArgs();
@@ -972,8 +981,9 @@ class DartdocOptionFileOnly<T> extends DartdocOption<T>
972981

973982
/// Implements checking for options contained in dartdoc.yaml.
974983
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.
977987
bool get parentDirOverridesChild;
978988

979989
/// The name of the option, with nested options joined by [.]. For example:
@@ -995,8 +1005,9 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
9951005
_OptionValueWithContext<Object> valueWithContext, String missingPath) {
9961006
var dartdocYaml = p.join(
9971007
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}"');
10001011
}
10011012

10021013
@override
@@ -1025,9 +1036,8 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
10251036
return __valueAtFromFiles[key];
10261037
}
10271038

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.
10311041
_OptionValueWithContext<Object> _valueAtFromFilesFirstFound(Directory dir) {
10321042
_OptionValueWithContext<Object> value;
10331043
while (true) {
@@ -1038,8 +1048,8 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
10381048
return value;
10391049
}
10401050

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
10431053
/// mentioned in.
10441054
_OptionValueWithContext<Object> _valueAtFromFilesLastFound(Directory dir) {
10451055
_OptionValueWithContext<Object> value;
@@ -1052,7 +1062,7 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
10521062
return value;
10531063
}
10541064

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
10561066
/// parents).
10571067
_OptionValueWithContext<Object> _valueAtFromFile(Directory dir) {
10581068
var yamlFileData = _yamlAtDirectory(dir);
@@ -1090,7 +1100,8 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
10901100
}
10911101
if (_convertYamlToType == null) {
10921102
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');
10941105
}
10951106
var canonicalDirectoryPath = p.canonicalize(contextPath);
10961107
returnData = _convertYamlToType(
@@ -1138,16 +1149,19 @@ abstract class _DartdocFileOption<T> implements DartdocOption<T> {
11381149

11391150
/// Mixin class implementing command-line arguments for [DartdocOption].
11401151
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.
11421154
bool get negatable;
11431155

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.
11451158
bool get splitCommas;
11461159

11471160
/// For [ArgParser], set to true to hide this from the help menu.
11481161
bool get hide;
11491162

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.
11511165
String get abbr;
11521166

11531167
/// valueAt for arguments ignores the [dir] parameter and only uses command
@@ -1166,7 +1180,8 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
11661180
example = '0.76';
11671181
}
11681182
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}');
11701185
}
11711186

11721187
/// Returns null if no argument was given on the command line.
@@ -1183,7 +1198,8 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
11831198
void _onMissingFromArgs(
11841199
_OptionValueWithContext<Object> valueWithContext, String missingPath) {
11851200
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}"');
11871203
}
11881204

11891205
/// Generates an _OptionValueWithContext using the value of the argument from
@@ -1194,9 +1210,9 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
11941210
if (!_argResults.wasParsed(argName)) return null;
11951211

11961212
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?
12001216
if (_isBool || _isListString || _isString) {
12011217
retval = _argResults[argName];
12021218
} else if (_isInt) {
@@ -1289,9 +1305,11 @@ abstract class DartdocOptionContextBase {
12891305
}
12901306

12911307
/// 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.
12951313
class DartdocOptionContext extends DartdocOptionContextBase
12961314
with
12971315
DartdocExperimentOptionContext,
@@ -1325,7 +1343,8 @@ class DartdocOptionContext extends DartdocOptionContextBase
13251343
return DartdocOptionContext(optionSet, File(element.source.fullName));
13261344
}
13271345

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].
13291348
factory DartdocOptionContext.fromContextElement(
13301349
DartdocOptionContext optionContext, Element element) {
13311350
return DartdocOptionContext.fromElement(optionContext.optionSet, element);
@@ -1422,7 +1441,8 @@ class DartdocOptionContext extends DartdocOptionContextBase
14221441
/// Output format, e.g. 'html', 'md'
14231442
String get format => optionSet['format'].valueAt(context);
14241443

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
14261446
bool get useBaseHref => optionSet['useBaseHref'].valueAt(context);
14271447
}
14281448

@@ -1443,9 +1463,9 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
14431463
'in the current package or "include-external"',
14441464
negatable: true),
14451465
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.'),
14491469
DartdocOptionFileOnly<CategoryConfiguration>(
14501470
'categories', CategoryConfiguration.empty,
14511471
convertYamlToType: CategoryConfiguration.fromYamlMap,
@@ -1573,8 +1593,8 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
15731593
),
15741594
DartdocOptionArgOnly<List<String>>('packageOrder', [],
15751595
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.'),
15781598
DartdocOptionArgOnly<bool>('sdkDocs', false,
15791599
help: 'Generate ONLY the docs for the Dart SDK.'),
15801600
DartdocOptionArgSynth<String>('sdkDir',
@@ -1606,8 +1626,8 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
16061626
DartdocOptionArgOnly<bool>('useCategories', true,
16071627
help: 'Display categories in the sidebar of packages'),
16081628
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)',
16111631
negatable: true),
16121632
DartdocOptionArgOnly<bool>('verboseWarnings', true,
16131633
help: 'Display extra debugging information and help with warnings.',
@@ -1625,7 +1645,7 @@ Future<List<DartdocOption<Object>>> createDartdocOptions(
16251645
'Use <base href> in generated files (legacy behavior). This option '
16261646
'is temporary and support will be removed in the future. Use only '
16271647
'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.',
16291649
negatable: false,
16301650
hide: true),
16311651
// TODO(jdkoren): Unhide when we have good support for another format.

0 commit comments

Comments
 (0)