move to the latest version of pedantic (#1975)
diff --git a/analysis_options.yaml b/analysis_options.yaml
index e913fc0..e29f308 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,4 +1,4 @@
-include: package:pedantic/analysis_options.1.5.0.yaml
+include: package:pedantic/analysis_options.1.7.0.yaml
analyzer:
exclude:
diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart
index b428213..8b49977 100644
--- a/lib/dartdoc.dart
+++ b/lib/dartdoc.dart
@@ -24,7 +24,7 @@
import 'package:dartdoc/src/warnings.dart';
import 'package:html/dom.dart' show Element, Document;
import 'package:html/parser.dart' show parse;
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
export 'package:dartdoc/src/dartdoc_options.dart';
export 'package:dartdoc/src/element_type.dart';
@@ -105,10 +105,11 @@
for (var generator in generators) {
await generator.generate(packageGraph, outputDir.path);
- writtenFiles.addAll(generator.writtenFiles.map(pathLib.normalize));
+ writtenFiles.addAll(generator.writtenFiles.map(path.normalize));
}
- if (config.validateLinks && writtenFiles.isNotEmpty)
+ if (config.validateLinks && writtenFiles.isNotEmpty) {
validateLinks(packageGraph, outputDir.path);
+ }
}
int warnings = packageGraph.packageWarningCounter.warningCount;
@@ -159,12 +160,12 @@
Set<Warnable> warnOnElements;
// Make all paths relative to origin.
- if (pathLib.isWithin(origin, warnOn)) {
- warnOn = pathLib.relative(warnOn, from: origin);
+ if (path.isWithin(origin, warnOn)) {
+ warnOn = path.relative(warnOn, from: origin);
}
if (referredFrom != null) {
- if (pathLib.isWithin(origin, referredFrom)) {
- referredFrom = pathLib.relative(referredFrom, from: origin);
+ if (path.isWithin(origin, referredFrom)) {
+ referredFrom = path.relative(referredFrom, from: origin);
}
// Source paths are always relative.
if (_hrefs[referredFrom] != null) {
@@ -185,8 +186,9 @@
}
}
- if (referredFromElements.isEmpty && referredFrom == 'index.html')
+ if (referredFromElements.isEmpty && referredFrom == 'index.html') {
referredFromElements.add(packageGraph.defaultPackage);
+ }
String message = warnOn;
if (referredFrom == 'index.json') message = '$warnOn (from index.json)';
packageGraph.warnOnElement(warnOnElement, kind,
@@ -195,13 +197,13 @@
void _doOrphanCheck(
PackageGraph packageGraph, String origin, Set<String> visited) {
- String normalOrigin = pathLib.normalize(origin);
- String staticAssets = pathLib.joinAll([normalOrigin, 'static-assets', '']);
- String indexJson = pathLib.joinAll([normalOrigin, 'index.json']);
+ String normalOrigin = path.normalize(origin);
+ String staticAssets = path.joinAll([normalOrigin, 'static-assets', '']);
+ String indexJson = path.joinAll([normalOrigin, 'index.json']);
bool foundIndexJson = false;
for (FileSystemEntity f
in new Directory(normalOrigin).listSync(recursive: true)) {
- var fullPath = pathLib.normalize(f.path);
+ var fullPath = path.normalize(f.path);
if (f is Directory) {
continue;
}
@@ -214,7 +216,7 @@
continue;
}
if (visited.contains(fullPath)) continue;
- String relativeFullPath = pathLib.relative(fullPath, from: normalOrigin);
+ String relativeFullPath = path.relative(fullPath, from: normalOrigin);
if (!writtenFiles.contains(relativeFullPath)) {
// This isn't a file we wrote (this time); don't claim we did.
_warn(packageGraph, PackageWarning.unknownFile, fullPath, normalOrigin);
@@ -259,8 +261,8 @@
void _doSearchIndexCheck(
PackageGraph packageGraph, String origin, Set<String> visited) {
- String fullPath = pathLib.joinAll([origin, 'index.json']);
- String indexPath = pathLib.joinAll([origin, 'index.html']);
+ String fullPath = path.joinAll([origin, 'index.json']);
+ String indexPath = path.joinAll([origin, 'index.html']);
File file = new File("$fullPath");
if (!file.existsSync()) {
return null;
@@ -275,10 +277,10 @@
found.add(indexPath);
for (Map<String, dynamic> entry in jsonData) {
if (entry.containsKey('href')) {
- String entryPath = pathLib.joinAll([origin, entry['href']]);
+ String entryPath = path.joinAll([origin, entry['href']]);
if (!visited.contains(entryPath)) {
_warn(packageGraph, PackageWarning.brokenLink, entryPath,
- pathLib.normalize(origin),
+ path.normalize(origin),
referredFrom: fullPath);
}
found.add(entryPath);
@@ -288,7 +290,7 @@
Set<String> missing_from_search = visited.difference(found);
for (String s in missing_from_search) {
_warn(packageGraph, PackageWarning.missingFromSearchIndex, s,
- pathLib.normalize(origin),
+ path.normalize(origin),
referredFrom: fullPath);
}
}
@@ -297,14 +299,14 @@
String pathToCheck,
[String source, String fullPath]) {
if (fullPath == null) {
- fullPath = pathLib.joinAll([origin, pathToCheck]);
- fullPath = pathLib.normalize(fullPath);
+ fullPath = path.joinAll([origin, pathToCheck]);
+ fullPath = path.normalize(fullPath);
}
Tuple2 stringLinksAndHref = _getStringLinksAndHref(fullPath);
if (stringLinksAndHref == null) {
_warn(packageGraph, PackageWarning.brokenLink, pathToCheck,
- pathLib.normalize(origin),
+ path.normalize(origin),
referredFrom: source);
_onCheckProgress.add(pathToCheck);
// Remove so that we properly count that the file doesn't exist for
@@ -328,18 +330,20 @@
Uri uri;
try {
uri = Uri.parse(href);
- } catch (FormatError) {}
+ } catch (FormatError) {
+ // ignore
+ }
if (uri == null || !uri.hasAuthority && !uri.hasFragment) {
var full;
if (baseHref != null) {
- full = '${pathLib.dirname(pathToCheck)}/$baseHref/$href';
+ full = '${path.dirname(pathToCheck)}/$baseHref/$href';
} else {
- full = '${pathLib.dirname(pathToCheck)}/$href';
+ full = '${path.dirname(pathToCheck)}/$href';
}
- var newPathToCheck = pathLib.normalize(full);
- String newFullPath = pathLib.joinAll([origin, newPathToCheck]);
- newFullPath = pathLib.normalize(newFullPath);
+ var newPathToCheck = path.normalize(full);
+ String newFullPath = path.joinAll([origin, newPathToCheck]);
+ newFullPath = path.normalize(newFullPath);
if (!visited.contains(newFullPath)) {
toVisit.add(new Tuple2(newPathToCheck, newFullPath));
visited.add(newFullPath);
diff --git a/lib/src/dartdoc_options.dart b/lib/src/dartdoc_options.dart
index 6678e70..9b78b07 100644
--- a/lib/src/dartdoc_options.dart
+++ b/lib/src/dartdoc_options.dart
@@ -26,7 +26,7 @@
import 'package:dartdoc/src/tool_runner.dart';
import 'package:dartdoc/src/tuple.dart';
import 'package:dartdoc/src/warnings.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as p;
import 'package:yaml/yaml.dart';
/// Constants to help with type checking, because T is int and so forth
@@ -41,8 +41,7 @@
/// Args are computed relative to the current directory at the time the
/// program starts.
final Directory directoryCurrent = Directory.current;
-final String directoryCurrentPath =
- pathLib.canonicalize(Directory.current.path);
+final String directoryCurrentPath = p.canonicalize(Directory.current.path);
class DartdocOptionError extends DartdocFailure {
DartdocOptionError(String details) : super(details);
@@ -85,7 +84,7 @@
}
static CategoryConfiguration fromYamlMap(
- YamlMap yamlMap, pathLib.Context pathContext) {
+ YamlMap yamlMap, p.Context pathContext) {
Map<String, CategoryDefinition> newCategoryDefinitions = {};
for (MapEntry entry in yamlMap.entries) {
String name = entry.key.toString();
@@ -136,7 +135,7 @@
/// Returns true if the given executable path has an extension recognized as a
/// Dart extension (e.g. '.dart' or '.snapshot').
static bool isDartExecutable(String executable) {
- var extension = pathLib.extension(executable);
+ var extension = p.extension(executable);
return extension == '.dart' || extension == '.snapshot';
}
@@ -189,6 +188,7 @@
///
class Snapshot {
File _snapshotFile;
+
File get snapshotFile => _snapshotFile;
final Completer _snapshotCompleter = Completer();
@@ -199,7 +199,7 @@
snapshotCompleted();
} else {
_snapshotFile =
- File(pathLib.join(snapshotCache.absolute.path, 'snapshot_$serial'));
+ File(p.join(snapshotCache.absolute.path, 'snapshot_$serial'));
}
}
@@ -216,6 +216,7 @@
}
Future<void> snapshotValid() => _snapshotCompleter.future;
+
void snapshotCompleted() => _snapshotCompleter.complete();
}
@@ -294,6 +295,7 @@
final Map<String, ToolDefinition> tools;
ToolRunner _runner;
+
ToolRunner get runner => _runner ??= ToolRunner(this);
ToolConfiguration._(this.tools);
@@ -303,8 +305,7 @@
}
// TODO(jcollins-g): consider caching these.
- static ToolConfiguration fromYamlMap(
- YamlMap yamlMap, pathLib.Context pathContext) {
+ static ToolConfiguration fromYamlMap(YamlMap yamlMap, p.Context pathContext) {
var newToolDefinitions = <String, ToolDefinition>{};
for (var entry in yamlMap.entries) {
var name = entry.key.toString();
@@ -428,14 +429,14 @@
String definingFile;
/// A [pathLib.Context] variable initialized with canonicalDirectoryPath.
- pathLib.Context pathContext;
+ p.Context pathContext;
/// Build a _OptionValueWithContext.
/// [path] is the path where this value came from (not required to be canonical)
_OptionValueWithContext(this.value, String path, {String definingFile}) {
this.definingFile = definingFile;
- canonicalDirectoryPath = pathLib.canonicalize(path);
- pathContext = new pathLib.Context(current: canonicalDirectoryPath);
+ canonicalDirectoryPath = p.canonicalize(path);
+ pathContext = new p.Context(current: canonicalDirectoryPath);
}
/// Assume value is a path, and attempt to resolve it. Throws [UnsupportedError]
@@ -502,7 +503,7 @@
}
/// Closure to convert yaml data into some other structure.
- T Function(YamlMap, pathLib.Context) _convertYamlToType;
+ T Function(YamlMap, p.Context) _convertYamlToType;
// The choice not to use reflection means there's some ugly type checking,
// somewhat more ugly than we'd have to do anyway to automatically convert
@@ -510,10 +511,15 @@
//
// Condense the ugly all in one place, this set of getters.
bool get _isString => _kStringVal is T;
+
bool get _isListString => _kListStringVal is T;
+
bool get _isMapString => _kMapStringVal is T;
+
bool get _isBool => _kBoolVal is T;
+
bool get _isInt => _kIntVal is T;
+
bool get _isDouble => _kDoubleVal is T;
DartdocOption _parent;
@@ -529,6 +535,7 @@
root.__yamlAtCanonicalPathCache;
final ArgParser __argParser = new ArgParser();
+
ArgParser get argParser => root.__argParser;
ArgResults __argResults;
@@ -573,8 +580,9 @@
/// For a [List<String>] or [String] value, if [isDir] or [isFile] is set,
/// resolve paths in value relative to canonicalPath.
T _handlePathsInContext(_OptionValueWithContext valueWithContext) {
- if (valueWithContext?.value == null || !(isDir || isFile))
+ if (valueWithContext?.value == null || !(isDir || isFile)) {
return valueWithContext?.value;
+ }
_validatePaths(valueWithContext);
return valueWithContext.resolvedValue;
}
@@ -583,6 +591,7 @@
/// children.
void parseArguments(List<String> arguments) =>
root._parseArguments(arguments);
+
ArgResults get _argResults => root.__argResults;
/// Set the parent of this [DartdocOption]. Do not call more than once.
@@ -631,14 +640,15 @@
T valueAtCurrent() => valueAt(directoryCurrent);
/// Calls [valueAt] on the directory this element is defined in.
- T valueAtElement(Element element) => valueAt(new Directory(
- pathLib.canonicalize(pathLib.basename(element.source.fullName))));
+ T valueAtElement(Element element) => valueAt(
+ new Directory(p.canonicalize(p.basename(element.source.fullName))));
/// Adds a DartdocOption to the children of this DartdocOption.
void add(DartdocOption option) {
- if (_children.containsKey(option.name))
+ if (_children.containsKey(option.name)) {
throw new DartdocOptionError(
'Tried to add two children with the same name: ${option.name}');
+ }
_children[option.name] = option;
option.parent = this;
option.traverse((option) => option._onAdd());
@@ -670,13 +680,14 @@
bool _parentDirOverridesChild;
@override
T Function(DartdocSyntheticOption<T>, Directory) _compute;
+
DartdocOptionFileSynth(String name, this._compute,
{bool mustExist = false,
String help = '',
bool isDir = false,
bool isFile = false,
bool parentDirOverridesChild,
- T Function(YamlMap, pathLib.Context) convertYamlToType})
+ T Function(YamlMap, p.Context) convertYamlToType})
: super(name, null, help, isDir, isFile, mustExist, convertYamlToType) {
_parentDirOverridesChild = parentDirOverridesChild;
}
@@ -715,6 +726,7 @@
@override
T Function(DartdocSyntheticOption<T>, Directory) _compute;
+
DartdocOptionArgSynth(String name, this._compute,
{String abbr,
bool mustExist = false,
@@ -747,8 +759,10 @@
@override
String get abbr => _abbr;
+
@override
bool get hide => _hide;
+
@override
bool get negatable => _negatable;
@@ -765,6 +779,7 @@
with DartdocSyntheticOption<T> {
@override
T Function(DartdocSyntheticOption<T>, Directory) _compute;
+
DartdocOptionSyntheticOnly(String name, this._compute,
{bool mustExist = false,
String help = '',
@@ -864,10 +879,13 @@
@override
String get abbr => _abbr;
+
@override
bool get hide => _hide;
+
@override
bool get negatable => _negatable;
+
@override
bool get splitCommas => _splitCommas;
}
@@ -921,12 +939,16 @@
@override
String get abbr => _abbr;
+
@override
bool get hide => _hide;
+
@override
bool get negatable => _negatable;
+
@override
bool get parentDirOverridesChild => _parentDirOverridesChild;
+
@override
bool get splitCommas => _splitCommas;
}
@@ -934,13 +956,14 @@
class DartdocOptionFileOnly<T> extends DartdocOption<T>
with _DartdocFileOption<T> {
bool _parentDirOverridesChild;
+
DartdocOptionFileOnly(String name, T defaultsTo,
{bool mustExist = false,
String help = '',
bool isDir = false,
bool isFile = false,
bool parentDirOverridesChild = false,
- T Function(YamlMap, pathLib.Context) convertYamlToType})
+ T Function(YamlMap, p.Context) convertYamlToType})
: super(name, defaultsTo, help, isDir, isFile, mustExist,
convertYamlToType) {
_parentDirOverridesChild = parentDirOverridesChild;
@@ -973,7 +996,7 @@
void _onMissingFromFiles(
_OptionValueWithContext valueWithContext, String missingPath) {
- String dartdocYaml = pathLib.join(
+ String dartdocYaml = p.join(
valueWithContext.canonicalDirectoryPath, valueWithContext.definingFile);
throw new DartdocFileMissing(
'Field ${fieldName} from ${dartdocYaml}, set to ${valueWithContext.value}, resolves to missing path: "${missingPath}"');
@@ -988,10 +1011,11 @@
}
final Map<String, T> __valueAtFromFiles = new Map();
+
// The value of this option from files will not change unless files are
// modified during execution (not allowed in Dartdoc).
T _valueAtFromFiles(Directory dir) {
- String key = pathLib.canonicalize(dir.path);
+ String key = p.canonicalize(dir.path);
if (!__valueAtFromFiles.containsKey(key)) {
_OptionValueWithContext valueWithContext;
if (parentDirOverridesChild) {
@@ -1011,7 +1035,7 @@
_OptionValueWithContext value;
while (true) {
value = _valueAtFromFile(dir);
- if (value != null || pathLib.equals(dir.parent.path, dir.path)) break;
+ if (value != null || p.equals(dir.parent.path, dir.path)) break;
dir = dir.parent;
}
return value;
@@ -1025,7 +1049,7 @@
while (true) {
_OptionValueWithContext tmpValue = _valueAtFromFile(dir);
if (tmpValue != null) value = tmpValue;
- if (pathLib.equals(dir.parent.path, dir.path)) break;
+ if (p.equals(dir.parent.path, dir.path)) break;
dir = dir.parent;
}
return value;
@@ -1059,7 +1083,7 @@
// _OptionValueWithContext into the return data here, and would not have
// that be separate.
if (_isMapString && _convertYamlToType == null) {
- _convertYamlToType = (YamlMap yamlMap, pathLib.Context pathContext) {
+ _convertYamlToType = (YamlMap yamlMap, p.Context pathContext) {
var returnData = <String, String>{};
for (MapEntry entry in yamlMap.entries) {
returnData[entry.key.toString()] = entry.value.toString();
@@ -1071,9 +1095,9 @@
throw new DartdocOptionError(
'Unable to convert yaml to type for option: $fieldName, method not defined');
}
- String canonicalDirectoryPath = pathLib.canonicalize(contextPath);
+ String canonicalDirectoryPath = p.canonicalize(contextPath);
returnData = _convertYamlToType(
- yamlData, new pathLib.Context(current: canonicalDirectoryPath));
+ yamlData, new p.Context(current: canonicalDirectoryPath));
} else if (_isDouble) {
if (yamlData is num) {
returnData = yamlData.toDouble();
@@ -1090,7 +1114,7 @@
}
_YamlFileData _yamlAtDirectory(Directory dir) {
- List<String> canonicalPaths = [pathLib.canonicalize(dir.path)];
+ List<String> canonicalPaths = [p.canonicalize(dir.path)];
if (!_yamlAtCanonicalPathCache.containsKey(canonicalPaths.first)) {
_YamlFileData yamlData =
new _YamlFileData(new Map(), directoryCurrentPath);
@@ -1099,16 +1123,16 @@
while (true) {
dartdocOptionsFile =
- new File(pathLib.join(dir.path, 'dartdoc_options.yaml'));
+ new File(p.join(dir.path, 'dartdoc_options.yaml'));
if (dartdocOptionsFile.existsSync() ||
- pathLib.equals(dir.parent.path, dir.path)) break;
+ p.equals(dir.parent.path, dir.path)) break;
dir = dir.parent;
- canonicalPaths.add(pathLib.canonicalize(dir.path));
+ canonicalPaths.add(p.canonicalize(dir.path));
}
if (dartdocOptionsFile.existsSync()) {
yamlData = new _YamlFileData(
loadYaml(dartdocOptionsFile.readAsStringSync()),
- pathLib.canonicalize(dir.path));
+ p.canonicalize(dir.path));
}
}
canonicalPaths.forEach((p) => _yamlAtCanonicalPathCache[p] = yamlData);
@@ -1265,6 +1289,7 @@
/// DartdocOptionContext mixins they use for calculating synthetic options.
abstract class DartdocOptionContextBase {
DartdocOptionSet get optionSet;
+
Directory get context;
}
@@ -1293,8 +1318,8 @@
directoryCurrentPath;
context = new Directory(inputDir);
} else {
- context = new Directory(pathLib
- .canonicalize(entity is File ? entity.parent.path : entity.path));
+ context = new Directory(
+ p.canonicalize(entity is File ? entity.parent.path : entity.path));
}
}
@@ -1321,34 +1346,51 @@
// All values defined in createDartdocOptions should be exposed here.
bool get allowTools => optionSet['allowTools'].valueAt(context);
+
double get ambiguousReexportScorerMinConfidence =>
optionSet['ambiguousReexportScorerMinConfidence'].valueAt(context);
+
bool get autoIncludeDependencies =>
optionSet['autoIncludeDependencies'].valueAt(context);
+
List<String> get categoryOrder => optionSet['categoryOrder'].valueAt(context);
+
CategoryConfiguration get categories =>
optionSet['categories'].valueAt(context);
+
List<String> get dropTextFrom => optionSet['dropTextFrom'].valueAt(context);
+
String get examplePathPrefix =>
optionSet['examplePathPrefix'].valueAt(context);
+
List<String> get exclude => optionSet['exclude'].valueAt(context);
+
List<String> get excludePackages =>
optionSet['excludePackages'].valueAt(context);
String get flutterRoot => optionSet['flutterRoot'].valueAt(context);
+
bool get hideSdkText => optionSet['hideSdkText'].valueAt(context);
+
List<String> get include => optionSet['include'].valueAt(context);
+
List<String> get includeExternal =>
optionSet['includeExternal'].valueAt(context);
+
bool get includeSource => optionSet['includeSource'].valueAt(context);
+
bool get injectHtml => optionSet['injectHtml'].valueAt(context);
+
ToolConfiguration get tools => optionSet['tools'].valueAt(context);
/// _input is only used to construct synthetic options.
// ignore: unused_element
String get _input => optionSet['input'].valueAt(context);
+
String get inputDir => optionSet['inputDir'].valueAt(context);
+
bool get linkToRemote => optionSet['linkTo']['remote'].valueAt(context);
+
String get linkToUrl => optionSet['linkTo']['url'].valueAt(context);
/// _linkToHosted is only used to construct synthetic options.
@@ -1356,19 +1398,28 @@
String get _linkToHosted => optionSet['linkTo']['hosted'].valueAt(context);
String get output => optionSet['output'].valueAt(context);
+
PackageMeta get packageMeta => optionSet['packageMeta'].valueAt(context);
+
List<String> get packageOrder => optionSet['packageOrder'].valueAt(context);
+
bool get sdkDocs => optionSet['sdkDocs'].valueAt(context);
+
String get sdkDir => optionSet['sdkDir'].valueAt(context);
+
bool get showUndocumentedCategories =>
optionSet['showUndocumentedCategories'].valueAt(context);
+
PackageMeta get topLevelPackageMeta =>
optionSet['topLevelPackageMeta'].valueAt(context);
+
bool get useCategories => optionSet['useCategories'].valueAt(context);
+
bool get validateLinks => optionSet['validateLinks'].valueAt(context);
bool isLibraryExcluded(String name) =>
exclude.any((pattern) => name == pattern);
+
bool isPackageExcluded(String name) =>
excludePackages.any((pattern) => name == pattern);
}
@@ -1508,7 +1559,7 @@
help: 'Allow links to be generated for packages outside this one.',
negatable: true),
]),
- new DartdocOptionArgOnly<String>('output', pathLib.join('doc', 'api'),
+ new DartdocOptionArgOnly<String>('output', p.join('doc', 'api'),
isDir: true, help: 'Path to output directory.'),
new DartdocOptionSyntheticOnly<PackageMeta>(
'packageMeta',
@@ -1537,7 +1588,7 @@
throw new DartdocOptionError(
'Top level package requires Flutter but FLUTTER_ROOT environment variable not set');
}
- return pathLib.join(flutterRoot, 'bin', 'cache', 'dart-sdk');
+ return p.join(flutterRoot, 'bin', 'cache', 'dart-sdk');
}
return defaultSdkDir.absolute.path;
}, help: 'Path to the SDK directory.', isDir: true, mustExist: true),
diff --git a/lib/src/html/html_generator.dart b/lib/src/html/html_generator.dart
index b09db48..89b6402 100644
--- a/lib/src/html/html_generator.dart
+++ b/lib/src/html/html_generator.dart
@@ -15,7 +15,7 @@
import 'package:dartdoc/src/html/template_data.dart';
import 'package:dartdoc/src/html/templates.dart';
import 'package:dartdoc/src/model.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
typedef String Renderer(String input);
@@ -84,7 +84,7 @@
// docs somehow. Check data.self.isCanonical and callers for bugs.
assert(allowOverwrite || !writtenFiles.contains(filePath));
- var file = new File(pathLib.join(outputDirectoryPath, filePath));
+ var file = new File(path.join(outputDirectoryPath, filePath));
var parent = file.parent;
if (!parent.existsSync()) {
parent.createSync(recursive: true);
@@ -209,7 +209,7 @@
// TODO(jcollins-g): Eliminate special casing for SDK and use config file.
if (topLevelPackageMeta.isSdk == true) {
footerTextPaths
- .add(pathLib.canonicalize(_sdkFooterCopyrightUri.toFilePath()));
+ .add(path.canonicalize(_sdkFooterCopyrightUri.toFilePath()));
}
footerTextPaths.addAll(option.parent['footerText'].valueAt(dir));
return footerTextPaths;
diff --git a/lib/src/html/html_generator_instance.dart b/lib/src/html/html_generator_instance.dart
index 79052ec..6b86232 100644
--- a/lib/src/html/html_generator_instance.dart
+++ b/lib/src/html/html_generator_instance.dart
@@ -17,7 +17,7 @@
import 'package:dartdoc/src/model_utils.dart';
import 'package:dartdoc/src/warnings.dart';
import 'package:mustache/mustache.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
typedef void FileWriter(String path, Object content, {bool allowOverwrite});
@@ -42,7 +42,7 @@
if (_options.faviconPath != null) {
var bytes = new File(_options.faviconPath).readAsBytesSync();
// Allow overwrite of favicon.
- _writer(pathLib.join('static-assets', 'favicon.png'), bytes,
+ _writer(path.join('static-assets', 'favicon.png'), bytes,
allowOverwrite: true);
}
}
@@ -73,10 +73,11 @@
});
String json = encoder.convert(indexItems);
- _writer(pathLib.join('categories.json'), '${json}\n');
+ _writer(path.join('categories.json'), '${json}\n');
}
List<Categorization> _categorizationItems;
+
void _generateSearchIndex() {
var encoder = _options.prettyIndexJson
? new JsonEncoder.withIndent(' ')
@@ -84,8 +85,9 @@
_categorizationItems = [];
final List<Map> indexItems = _indexedElements.map((Indexable e) {
- if (e is Categorization && e.hasCategorization)
+ if (e is Categorization && e.hasCategorization) {
_categorizationItems.add(e);
+ }
Map data = {
'name': e.name,
'qualifiedName': e.fullyQualifiedName,
@@ -114,7 +116,7 @@
});
String json = encoder.convert(indexItems);
- _writer(pathLib.join('index.json'), '${json}\n');
+ _writer(path.join('index.json'), '${json}\n');
}
void _generateDocs() {
@@ -254,8 +256,8 @@
TemplateData data =
new CategoryTemplateData(_options, packageGraph, category);
- _build(pathLib.joinAll(category.href.split('/')),
- _templates.categoryTemplate, data);
+ _build(path.joinAll(category.href.split('/')), _templates.categoryTemplate,
+ data);
}
void generateLibrary(PackageGraph packageGraph, Library lib) {
@@ -266,22 +268,20 @@
}
TemplateData data = new LibraryTemplateData(_options, packageGraph, lib);
- _build(pathLib.join(lib.dirName, '${lib.fileName}'),
+ _build(path.join(lib.dirName, '${lib.fileName}'),
_templates.libraryTemplate, data);
}
void generateClass(PackageGraph packageGraph, Library lib, Class clazz) {
TemplateData data =
new ClassTemplateData(_options, packageGraph, lib, clazz);
- _build(
- pathLib.joinAll(clazz.href.split('/')), _templates.classTemplate, data);
+ _build(path.joinAll(clazz.href.split('/')), _templates.classTemplate, data);
}
void generateMixins(PackageGraph packageGraph, Library lib, Mixin mixin) {
TemplateData data =
new MixinTemplateData(_options, packageGraph, lib, mixin);
- _build(
- pathLib.joinAll(mixin.href.split('/')), _templates.mixinTemplate, data);
+ _build(path.joinAll(mixin.href.split('/')), _templates.mixinTemplate, data);
}
void generateConstructor(PackageGraph packageGraph, Library lib, Class clazz,
@@ -289,15 +289,14 @@
TemplateData data = new ConstructorTemplateData(
_options, packageGraph, lib, clazz, constructor);
- _build(pathLib.joinAll(constructor.href.split('/')),
+ _build(path.joinAll(constructor.href.split('/')),
_templates.constructorTemplate, data);
}
void generateEnum(PackageGraph packageGraph, Library lib, Enum eNum) {
TemplateData data = new EnumTemplateData(_options, packageGraph, lib, eNum);
- _build(
- pathLib.joinAll(eNum.href.split('/')), _templates.enumTemplate, data);
+ _build(path.joinAll(eNum.href.split('/')), _templates.enumTemplate, data);
}
void generateFunction(
@@ -305,8 +304,8 @@
TemplateData data =
new FunctionTemplateData(_options, packageGraph, lib, function);
- _build(pathLib.joinAll(function.href.split('/')),
- _templates.functionTemplate, data);
+ _build(path.joinAll(function.href.split('/')), _templates.functionTemplate,
+ data);
}
void generateMethod(
@@ -314,8 +313,8 @@
TemplateData data =
new MethodTemplateData(_options, packageGraph, lib, clazz, method);
- _build(pathLib.joinAll(method.href.split('/')), _templates.methodTemplate,
- data);
+ _build(
+ path.joinAll(method.href.split('/')), _templates.methodTemplate, data);
}
void generateConstant(
@@ -323,8 +322,8 @@
TemplateData data =
new ConstantTemplateData(_options, packageGraph, lib, clazz, property);
- _build(pathLib.joinAll(property.href.split('/')),
- _templates.constantTemplate, data);
+ _build(path.joinAll(property.href.split('/')), _templates.constantTemplate,
+ data);
}
void generateProperty(
@@ -332,8 +331,8 @@
TemplateData data =
new PropertyTemplateData(_options, packageGraph, lib, clazz, property);
- _build(pathLib.joinAll(property.href.split('/')),
- _templates.propertyTemplate, data);
+ _build(path.joinAll(property.href.split('/')), _templates.propertyTemplate,
+ data);
}
void generateTopLevelProperty(
@@ -341,7 +340,7 @@
TemplateData data =
new TopLevelPropertyTemplateData(_options, packageGraph, lib, property);
- _build(pathLib.joinAll(property.href.split('/')),
+ _build(path.joinAll(property.href.split('/')),
_templates.topLevelPropertyTemplate, data);
}
@@ -350,7 +349,7 @@
TemplateData data =
new TopLevelConstTemplateData(_options, packageGraph, lib, property);
- _build(pathLib.joinAll(property.href.split('/')),
+ _build(path.joinAll(property.href.split('/')),
_templates.topLevelConstantTemplate, data);
}
@@ -359,7 +358,7 @@
TemplateData data =
new TypedefTemplateData(_options, packageGraph, lib, typeDef);
- _build(pathLib.joinAll(typeDef.href.split('/')), _templates.typeDefTemplate,
+ _build(path.joinAll(typeDef.href.split('/')), _templates.typeDefTemplate,
data);
}
@@ -372,7 +371,7 @@
'encountered $resourcePath');
}
String destFileName = resourcePath.substring(prefix.length);
- _writer(pathLib.join('static-assets', destFileName),
+ _writer(path.join('static-assets', destFileName),
await loader.loadAsBytes(resourcePath));
}
}
diff --git a/lib/src/io_utils.dart b/lib/src/io_utils.dart
index 358d948..d321b1a 100644
--- a/lib/src/io_utils.dart
+++ b/lib/src/io_utils.dart
@@ -8,7 +8,7 @@
import 'dart:async';
import 'dart:io';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
/// Return a resolved path including the home directory in place of tilde
/// references.
@@ -20,12 +20,12 @@
String homeDir;
if (Platform.isWindows) {
- homeDir = pathLib.absolute(Platform.environment['USERPROFILE']);
+ homeDir = path.absolute(Platform.environment['USERPROFILE']);
} else {
- homeDir = pathLib.absolute(Platform.environment['HOME']);
+ homeDir = path.absolute(Platform.environment['HOME']);
}
- return pathLib.join(homeDir, originalPath.substring(2));
+ return path.join(homeDir, originalPath.substring(2));
}
/// Lists the contents of [dir].
@@ -53,7 +53,7 @@
for (var entity in listDir(new Directory(dir))) {
// Skip hidden files and directories
- if (pathLib.basename(entity.path).startsWith('.')) {
+ if (path.basename(entity.path).startsWith('.')) {
continue;
}
diff --git a/lib/src/markdown_processor.dart b/lib/src/markdown_processor.dart
index c71592c..1d0b4bd 100644
--- a/lib/src/markdown_processor.dart
+++ b/lib/src/markdown_processor.dart
@@ -153,6 +153,7 @@
class MatchingLinkResult {
final ModelElement element;
final bool warn;
+
MatchingLinkResult(this.element, {this.warn = true});
}
@@ -211,8 +212,9 @@
}
// Ignore all parameters.
- if (refModelElement is Parameter || refModelElement is TypeParameter)
+ if (refModelElement is Parameter || refModelElement is TypeParameter) {
return new MatchingLinkResult(null, warn: false);
+ }
// There have been places in the code which helpfully cache entities
// regardless of what package they are associated with. This assert
@@ -433,9 +435,11 @@
}
List<String> _codeRefParts;
+
List<String> get codeRefParts => _codeRefParts ??= codeRef.split('.');
List<String> _codeRefChompedParts;
+
List<String> get codeRefChompedParts =>
_codeRefChompedParts ??= codeRefChomped.split('.');
@@ -933,9 +937,11 @@
class Documentation {
final Canonicalization _element;
+
Documentation.forElement(this._element);
bool _hasExtendedDocs;
+
bool get hasExtendedDocs {
if (_hasExtendedDocs == null) {
_renderHtmlForDartdoc(_element.isCanonical && _asHtml == null);
@@ -944,6 +950,7 @@
}
String _asHtml;
+
String get asHtml {
if (_asHtml == null) {
assert(_asOneLiner == null || _element.isCanonical);
@@ -953,6 +960,7 @@
}
String _asOneLiner;
+
String get asOneLiner {
if (_asOneLiner == null) {
assert(_asHtml == null);
diff --git a/lib/src/model.dart b/lib/src/model.dart
index 454d84d..a417a57 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -23,28 +23,30 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/visitor.dart';
-import 'package:analyzer/file_system/file_system.dart' as fileSystem;
+import 'package:analyzer/file_system/file_system.dart' as file_system;
import 'package:analyzer/file_system/physical_file_system.dart';
-import 'package:analyzer/src/source/package_map_resolver.dart';
-import 'package:analyzer/src/source/sdk_ext.dart';
-// TODO(jcollins-g): Stop using internal analyzer structures somehow.
import 'package:analyzer/src/context/builder.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
+import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/handle.dart';
+import 'package:analyzer/src/dart/element/member.dart'
+ show ExecutableMember, Member, ParameterMember;
import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult;
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/resolver.dart'
- show Namespace, NamespaceBuilder, InheritanceManager; // ignore: deprecated_member_use
+ show
+ Namespace,
+ NamespaceBuilder,
+ InheritanceManager; // ignore: deprecated_member_use
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
-import 'package:analyzer/src/dart/element/member.dart'
- show ExecutableMember, Member, ParameterMember;
-import 'package:analyzer/src/dart/analysis/driver.dart';
+import 'package:analyzer/src/source/package_map_resolver.dart';
+import 'package:analyzer/src/source/sdk_ext.dart';
import 'package:args/args.dart';
import 'package:collection/collection.dart';
import 'package:crypto/crypto.dart';
@@ -61,10 +63,10 @@
import 'package:dartdoc/src/tuple.dart';
import 'package:dartdoc/src/utils.dart';
import 'package:dartdoc/src/warnings.dart';
-import 'package:path/path.dart' as pathLib;
-import 'package:pub_semver/pub_semver.dart';
import 'package:package_config/discovery.dart' as package_config;
-import 'package:quiver/iterables.dart' as quiverIterables;
+import 'package:path/path.dart' as path;
+import 'package:pub_semver/pub_semver.dart';
+import 'package:quiver/iterables.dart' as quiver;
int byName(Nameable a, Nameable b) =>
compareAsciiLowerCaseNatural(a.name, b.name);
@@ -158,6 +160,7 @@
/// the one in the public namespace that will be documented.
abstract class Inheritable implements ModelElement {
bool get isInherited;
+
bool _canonicalEnclosingClassIsSet = false;
Class _canonicalEnclosingClass;
Class _definingEnclosingClass;
@@ -264,6 +267,7 @@
Inheritable get overriddenElement;
bool _isOverride;
+
bool get isOverride {
if (_isOverride == null) {
// The canonical version of the enclosing element -- not canonicalEnclosingElement,
@@ -300,6 +304,7 @@
}
int _overriddenDepth;
+
@override
int get overriddenDepth {
if (_overriddenDepth == null) {
@@ -335,6 +340,7 @@
ModelElement _enclosingElement;
bool _isInherited = false;
+
InheritableAccessor(PropertyAccessorElement element, Library library,
PackageGraph packageGraph)
: super(element, library, packageGraph, null);
@@ -359,6 +365,7 @@
bool _overriddenElementIsSet = false;
ModelElement _overriddenElement;
+
@override
InheritableAccessor get overriddenElement {
assert(packageGraph.allLibrariesAdded);
@@ -501,6 +508,7 @@
}
bool get isGetter => _accessor.isGetter;
+
bool get isSetter => _accessor.isSetter;
@override
@@ -562,6 +570,7 @@
bool get hasPublicSuperclassConstraints =>
publicSuperclassConstraints.isNotEmpty;
+
Iterable<ParameterizedElementType> get publicSuperclassConstraints =>
filterNonPublic(superclassConstraints);
@@ -615,6 +624,7 @@
}
Constructor _defaultConstructor;
+
Constructor get defaultConstructor {
if (_defaultConstructor == null) {
_defaultConstructor = constructors
@@ -624,7 +634,7 @@
}
Iterable<Method> get allInstanceMethods =>
- quiverIterables.concat([instanceMethods, inheritedMethods]);
+ quiver.concat([instanceMethods, inheritedMethods]);
Iterable<Method> get allPublicInstanceMethods =>
filterNonPublic(allInstanceMethods);
@@ -633,9 +643,9 @@
instanceMethods.every((f) => f.isInherited);
Iterable<Field> get allInstanceFields =>
- quiverIterables.concat([instanceProperties, inheritedProperties]);
+ quiver.concat([instanceProperties, inheritedProperties]);
- Iterable<Accessor> get allAccessors => quiverIterables.concat([
+ Iterable<Accessor> get allAccessors => quiver.concat([
allInstanceFields.expand((f) => f.allAccessors),
constants.map((c) => c.getter)
]);
@@ -647,7 +657,7 @@
allPublicInstanceProperties.every((f) => f.isInherited);
Iterable<Operator> get allOperators =>
- quiverIterables.concat([operators, inheritedOperators]);
+ quiver.concat([operators, inheritedOperators]);
Iterable<Operator> get allPublicOperators => filterNonPublic(allOperators);
@@ -665,6 +675,7 @@
Iterable<Field> get publicConstants => filterNonPublic(constants);
Map<Element, ModelElement> _allElements;
+
Map<Element, ModelElement> get allElements {
if (_allElements == null) {
_allElements = new Map();
@@ -706,8 +717,9 @@
if (_membersByName == null) {
_membersByName = new Map();
for (ModelElement me in allModelElements) {
- if (!_membersByName.containsKey(me.name))
+ if (!_membersByName.containsKey(me.name)) {
_membersByName[me.name] = new List();
+ }
_membersByName[me.name].add(me);
}
}
@@ -724,10 +736,11 @@
}
List<ModelElement> _allModelElements;
+
List<ModelElement> get allModelElements {
if (_allModelElements == null) {
_allModelElements = new List.from(
- quiverIterables.concat([
+ quiver.concat([
allInstanceMethods,
allInstanceFields,
allAccessors,
@@ -744,6 +757,7 @@
}
List<ModelElement> _allCanonicalModelElements;
+
List<ModelElement> get allCanonicalModelElements {
return (_allCanonicalModelElements ??=
allModelElements.where((e) => e.isCanonical).toList());
@@ -813,8 +827,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalLibrary == library);
return '${package.baseHref}${library.dirName}/$fileName';
@@ -914,7 +929,9 @@
Iterable<Field> get publicInstanceProperties =>
filterNonPublic(instanceProperties);
+
List<DefinedElementType> get interfaces => _interfaces;
+
Iterable<DefinedElementType> get publicInterfaces =>
filterNonPublic(interfaces);
@@ -991,6 +1008,7 @@
/// to include them in the set of things we might link to for documentation
/// purposes in abstract classes.
List<Class> _inheritanceChain;
+
List<Class> get inheritanceChain {
if (_inheritanceChain == null) {
_inheritanceChain = [];
@@ -1036,16 +1054,20 @@
Iterable<DefinedElementType> get publicSuperChain =>
filterNonPublic(superChain);
+
Iterable<DefinedElementType> get publicSuperChainReversed =>
publicSuperChain.toList().reversed;
List<ExecutableElement> __inheritedElements;
+
List<ExecutableElement> get _inheritedElements {
if (__inheritedElements == null) {
Map<String, ExecutableElement> cmap = definingLibrary.inheritanceManager
- .getMembersInheritedFromClasses(element); // ignore: deprecated_member_use
+ .getMembersInheritedFromClasses(
+ element); // ignore: deprecated_member_use
Map<String, ExecutableElement> imap = definingLibrary.inheritanceManager
- .getMembersInheritedFromInterfaces(element); // ignore: deprecated_member_use
+ .getMembersInheritedFromInterfaces(
+ element); // ignore: deprecated_member_use
__inheritedElements = new List.from(cmap.values)
..addAll(imap.values.where((e) => !cmap.containsKey(e.name)));
}
@@ -1130,7 +1152,8 @@
f = getterElement.variable;
} else if (getter == null && setter != null) {
f = setterElement.variable;
- } else /* getter != null && setter != null */ {
+ } else
+ /* getter != null && setter != null */ {
// In cases where a Field is composed of two Accessors defined in
// different places in the inheritance chain, there are two FieldElements
// for this single Field we're trying to compose. Pick the one closest
@@ -1174,6 +1197,7 @@
}
List<TypeParameter> _typeParameters;
+
// a stronger hash?
@override
List<TypeParameter> get typeParameters {
@@ -1224,8 +1248,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalLibrary == library);
return '${package.baseHref}${enclosingElement.library.dirName}/${enclosingElement.name}/$name.html';
@@ -1245,6 +1270,7 @@
DefinedElementType get modelType => super.modelType;
String _name;
+
@override
String get name {
if (_name == null) {
@@ -1259,6 +1285,7 @@
}
String _nameWithGenerics;
+
@override
String get nameWithGenerics {
if (_nameWithGenerics == null) {
@@ -1288,12 +1315,19 @@
/// both of which have documentation.
abstract class Documentable extends Nameable {
String get documentation;
+
String get documentationAsHtml;
+
bool get hasDocumentation;
+
bool get hasExtendedDocumentation;
+
String get oneLineDoc;
+
PackageGraph get packageGraph;
+
bool get isDocumented;
+
DartdocOptionContext get config;
}
@@ -1396,6 +1430,7 @@
bool _hasCategorization;
Iterable<Category> _categories;
+
Iterable<Category> get categories {
if (_categories == null) {
_categories = categoryNames
@@ -1425,6 +1460,7 @@
class ModelCommentReference {
final String name;
final Element staticElement;
+
ModelCommentReference(CommentReference ref)
: name = ref.identifier.name,
staticElement = ref.identifier.staticElement;
@@ -1485,9 +1521,11 @@
/// Classes extending this class have canonicalization support in Dartdoc.
abstract class Canonicalization implements Locatable, Documentable {
bool get isCanonical;
+
Library get canonicalLibrary;
List<ModelCommentReference> _commentRefs;
+
List<ModelCommentReference> get commentRefs => _commentRefs;
/// Pieces of the location split by [locationSplitter] (removing package: and
@@ -1581,6 +1619,7 @@
: super(element, library, packageGraph);
List<EnumField> _instanceProperties;
+
@override
List<EnumField> get instanceProperties {
if (_instanceProperties == null) {
@@ -1639,8 +1678,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(!(canonicalLibrary == null || canonicalEnclosingElement == null));
assert(canonicalLibrary == library);
assert(canonicalEnclosingElement == enclosingElement);
@@ -1730,8 +1770,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalEnclosingElement == enclosingElement);
assert(canonicalLibrary == library);
@@ -1862,10 +1903,12 @@
Set<String> get comboFeatures {
Set<String> allFeatures = new Set();
- if (hasExplicitGetter && hasPublicGetter)
+ if (hasExplicitGetter && hasPublicGetter) {
allFeatures.addAll(getter.features);
- if (hasExplicitSetter && hasPublicSetter)
+ }
+ if (hasExplicitSetter && hasPublicSetter) {
allFeatures.addAll(setter.features);
+ }
if (readOnly && !isFinal && !isConst) allFeatures.add('read-only');
if (writeOnly) allFeatures.add('write-only');
if (readWrite) allFeatures.add('read / write');
@@ -1877,6 +1920,7 @@
@override
ModelElement enclosingElement;
+
bool get isInherited;
Expression get constantInitializer =>
@@ -1907,13 +1951,16 @@
}
String get constantValue => linkifyConstantValue(constantValueBase);
+
String get constantValueTruncated =>
linkifyConstantValue(truncateString(constantValueBase, 200));
String _constantValueBase;
+
String get constantValueBase =>
_constantValueBase ??= _buildConstantValueBase();
bool get hasPublicGetter => hasGetter && getter.isPublic;
+
bool get hasPublicSetter => hasSetter && setter.isPublic;
@override
@@ -1928,9 +1975,10 @@
} else if (hasPublicSetter) {
_documentationFrom.addAll(setter.documentationFrom);
}
- if (_documentationFrom.isEmpty||
- _documentationFrom.every((e) => e.documentationComment == ''))
+ if (_documentationFrom.isEmpty ||
+ _documentationFrom.every((e) => e.documentationComment == '')) {
_documentationFrom = computeDocumentationFrom;
+ }
}
return _documentationFrom;
}
@@ -1941,6 +1989,7 @@
hasPublicSetter &&
!setter.isSynthetic &&
setter.documentation.isNotEmpty);
+
bool get getterSetterBothAvailable => (hasPublicGetter &&
getter.documentation.isNotEmpty &&
hasPublicSetter &&
@@ -2014,11 +2063,13 @@
}
bool get hasExplicitGetter => hasPublicGetter && !getter.isSynthetic;
+
bool get hasExplicitSetter => hasPublicSetter && !setter.isSynthetic;
bool get hasGetter => getter != null;
bool get hasNoGetterSetter => !hasGetterOrSetter;
+
bool get hasGetterOrSetter => hasExplicitGetter || hasExplicitSetter;
bool get hasSetter => setter != null;
@@ -2037,6 +2088,7 @@
}
bool get readOnly => hasPublicGetter && !hasPublicSetter;
+
bool get readWrite => hasPublicGetter && hasPublicSetter;
bool get writeOnly => hasPublicSetter && !hasPublicGetter;
@@ -2049,6 +2101,7 @@
class _HashableChildLibraryElementVisitor
extends GeneralizingElementVisitor<void> {
final void Function(Element) libraryProcessor;
+
_HashableChildLibraryElementVisitor(this.libraryProcessor);
@override
@@ -2108,6 +2161,7 @@
List<String> _allOriginalModelElementNames;
final Package _package;
+
@override
Package get package {
// Everything must be in a package. TODO(jcollins-g): Support other things
@@ -2172,8 +2226,9 @@
return false;
}
if (config.isLibraryExcluded(name) ||
- config.isLibraryExcluded(element.librarySource.uri.toString()))
+ config.isLibraryExcluded(element.librarySource.uri.toString())) {
return false;
+ }
return true;
}
@@ -2249,6 +2304,7 @@
}
String _dirName;
+
String get dirName {
if (_dirName == null) {
_dirName = name;
@@ -2371,17 +2427,19 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
return '${package.baseHref}${library.dirName}/$fileName';
}
// ignore: deprecated_member_use
InheritanceManager _inheritanceManager;
+
// ignore: deprecated_member_use
InheritanceManager get inheritanceManager {
if (_inheritanceManager == null) {
- // ignore: deprecated_member_use
+ // ignore: deprecated_member_use
_inheritanceManager = new InheritanceManager(element);
}
return _inheritanceManager;
@@ -2425,6 +2483,7 @@
/// The real packageMeta, as opposed to the package we are documenting with.
PackageMeta _packageMeta;
+
PackageMeta get packageMeta {
if (_packageMeta == null) {
_packageMeta = new PackageMeta.fromElement(element, config);
@@ -2514,11 +2573,13 @@
_variables = [];
for (TopLevelVariableElement element in elements) {
Accessor getter;
- if (element.getter != null)
+ if (element.getter != null) {
getter = new ModelElement.from(element.getter, this, packageGraph);
+ }
Accessor setter;
- if (element.setter != null)
+ if (element.setter != null) {
setter = new ModelElement.from(element.setter, this, packageGraph);
+ }
ModelElement me = new ModelElement.from(element, this, packageGraph,
getter: getter, setter: setter);
_variables.add(me);
@@ -2567,7 +2628,7 @@
String name = element.name;
if (name == null || name.isEmpty) {
// handle the case of an anonymous library
- name = pathLib.basename(source.fullName);
+ name = path.basename(source.fullName);
if (name.endsWith('.dart')) {
name = name.substring(0, name.length - '.dart'.length);
@@ -2602,27 +2663,28 @@
}
Map<Element, Set<ModelElement>> _modelElementsMap;
+
Map<Element, Set<ModelElement>> get modelElementsMap {
if (_modelElementsMap == null) {
- Iterable<ModelElement> results = quiverIterables.concat([
+ Iterable<ModelElement> results = quiver.concat([
library.constants,
library.functions,
library.properties,
library.typedefs,
library.allClasses.expand((c) {
- return quiverIterables.concat([
+ return quiver.concat([
[c],
c.allModelElements
]);
}),
library.enums.expand((e) {
- return quiverIterables.concat([
+ return quiver.concat([
[e],
e.allModelElements
]);
}),
library.mixins.expand((m) {
- return quiverIterables.concat([
+ return quiver.concat([
[m],
m.allModelElements
]);
@@ -2640,6 +2702,7 @@
}
List<ModelElement> _allModelElements;
+
Iterable<ModelElement> get allModelElements {
if (_allModelElements == null) {
_allModelElements = [];
@@ -2651,6 +2714,7 @@
}
List<ModelElement> _allCanonicalModelElements;
+
Iterable<ModelElement> get allCanonicalModelElements {
return (_allCanonicalModelElements ??=
allModelElements.where((e) => e.isCanonical).toList());
@@ -2700,8 +2764,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(!(canonicalLibrary == null || canonicalEnclosingElement == null));
assert(canonicalLibrary == library);
assert(canonicalEnclosingElement == enclosingElement);
@@ -2844,6 +2909,7 @@
with Privacy, Warnable, Nameable, SourceCodeMixin, Indexable
implements Comparable, Documentable {
final Element _element;
+
// TODO(jcollins-g): This really wants a "member that has a type" class.
final Member _originalMember;
final Library _library;
@@ -2983,20 +3049,22 @@
newModelElement = new Constructor(e, library, packageGraph);
}
if (e is MethodElement && e.isOperator) {
- if (enclosingClass == null)
+ if (enclosingClass == null) {
newModelElement = new Operator(e, library, packageGraph);
- else
+ } else {
newModelElement = new Operator.inherited(
e, enclosingClass, library, packageGraph,
originalMember: originalMember);
+ }
}
if (e is MethodElement && !e.isOperator) {
- if (enclosingClass == null)
+ if (enclosingClass == null) {
newModelElement = new Method(e, library, packageGraph);
- else
+ } else {
newModelElement = new Method.inherited(
e, enclosingClass, library, packageGraph,
originalMember: originalMember);
+ }
}
if (e is TopLevelVariableElement) {
assert(getter != null || setter != null);
@@ -3007,13 +3075,14 @@
// TODO(jcollins-g): why test for ClassElement in enclosingElement?
if (e.enclosingElement is ClassElement ||
e is MultiplyInheritedExecutableElement) {
- if (enclosingClass == null)
+ if (enclosingClass == null) {
newModelElement =
new InheritableAccessor(e, library, packageGraph);
- else
+ } else {
newModelElement = new InheritableAccessor.inherited(
e, library, packageGraph, enclosingClass,
originalMember: originalMember);
+ }
} else {
newModelElement = new Accessor(e, library, packageGraph, null);
}
@@ -3060,6 +3129,7 @@
}
ModelNode _modelNode;
+
@override
ModelNode get modelNode =>
_modelNode ??= packageGraph._getModelNodeFor(element);
@@ -3108,6 +3178,7 @@
}
bool _isPublic;
+
@override
bool get isPublic {
if (_isPublic == null) {
@@ -3150,6 +3221,7 @@
}
DartdocOptionContext _config;
+
@override
DartdocOptionContext get config {
if (_config == null) {
@@ -3206,10 +3278,12 @@
// Returns the canonical ModelElement for this ModelElement, or null
// if there isn't one.
ModelElement _canonicalModelElement;
+
ModelElement get canonicalModelElement =>
_canonicalModelElement ??= _buildCanonicalModelElement();
List<ModelElement> _documentationFrom;
+
// TODO(jcollins-g): untangle when mixins can call super
@override
List<ModelElement> get documentationFrom {
@@ -3221,6 +3295,7 @@
bool get hasSourceHref => sourceHref.isNotEmpty;
String _sourceHref;
+
String get sourceHref {
_sourceHref ??= new SourceLinker.fromElement(this).href();
return _sourceHref;
@@ -3309,6 +3384,7 @@
/// definitions are stripped, but macros themselves are not injected. This
/// is a two stage process to avoid ordering problems.
String _documentationLocal;
+
String get documentationLocal =>
_documentationLocal ??= _buildDocumentationLocal();
@@ -3323,9 +3399,11 @@
packageGraph.findButDoNotCreateLibraryFor(element);
Library _canonicalLibrary;
+
// _canonicalLibrary can be null so we can't check against null to see whether
// we tried to compute it before.
bool _canonicalLibraryIsSet = false;
+
@override
Library get canonicalLibrary {
if (!_canonicalLibraryIsSet) {
@@ -3357,8 +3435,9 @@
Element lookup = (l.element as LibraryElement)
.exportNamespace
.definedNames[topLevelElement?.name];
- if (lookup is PropertyAccessorElement)
+ if (lookup is PropertyAccessorElement) {
lookup = (lookup as PropertyAccessorElement).variable;
+ }
if (topLevelElement == lookup) return true;
return false;
}).toList();
@@ -3402,8 +3481,9 @@
message: message, extendedDebug: debugLines);
}
}
- if (candidateLibraries.isNotEmpty)
+ if (candidateLibraries.isNotEmpty) {
_canonicalLibrary = candidateLibraries.last;
+ }
}
} else {
_canonicalLibrary = definingLibrary;
@@ -3446,6 +3526,7 @@
}
String _htmlDocumentation;
+
@override
String get documentationAsHtml {
if (_htmlDocumentation != null) return _htmlDocumentation;
@@ -3460,9 +3541,9 @@
String get location {
// Call nothing from here that can emit warnings or you'll cause stack overflows.
if (lineAndColumn != null) {
- return "(${pathLib.toUri(sourceFileName)}:${lineAndColumn.item1}:${lineAndColumn.item2})";
+ return "(${path.toUri(sourceFileName)}:${lineAndColumn.item1}:${lineAndColumn.item2})";
}
- return "(${pathLib.toUri(sourceFileName)})";
+ return "(${path.toUri(sourceFileName)})";
}
/// Returns a link to extended documentation, or the empty string if that
@@ -3497,6 +3578,7 @@
Tuple2<int, int> _lineAndColumn;
bool _isLineNumberComputed = false;
+
@override
Tuple2<int, int> get lineAndColumn {
// TODO(jcollins-g): implement lineAndColumn for explicit fields
@@ -3631,6 +3713,7 @@
String computeOneLineDoc() =>
'${_documentation.asOneLiner}${extendedDocLink.isEmpty ? "" : " $extendedDocLink"}';
String _oneLineDoc;
+
@override
String get oneLineDoc {
if (_oneLineDoc == null) {
@@ -3642,6 +3725,7 @@
Member get originalMember => _originalMember;
final PackageGraph _packageGraph;
+
@override
PackageGraph get packageGraph => _packageGraph;
@@ -3652,6 +3736,7 @@
isPublic && library.packageGraph.packageDocumentedFor(this);
List<Parameter> _allParameters;
+
// TODO(jcollins-g): This is in the wrong place. Move parts to GetterSetterCombo,
// elsewhere as appropriate?
List<Parameter> get allParameters {
@@ -3724,6 +3809,7 @@
bool _documentationCommentComputed = false;
String _documentationComment;
+
String get documentationComment {
if (_documentationCommentComputed == false) {
_documentationComment = _computeDocumentationComment();
@@ -3797,8 +3883,9 @@
if (typeName.isNotEmpty) {
buf.write('<span class="type-annotation">$typeName</span>');
}
- if (typeName.isNotEmpty && showNames && param.name.isNotEmpty)
+ if (typeName.isNotEmpty && showNames && param.name.isNotEmpty) {
buf.write(' ');
+ }
if (showNames && param.name.isNotEmpty) {
buf.write('<span class="parameter-name">${param.name}</span>');
}
@@ -3817,7 +3904,9 @@
}
String linkedParams(
- {bool showMetadata = true, bool showNames = true, String separator = ', '}) {
+ {bool showMetadata = true,
+ bool showNames = true,
+ String separator = ', '}) {
List<Parameter> requiredParams =
parameters.where((Parameter p) => !p.isOptional).toList();
List<Parameter> positionalParams =
@@ -3931,11 +4020,11 @@
return '';
}
var lang =
- args['lang'] ?? pathLib.extension(args['src']).replaceFirst('.', '');
+ args['lang'] ?? path.extension(args['src']).replaceFirst('.', '');
var replacement = match[0]; // default to fully matched string.
- var fragmentFile = new File(pathLib.join(dirPath, args['file']));
+ var fragmentFile = new File(path.join(dirPath, args['file']));
if (fragmentFile.existsSync()) {
replacement = fragmentFile.readAsStringSync();
if (lang.isNotEmpty) {
@@ -4044,7 +4133,7 @@
'SOURCE_PATH': (sourceFileName == null ||
package?.packagePath == null)
? null
- : pathLib.relative(sourceFileName, from: package.packagePath),
+ : path.relative(sourceFileName, from: package.packagePath),
'PACKAGE_PATH': package?.packagePath,
'PACKAGE_NAME': package?.name,
'LIBRARY_NAME': library?.fullyQualifiedName,
@@ -4465,8 +4554,9 @@
// by an equals sign), add a "--" in front so that they parse as options.
return matches.map<String>((Match match) {
var option = '';
- if (convertToArgs && match[1] != null && !match[1].startsWith('-'))
+ if (convertToArgs && match[1] != null && !match[1].startsWith('-')) {
option = '--';
+ }
if (match[2] != null) {
// This arg has quotes, so strip them.
return '$option${match[1] ?? ''}${match[3] ?? ''}${match[4] ?? ''}';
@@ -4521,14 +4611,14 @@
var file = src + fragExtension;
var region = args['region'] ?? '';
if (region.isNotEmpty) {
- var dir = pathLib.dirname(src);
- var basename = pathLib.basenameWithoutExtension(src);
- var ext = pathLib.extension(src);
- file = pathLib.join(dir, '$basename-$region$ext$fragExtension');
+ var dir = path.dirname(src);
+ var basename = path.basenameWithoutExtension(src);
+ var ext = path.extension(src);
+ file = path.join(dir, '$basename-$region$ext$fragExtension');
}
args['file'] = config.examplePathPrefix == null
? file
- : pathLib.join(config.examplePathPrefix, file);
+ : path.join(config.examplePathPrefix, file);
return args;
}
}
@@ -4590,8 +4680,9 @@
String get name {
Element e = element;
while (e != null) {
- if (e is FunctionTypeAliasElement || e is GenericTypeAliasElement)
+ if (e is FunctionTypeAliasElement || e is GenericTypeAliasElement) {
return e.name;
+ }
e = e.enclosingElement;
}
assert(false);
@@ -4622,8 +4713,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalLibrary == library);
return '${package.baseHref}${library.dirName}/$fileName';
@@ -4646,9 +4738,11 @@
/// Something that has a name.
abstract class Nameable {
String get name;
+
String get fullyQualifiedName => name;
Set<String> _namePieces;
+
Set<String> get namePieces {
if (_namePieces == null) {
_namePieces = new Set()
@@ -4676,7 +4770,9 @@
/// Something able to be indexed.
abstract class Indexable implements Nameable {
String get href;
+
String get kind;
+
int get overriddenDepth => 0;
}
@@ -4782,7 +4878,9 @@
// Go through docs of every ModelElement in package to pre-build the macros
// index. Uses toList() in order to get all the precaching on the stack.
List<Future> precacheFutures = precacheLocalDocs().toList();
- for (Future f in precacheFutures) await f;
+ for (Future f in precacheFutures) {
+ await f;
+ }
_localDocumentationBuilt = true;
// Scan all model elements to insure that interceptor and other special
@@ -4808,9 +4906,10 @@
Set<ModelElement> precachedElements = new Set();
Iterable<Future> precacheOneElement(ModelElement m) sync* {
- for (ModelElement d in m.documentationFrom.where((d) => d.documentationComment != null)) {
- if (needsPrecacheRegExp.hasMatch(d.documentationComment)
- && !precachedElements.contains(d)) {
+ for (ModelElement d
+ in m.documentationFrom.where((d) => d.documentationComment != null)) {
+ if (needsPrecacheRegExp.hasMatch(d.documentationComment) &&
+ !precachedElements.contains(d)) {
precachedElements.add(d);
yield d._precacheLocalDocs();
}
@@ -4830,6 +4929,7 @@
// Many ModelElements have the same ModelNode; don't build/cache this data more
// than once for them.
final Map<Element, ModelNode> _modelNodes = Map();
+
void _populateModelNodeFor(
Element element, Map<String, CompilationUnit> compilationUnitMap) {
_modelNodes.putIfAbsent(element,
@@ -4850,6 +4950,7 @@
}
Map<String, Set<ModelElement>> _findRefElementCache;
+
Map<String, Set<ModelElement>> get findRefElementCache {
if (_findRefElementCache == null) {
assert(packageGraph.allLibrariesAdded);
@@ -4895,6 +4996,7 @@
final DartdocOptionContext config;
Package _defaultPackage;
+
Package get defaultPackage {
if (_defaultPackage == null) {
_defaultPackage = new Package.fromPackageMeta(packageMeta, this);
@@ -4915,6 +5017,7 @@
final DartSdk sdk;
Map<Source, SdkLibrary> _sdkLibrarySources;
+
Map<Source, SdkLibrary> get sdkLibrarySources {
if (_sdkLibrarySources == null) {
_sdkLibrarySources = new Map();
@@ -4935,6 +5038,7 @@
/// Usable as a cross-check for dartdoc's canonicalization to generate
/// warnings for ModelElement.isPublicAndPackageDocumented.
Set<String> _allRootDirs;
+
bool packageDocumentedFor(ModelElement element) {
if (_allRootDirs == null) {
_allRootDirs = new Set()
@@ -4947,6 +5051,7 @@
final Set<Tuple3<Element, PackageWarning, String>> _warnAlreadySeen =
new Set();
+
void warnOnElement(Warnable warnable, PackageWarning kind,
{String message,
Iterable<Locatable> referredFrom,
@@ -4980,8 +5085,9 @@
if (warnable is Accessor) {
// This might be part of a Field, if so, assign this warning to the field
// rather than the Accessor.
- if ((warnable as Accessor).enclosingCombo != null)
+ if ((warnable as Accessor).enclosingCombo != null) {
warnable = (warnable as Accessor).enclosingCombo;
+ }
}
} else {
// If we don't have an element, we need a message to disambiguate.
@@ -5131,16 +5237,18 @@
List<Package> get packages => packageMap.values.toList();
List<Package> _publicPackages;
+
List<Package> get publicPackages {
if (_publicPackages == null) {
assert(allLibrariesAdded);
// Help the user if they pass us a package that doesn't exist.
for (String packageName in config.packageOrder) {
- if (!packages.map((p) => p.name).contains(packageName))
+ if (!packages.map((p) => p.name).contains(packageName)) {
warnOnElement(
null, PackageWarning.packageOrderGivesMissingPackageName,
message:
"${packageName}, packages: ${packages.map((p) => p.name).join(',')}");
+ }
}
_publicPackages = packages.where((p) => p.isPublic).toList()..sort();
}
@@ -5159,6 +5267,7 @@
/// Prevent cycles from breaking our stack.
Set<Tuple2<Library, LibraryElement>> _reexportsTagged = new Set();
+
void _tagReexportsFor(
final Library topLevelLibrary, final LibraryElement libraryElement,
[ExportElement lastExportedElement]) {
@@ -5187,6 +5296,7 @@
}
int _lastSizeOfAllLibraries = 0;
+
Map<LibraryElement, Set<Library>> get libraryElementReexportedBy {
// Table must be reset if we're still in the middle of adding libraries.
if (allLibraries.keys.length != _lastSizeOfAllLibraries) {
@@ -5263,6 +5373,7 @@
packages.expand((p) => p.libraries).toList()..sort();
List<Library> _publicLibraries;
+
Iterable<Library> get publicLibraries {
if (_publicLibraries == null) {
assert(allLibrariesAdded);
@@ -5272,6 +5383,7 @@
}
List<Library> _localLibraries;
+
Iterable<Library> get localLibraries {
if (_localLibraries == null) {
assert(allLibrariesAdded);
@@ -5282,6 +5394,7 @@
}
List<Library> _localPublicLibraries;
+
Iterable<Library> get localPublicLibraries {
if (_localPublicLibraries == null) {
assert(allLibrariesAdded);
@@ -5461,10 +5574,12 @@
Accessor getter;
Accessor setter;
if (e is PropertyInducingElement) {
- if (e.getter != null)
+ if (e.getter != null) {
getter = new ModelElement.from(e.getter, lib, packageGraph);
- if (e.setter != null)
+ }
+ if (e.setter != null) {
setter = new ModelElement.from(e.setter, lib, packageGraph);
+ }
}
modelElement = new ModelElement.from(e, lib, packageGraph,
getter: getter, setter: setter);
@@ -5515,6 +5630,7 @@
}
List<ModelElement> _allModelElements;
+
Iterable<ModelElement> get allModelElements {
assert(allLibrariesAdded);
if (_allModelElements == null) {
@@ -5543,6 +5659,7 @@
}
List<ModelElement> _allLocalModelElements;
+
Iterable<ModelElement> get allLocalModelElements {
assert(allLibrariesAdded);
if (_allLocalModelElements == null) {
@@ -5555,6 +5672,7 @@
}
List<ModelElement> _allCanonicalModelElements;
+
Iterable<ModelElement> get allCanonicalModelElements {
return (_allCanonicalModelElements ??=
allLocalModelElements.where((e) => e.isCanonical).toList());
@@ -5597,31 +5715,52 @@
List<Typedef> _typedefs;
Iterable<Class> get classes => _classes;
+
Iterable<Enum> get enums => _enums;
+
Iterable<Mixin> get mixins => _mixins;
+
Iterable<Class> get exceptions => _exceptions;
+
Iterable<TopLevelVariable> get constants => _constants;
+
Iterable<TopLevelVariable> get properties => _properties;
+
Iterable<ModelFunction> get functions => _functions;
+
Iterable<Typedef> get typedefs => _typedefs;
bool get hasPublicClasses => publicClasses.isNotEmpty;
+
bool get hasPublicConstants => publicConstants.isNotEmpty;
+
bool get hasPublicEnums => publicEnums.isNotEmpty;
+
bool get hasPublicExceptions => publicExceptions.isNotEmpty;
+
bool get hasPublicFunctions => publicFunctions.isNotEmpty;
+
bool get hasPublicMixins => publicMixins.isNotEmpty;
+
bool get hasPublicProperties => publicProperties.isNotEmpty;
+
bool get hasPublicTypedefs => publicTypedefs.isNotEmpty;
Iterable<Class> get publicClasses => filterNonPublic(classes);
+
Iterable<TopLevelVariable> get publicConstants => filterNonPublic(constants);
+
Iterable<Enum> get publicEnums => filterNonPublic(enums);
+
Iterable<Class> get publicExceptions => filterNonPublic(exceptions);
+
Iterable<ModelFunction> get publicFunctions => filterNonPublic(functions);
+
Iterable<Mixin> get publicMixins => filterNonPublic(mixins);
+
Iterable<TopLevelVariable> get publicProperties =>
filterNonPublic(properties);
+
Iterable<Typedef> get publicTypedefs => filterNonPublic(typedefs);
}
@@ -5631,10 +5770,13 @@
abstract class LibraryContainer
implements Nameable, Comparable<LibraryContainer> {
final List<Library> _libraries = [];
+
List<Library> get libraries => _libraries;
PackageGraph get packageGraph;
+
Iterable<Library> get publicLibraries => filterNonPublic(libraries);
+
bool get hasPublicLibraries => publicLibraries.isNotEmpty;
/// The name of the container or object that this LibraryContainer is a part
@@ -5687,6 +5829,7 @@
String get documentation => documentationFile?.contents;
Documentation __documentation;
+
Documentation get _documentation {
if (__documentation != null) return __documentation;
__documentation = new Documentation.forElement(this);
@@ -5713,7 +5856,7 @@
FileContents get documentationFile;
@override
- String get location => pathLib.toUri(documentationFile.file.path).toString();
+ String get location => path.toUri(documentationFile.file.path).toString();
@override
Set<String> get locationPieces => new Set.from(<String>[location]);
@@ -5811,6 +5954,7 @@
DocumentLocation get documentedWhere => package.documentedWhere;
bool _isDocumented;
+
@override
bool get isDocumented {
if (_isDocumented == null) {
@@ -5856,10 +6000,10 @@
bool get isCanonical => categoryDefinition != null;
@override
- // TODO(jcollins-g): Category? Topic? Group? Stuff? Find a better name.
String get kind => 'Topic';
FileContents _documentationFile;
+
@override
FileContents get documentationFile {
if (_documentationFile == null) {
@@ -5927,8 +6071,10 @@
}
Package._(this._name, this._packageGraph, this._packageMeta);
+
@override
bool get isCanonical => true;
+
@override
Library get canonicalLibrary => null;
@@ -5944,7 +6090,9 @@
bool get hasHomepage =>
packageMeta.homepage != null && packageMeta.homepage.isNotEmpty;
+
String get homepage => packageMeta.homepage;
+
String get kind => (isSdk) ? 'SDK' : 'package';
@override
@@ -5963,6 +6111,7 @@
LibraryContainer get defaultCategory => nameToCategory[null];
String _documentationAsHtml;
+
@override
String get documentationAsHtml {
if (_documentationAsHtml != null) return _documentationAsHtml;
@@ -6000,6 +6149,7 @@
Warnable get enclosingElement => null;
bool _isPublic;
+
@override
bool get isPublic {
if (_isPublic == null) _isPublic = libraries.any((l) => l.isPublic);
@@ -6046,6 +6196,7 @@
String get fullyQualifiedName => 'package:$name';
String _baseHref;
+
String get baseHref {
if (_baseHref == null) {
if (documentedWhere == DocumentLocation.remote) {
@@ -6085,7 +6236,7 @@
String get href => '${baseHref}index.html';
@override
- String get location => pathLib.toUri(packageMeta.resolvedDir).toString();
+ String get location => path.toUri(packageMeta.resolvedDir).toString();
@override
String get name => _name;
@@ -6127,6 +6278,7 @@
}
List<Category> _categories;
+
List<Category> get categories {
if (_categories == null) {
_categories = nameToCategory.values.where((c) => c.name != null).toList()
@@ -6140,9 +6292,11 @@
Iterable<Category> get documentedCategories =>
categories.where((c) => c.isDocumented);
+
bool get hasDocumentedCategories => documentedCategories.isNotEmpty;
DartdocOptionContext _config;
+
@override
DartdocOptionContext get config {
if (_config == null) {
@@ -6162,9 +6316,10 @@
bool get isSdk => packageMeta.isSdk;
String _packagePath;
+
String get packagePath {
if (_packagePath == null) {
- _packagePath = pathLib.canonicalize(packageMeta.dir.path);
+ _packagePath = path.canonicalize(packageMeta.dir.path);
}
return _packagePath;
}
@@ -6183,6 +6338,7 @@
}
final PackageMeta _packageMeta;
+
PackageMeta get packageMeta => _packageMeta;
@override
@@ -6197,6 +6353,7 @@
ParameterElement element, Library library, PackageGraph packageGraph,
{Member originalMember})
: super(element, library, packageGraph, originalMember);
+
String get defaultValue {
if (!hasDefaultValue) return null;
return _parameter.defaultValueCode;
@@ -6259,6 +6416,7 @@
Library get library;
String _sourceCode;
+
String get sourceCode =>
_sourceCode ??= modelNode == null ? '' : modelNode.sourceCode;
}
@@ -6326,8 +6484,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalLibrary == library);
return '${package.baseHref}${library.dirName}/$fileName';
@@ -6393,8 +6552,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalLibrary == library);
return '${package.baseHref}${library.dirName}/$fileName';
@@ -6431,8 +6591,9 @@
@override
String get href {
- if (!identical(canonicalModelElement, this))
+ if (!identical(canonicalModelElement, this)) {
return canonicalModelElement?.href;
+ }
assert(canonicalLibrary != null);
assert(canonicalLibrary == library);
return '${package.baseHref}${enclosingElement.library.dirName}/${enclosingElement.name}/$name';
@@ -6442,6 +6603,7 @@
String get kind => 'type parameter';
ElementType _boundType;
+
ElementType get boundType {
if (_boundType == null) {
var bound = _typeParameter.bound;
@@ -6453,6 +6615,7 @@
}
String _name;
+
@override
String get name {
if (_name == null) {
@@ -6495,6 +6658,7 @@
}
DartSdk _sdk;
+
DartSdk get sdk {
if (_sdk == null) {
_sdk = new FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
@@ -6504,6 +6668,7 @@
}
EmbedderSdk _embedderSdk;
+
EmbedderSdk get embedderSdk {
if (_embedderSdk == null && !config.topLevelPackageMeta.isSdk) {
_embedderSdk = new EmbedderSdk(PhysicalResourceProvider.INSTANCE,
@@ -6512,17 +6677,17 @@
return _embedderSdk;
}
- static Map<String, List<fileSystem.Folder>> _calculatePackageMap(
- fileSystem.Folder dir) {
- Map<String, List<fileSystem.Folder>> map = new Map();
+ static Map<String, List<file_system.Folder>> _calculatePackageMap(
+ file_system.Folder dir) {
+ Map<String, List<file_system.Folder>> map = new Map();
var info = package_config.findPackagesFromFile(dir.toUri());
for (String name in info.packages) {
Uri uri = info.asMap()[name];
- String path = pathLib.normalize(pathLib.fromUri(uri));
- fileSystem.Resource resource =
- PhysicalResourceProvider.INSTANCE.getResource(path);
- if (resource is fileSystem.Folder) {
+ String packagePath = path.normalize(path.fromUri(uri));
+ file_system.Resource resource =
+ PhysicalResourceProvider.INSTANCE.getResource(packagePath);
+ if (resource is file_system.Folder) {
map[name] = [resource];
}
}
@@ -6530,10 +6695,11 @@
return map;
}
- Map<String, List<fileSystem.Folder>> _packageMap;
- Map<String, List<fileSystem.Folder>> get packageMap {
+ Map<String, List<file_system.Folder>> _packageMap;
+
+ Map<String, List<file_system.Folder>> get packageMap {
if (_packageMap == null) {
- fileSystem.Folder cwd =
+ file_system.Folder cwd =
PhysicalResourceProvider.INSTANCE.getResource(config.inputDir);
_packageMap = _calculatePackageMap(cwd);
}
@@ -6541,6 +6707,7 @@
}
DartUriResolver _embedderResolver;
+
DartUriResolver get embedderResolver {
if (_embedderResolver == null) {
_embedderResolver = new DartUriResolver(embedderSdk);
@@ -6571,7 +6738,7 @@
resolvers.add(new PackageWithoutSdkResolver(packageResolver, sdkResolver));
resolvers.add(sdkResolver);
resolvers.add(
- new fileSystem.ResourceUriResolver(PhysicalResourceProvider.INSTANCE));
+ new file_system.ResourceUriResolver(PhysicalResourceProvider.INSTANCE));
assert(
resolvers.any((UriResolver resolver) => resolver is DartUriResolver));
@@ -6580,6 +6747,7 @@
}
AnalysisDriver _driver;
+
AnalysisDriver get driver {
if (_driver == null) {
PerformanceLog log = new PerformanceLog(null);
@@ -6717,25 +6885,25 @@
Iterable<String> findFilesToDocumentInPackage(
String basePackageDir, bool autoIncludeDependencies,
[bool filterExcludes = true]) sync* {
- final String sep = pathLib.separator;
+ final String sep = path.separator;
Set<String> packageDirs = new Set()..add(basePackageDir);
if (autoIncludeDependencies) {
Map<String, Uri> info = package_config
.findPackagesFromFile(
- new Uri.file(pathLib.join(basePackageDir, 'pubspec.yaml')))
+ new Uri.file(path.join(basePackageDir, 'pubspec.yaml')))
.asMap();
for (String packageName in info.keys) {
if (!filterExcludes || !config.exclude.contains(packageName)) {
- packageDirs.add(pathLib.dirname(info[packageName].toFilePath()));
+ packageDirs.add(path.dirname(info[packageName].toFilePath()));
}
}
}
for (String packageDir in packageDirs) {
- var packageLibDir = pathLib.join(packageDir, 'lib');
- var packageLibSrcDir = pathLib.join(packageLibDir, 'src');
+ var packageLibDir = path.join(packageDir, 'lib');
+ var packageLibSrcDir = path.join(packageLibDir, 'src');
// To avoid analyzing package files twice, only files with paths not
// containing '/packages' will be added. The only exception is if the file
// to analyze already has a '/package' in its path.
@@ -6745,8 +6913,8 @@
(!lib.contains('${sep}packages${sep}') ||
packageDir.contains('${sep}packages${sep}'))) {
// Only include libraries within the lib dir that are not in lib/src
- if (pathLib.isWithin(packageLibDir, lib) &&
- !pathLib.isWithin(packageLibSrcDir, lib)) {
+ if (path.isWithin(packageLibDir, lib) &&
+ !path.isWithin(packageLibSrcDir, lib)) {
// Only add the file if it does not contain 'part of'
var contents = new File(lib).readAsStringSync();
@@ -6784,7 +6952,7 @@
files = findFilesToDocumentInPackage(
config.inputDir, config.autoIncludeDependencies);
}
- files = quiverIterables.concat([files, _includeExternalsFrom(files)]);
+ files = quiver.concat([files, _includeExternalsFrom(files)]);
return new Set.from(files.map((s) => new File(s).absolute.path));
}
@@ -6846,11 +7014,11 @@
var entities = dir.listSync();
var pubspec = entities.firstWhere(
- (e) => e is File && pathLib.basename(e.path) == 'pubspec.yaml',
+ (e) => e is File && path.basename(e.path) == 'pubspec.yaml',
orElse: () => null);
var libDir = entities.firstWhere(
- (e) => e is Directory && pathLib.basename(e.path) == 'lib',
+ (e) => e is Directory && path.basename(e.path) == 'lib',
orElse: () => null);
if (pubspec != null && libDir != null) {
diff --git a/lib/src/package_meta.dart b/lib/src/package_meta.dart
index ffdfe40..ac2dc7d 100644
--- a/lib/src/package_meta.dart
+++ b/lib/src/package_meta.dart
@@ -9,7 +9,7 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:dartdoc/dartdoc.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
import 'logging.dart';
@@ -19,7 +19,7 @@
Directory get defaultSdkDir {
Directory sdkDir = new File(Platform.resolvedExecutable).parent.parent;
- assert(pathLib.equals(sdkDir.path, PackageMeta.sdkDirParent(sdkDir).path));
+ assert(path.equals(sdkDir.path, PackageMeta.sdkDirParent(sdkDir).path));
return sdkDir;
}
@@ -41,15 +41,16 @@
PackageMeta(this.dir);
static List<List<String>> __sdkDirFilePaths;
+
static List<List<String>> get _sdkDirFilePaths {
if (__sdkDirFilePaths == null) {
__sdkDirFilePaths = [];
if (Platform.isWindows) {
for (List<String> paths in __sdkDirFilePathsPosix) {
List<String> windowsPaths = [];
- for (String path in paths) {
- windowsPaths.add(pathLib.joinAll(
- new pathLib.Context(style: pathLib.Style.posix).split(path)));
+ for (String p in paths) {
+ windowsPaths.add(path
+ .joinAll(new path.Context(style: path.Style.posix).split(p)));
}
__sdkDirFilePaths.add(windowsPaths);
}
@@ -63,18 +64,19 @@
/// Returns the directory of the SDK if the given directory is inside a Dart
/// SDK. Returns null if the directory isn't a subdirectory of the SDK.
static final Map<String, Directory> _sdkDirParent = {};
+
static Directory sdkDirParent(Directory dir) {
- String dirPathCanonical = pathLib.canonicalize(dir.path);
+ String dirPathCanonical = path.canonicalize(dir.path);
if (!_sdkDirParent.containsKey(dirPathCanonical)) {
_sdkDirParent[dirPathCanonical] = null;
while (dir.existsSync()) {
if (_sdkDirFilePaths.every((List<String> l) {
- return l.any((f) => new File(pathLib.join(dir.path, f)).existsSync());
+ return l.any((f) => new File(path.join(dir.path, f)).existsSync());
})) {
_sdkDirParent[dirPathCanonical] = dir;
break;
}
- if (pathLib.equals(dir.path, dir.parent.path)) break;
+ if (path.equals(dir.path, dir.parent.path)) break;
dir = dir.parent;
}
}
@@ -84,11 +86,11 @@
@override
bool operator ==(other) {
if (other is! PackageMeta) return false;
- return pathLib.equals(dir.absolute.path, other.dir.absolute.path);
+ return path.equals(dir.absolute.path, other.dir.absolute.path);
}
@override
- int get hashCode => pathLib.hash(dir.absolute.path);
+ int get hashCode => path.hash(dir.absolute.path);
/// Use this instead of fromDir where possible.
factory PackageMeta.fromElement(
@@ -96,10 +98,11 @@
// [config] is only here for sdkDir, and it's OK that it is the wrong
// context since sdkDir is argOnly and this is supposed to be a temporary
// workaround.
- if (libraryElement.isInSdk)
+ if (libraryElement.isInSdk) {
return new PackageMeta.fromDir(new Directory(config.sdkDir));
+ }
return new PackageMeta.fromDir(
- new File(pathLib.canonicalize(libraryElement.source.fullName)).parent);
+ new File(path.canonicalize(libraryElement.source.fullName)).parent);
}
factory PackageMeta.fromFilename(String filename) {
@@ -126,14 +129,14 @@
packageMeta = new _SdkMeta(parentSdkDir);
} else {
while (dir.existsSync()) {
- File pubspec = new File(pathLib.join(dir.path, 'pubspec.yaml'));
+ File pubspec = new File(path.join(dir.path, 'pubspec.yaml'));
if (pubspec.existsSync()) {
packageMeta = new _FilePackageMeta(dir);
break;
}
// Allow a package to be at root (possible in a Windows setting with
// drive letter mappings).
- if (pathLib.equals(dir.path, dir.parent.path)) break;
+ if (path.equals(dir.path, dir.parent.path)) break;
dir = dir.parent.absolute;
}
}
@@ -151,15 +154,15 @@
/// "both"), or null if this package is not part of a SDK.
String sdkType(String flutterRootPath) {
if (flutterRootPath != null) {
- String flutterPackages = pathLib.join(flutterRootPath, 'packages');
- String flutterBinCache = pathLib.join(flutterRootPath, 'bin', 'cache');
+ String flutterPackages = path.join(flutterRootPath, 'packages');
+ String flutterBinCache = path.join(flutterRootPath, 'bin', 'cache');
/// Don't include examples or other non-SDK components as being the
/// "Flutter SDK".
- if (pathLib.isWithin(
- flutterPackages, pathLib.canonicalize(dir.absolute.path)) ||
- pathLib.isWithin(
- flutterBinCache, pathLib.canonicalize(dir.absolute.path))) {
+ if (path.isWithin(
+ flutterPackages, path.canonicalize(dir.absolute.path)) ||
+ path.isWithin(
+ flutterBinCache, path.canonicalize(dir.absolute.path))) {
return 'Flutter';
}
}
@@ -177,11 +180,15 @@
/// null if not a hosted pub package. If set, the hostname
/// that the package is hosted at -- usually 'pub.dartlang.org'.
String get hostedAt;
+
String get version;
+
String get description;
+
String get homepage;
String _resolvedDir;
+
String get resolvedDir {
if (_resolvedDir == null) {
_resolvedDir = dir.resolveSymbolicLinksSync();
@@ -190,7 +197,9 @@
}
FileContents getReadmeContents();
+
FileContents getLicenseContents();
+
FileContents getChangelogContents();
/// Returns true if we are a valid package, valid enough to generate docs.
@@ -229,7 +238,7 @@
Map _pubspec;
_FilePackageMeta(Directory dir) : super(dir) {
- File f = new File(pathLib.join(dir.path, 'pubspec.yaml'));
+ File f = new File(path.join(dir.path, 'pubspec.yaml'));
if (f.existsSync()) {
_pubspec = loadYaml(f.readAsStringSync());
} else {
@@ -239,6 +248,7 @@
bool _setHostedAt = false;
String _hostedAt;
+
@override
String get hostedAt {
if (!_setHostedAt) {
@@ -252,13 +262,13 @@
// possibly by calculating hosting directly from pubspec.yaml or importing
// a pub library to do this.
// People could have a pub cache at root with Windows drive mappings.
- if (pathLib.split(pathLib.canonicalize(dir.path)).length >= 3) {
+ if (path.split(path.canonicalize(dir.path)).length >= 3) {
String pubCacheRoot = dir.parent.parent.parent.path;
- String hosted = pathLib.canonicalize(dir.parent.parent.path);
- String hostname = pathLib.canonicalize(dir.parent.path);
- if (pathLib.basename(hosted) == 'hosted' &&
- new Directory(pathLib.join(pubCacheRoot, '_temp')).existsSync()) {
- _hostedAt = pathLib.basename(hostname);
+ String hosted = path.canonicalize(dir.parent.parent.path);
+ String hostname = path.canonicalize(dir.parent.path);
+ if (path.basename(hosted) == 'hosted' &&
+ new Directory(path.join(pubCacheRoot, '_temp')).existsSync()) {
+ _hostedAt = path.basename(hostname);
}
}
}
@@ -270,12 +280,12 @@
@override
bool get needsPubGet =>
- !(new File(pathLib.join(dir.path, '.packages')).existsSync());
+ !(new File(path.join(dir.path, '.packages')).existsSync());
@override
void runPubGet() {
String pubPath =
- pathLib.join(pathLib.dirname(Platform.resolvedExecutable), 'pub');
+ path.join(path.dirname(Platform.resolvedExecutable), 'pub');
if (Platform.isWindows) pubPath += '.bat';
ProcessResult result =
@@ -296,10 +306,13 @@
@override
String get name => _pubspec['name'];
+
@override
String get version => _pubspec['version'];
+
@override
String get description => _pubspec['description'];
+
@override
String get homepage => _pubspec['homepage'];
@@ -351,7 +364,7 @@
for (String name in fileNames) {
for (File f in files) {
- String baseName = pathLib.basename(f.path).toLowerCase();
+ String baseName = path.basename(f.path).toLowerCase();
if (baseName == name) return f;
if (baseName.startsWith(name)) return f;
}
@@ -364,7 +377,7 @@
String sdkReadmePath;
_SdkMeta(Directory dir) : super(dir) {
- sdkReadmePath = pathLib.join(dir.path, 'lib', 'api_readme.md');
+ sdkReadmePath = path.join(dir.path, 'lib', 'api_readme.md');
}
@override
@@ -380,9 +393,10 @@
@override
String get name => 'Dart';
+
@override
String get version {
- File versionFile = new File(pathLib.join(dir.path, 'version'));
+ File versionFile = new File(path.join(dir.path, 'version'));
if (versionFile.existsSync()) return versionFile.readAsStringSync().trim();
return 'unknown';
}
@@ -391,6 +405,7 @@
String get description =>
'The Dart SDK is a set of tools and libraries for the '
'Dart programming language.';
+
@override
String get homepage => 'https://github.com/dart-lang/sdk';
@@ -399,9 +414,9 @@
@override
FileContents getReadmeContents() {
- File f = new File(pathLib.join(dir.path, 'lib', 'api_readme.md'));
+ File f = new File(path.join(dir.path, 'lib', 'api_readme.md'));
if (!f.existsSync()) {
- f = new File(pathLib.join(dir.path, 'api_readme.md'));
+ f = new File(path.join(dir.path, 'api_readme.md'));
}
return f.existsSync() ? new FileContents(f) : null;
}
diff --git a/lib/src/source_linker.dart b/lib/src/source_linker.dart
index 2f51479..cfa64ad 100644
--- a/lib/src/source_linker.dart
+++ b/lib/src/source_linker.dart
@@ -7,17 +7,20 @@
import 'package:dartdoc/src/dartdoc_options.dart';
import 'package:dartdoc/src/model.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
final uriTemplateRegexp = new RegExp(r'(%[frl]%)');
abstract class SourceLinkerOptionContext implements DartdocOptionContextBase {
List<String> get linkToSourceExcludes =>
optionSet['linkToSource']['excludes'].valueAt(context);
+
String get linkToSourceRevision =>
optionSet['linkToSource']['revision'].valueAt(context);
+
String get linkToSourceRoot =>
optionSet['linkToSource']['root'].valueAt(context);
+
String get linkToSourceUriTemplate =>
optionSet['linkToSource']['uriTemplate'].valueAt(context);
}
@@ -94,18 +97,20 @@
}
String href() {
- if (sourceFileName == null || root == null || uriTemplate == null)
+ if (sourceFileName == null || root == null || uriTemplate == null) {
return '';
- if (!pathLib.isWithin(root, sourceFileName) ||
+ }
+ if (!path.isWithin(root, sourceFileName) ||
excludes
- .any((String exclude) => pathLib.isWithin(exclude, sourceFileName)))
+ .any((String exclude) => path.isWithin(exclude, sourceFileName))) {
return '';
+ }
return uriTemplate.replaceAllMapped(uriTemplateRegexp, (match) {
switch (match[1]) {
case '%f%':
- var urlContext = new pathLib.Context(style: pathLib.Style.url);
- return urlContext.joinAll(
- pathLib.split(pathLib.relative(sourceFileName, from: root)));
+ var urlContext = new path.Context(style: path.Style.url);
+ return urlContext
+ .joinAll(path.split(path.relative(sourceFileName, from: root)));
break;
case '%r%':
return revision;
diff --git a/lib/src/tool_runner.dart b/lib/src/tool_runner.dart
index cc8d859..400e8ec 100644
--- a/lib/src/tool_runner.dart
+++ b/lib/src/tool_runner.dart
@@ -8,7 +8,7 @@
import 'dart:io';
import 'package:dartdoc/src/io_utils.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'dartdoc_options.dart';
typedef ToolErrorCallback = void Function(String message);
@@ -30,13 +30,15 @@
Directory.systemTemp.createTempSync('dartdoc_tools_');
static ToolTempFileTracker _instance;
+
static ToolTempFileTracker get instance =>
_instance ??= ToolTempFileTracker._();
int _temporaryFileCount = 0;
+
Future<File> createTemporaryFile() async {
_temporaryFileCount++;
- File tempFile = new File(pathLib.join(
+ File tempFile = new File(path.join(
temporaryDirectory.absolute.path, 'input_$_temporaryFileCount'));
await tempFile.create(recursive: true);
return tempFile;
@@ -188,8 +190,9 @@
argsWithInput.add(newArg);
}
- if (toolDefinition.setupCommand != null && !toolDefinition.setupComplete)
+ if (toolDefinition.setupCommand != null && !toolDefinition.setupComplete) {
await _runSetup(tool, toolDefinition, envWithInput, toolErrorCallback);
+ }
argsWithInput = toolArgs + argsWithInput;
var commandPath;
diff --git a/lib/src/warnings.dart b/lib/src/warnings.dart
index 1ac42e8..f67ab81 100644
--- a/lib/src/warnings.dart
+++ b/lib/src/warnings.dart
@@ -14,10 +14,12 @@
abstract class PackageWarningOptionContext implements DartdocOptionContextBase {
bool get allowNonLocalWarnings =>
optionSet['allowNonLocalWarnings'].valueAt(context);
+
// allowWarningsInPackages, ignoreWarningsInPackages, errors, warnings, and ignore
// are only used indirectly via the synthetic packageWarningOptions option.
PackageWarningOptions get packageWarningOptions =>
optionSet['packageWarningOptions'].valueAt(context);
+
bool get verboseWarnings => optionSet['verboseWarnings'].valueAt(context);
}
@@ -201,15 +203,20 @@
abstract class Warnable implements Canonicalization {
void warn(PackageWarning warning,
{String message, Iterable<Locatable> referredFrom});
+
Element get element;
+
Warnable get enclosingElement;
+
Package get package;
}
/// Something that can be located for warning purposes.
abstract class Locatable {
List<Locatable> get documentationFrom;
+
String get fullyQualifiedName;
+
String get href;
/// A string indicating the URI of this Locatable, usually derived from
@@ -339,8 +346,10 @@
void ignore(PackageWarning kind) =>
warningModes[kind] = PackageWarningMode.ignore;
+
void warn(PackageWarning kind) =>
warningModes[kind] = PackageWarningMode.warn;
+
void error(PackageWarning kind) =>
warningModes[kind] = PackageWarningMode.error;
@@ -415,9 +424,11 @@
!element.package.isLocal) {
warningMode = PackageWarningMode.ignore;
}
- if (warningMode == PackageWarningMode.warn)
+ if (warningMode == PackageWarningMode.warn) {
warningCount += 1;
- else if (warningMode == PackageWarningMode.error) errorCount += 1;
+ } else if (warningMode == PackageWarningMode.error) {
+ errorCount += 1;
+ }
Tuple2<PackageWarning, String> warningData = new Tuple2(kind, message);
countedWarnings.putIfAbsent(element?.element, () => new Set());
countedWarnings[element?.element].add(warningData);
diff --git a/test/dartdoc_integration_test.dart b/test/dartdoc_integration_test.dart
index e34ba1e..7129683 100644
--- a/test/dartdoc_integration_test.dart
+++ b/test/dartdoc_integration_test.dart
@@ -9,7 +9,7 @@
import 'dart:mirrors';
import 'package:dartdoc/dartdoc.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/utils.dart';
@@ -17,14 +17,13 @@
Uri get _currentFileUri =>
(reflect(main) as ClosureMirror).function.location.sourceUri;
String get _testPackagePath =>
- pathLib.fromUri(_currentFileUri.resolve('../testing/test_package'));
-String get _testPackageFlutterPluginPath => pathLib
+ path.fromUri(_currentFileUri.resolve('../testing/test_package'));
+String get _testPackageFlutterPluginPath => path
.fromUri(_currentFileUri.resolve('../testing/test_package_flutter_plugin'));
void main() {
group('Invoking command-line dartdoc', () {
- String dartdocPath =
- pathLib.canonicalize(pathLib.join('bin', 'dartdoc.dart'));
+ String dartdocPath = path.canonicalize(path.join('bin', 'dartdoc.dart'));
CoverageSubprocessLauncher subprocessLauncher;
Directory tempDir;
@@ -92,7 +91,7 @@
test('missing a required file path prints a fatal-error', () async {
List outputLines = [];
- String impossiblePath = pathLib.join(dartdocPath, 'impossible');
+ String impossiblePath = path.join(dartdocPath, 'impossible');
await expectLater(
() => subprocessLauncher.runStreamed(
Platform.resolvedExecutable,
@@ -114,7 +113,7 @@
() => subprocessLauncher.runStreamed(Platform.resolvedExecutable, [
dartdocPath,
'--input=${testPackageToolError.path}',
- '--output=${pathLib.join(tempDir.absolute.path, 'test_package_tool_error')}'
+ '--output=${path.join(tempDir.absolute.path, 'test_package_tool_error')}'
]),
throwsA(const TypeMatcher<ProcessException>()));
});
@@ -213,7 +212,7 @@
test('--footer-text includes text', () async {
String footerTextPath =
- pathLib.join(Directory.systemTemp.path, 'footer.txt');
+ path.join(Directory.systemTemp.path, 'footer.txt');
new File(footerTextPath).writeAsStringSync(' footer text include ');
var args = <String>[
@@ -228,7 +227,7 @@
await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args,
workingDirectory: _testPackagePath);
- File outFile = new File(pathLib.join(tempDir.path, 'index.html'));
+ File outFile = new File(path.join(tempDir.path, 'index.html'));
expect(outFile.readAsStringSync(), contains('footer text include'));
});
}, timeout: new Timeout.factor(4));
diff --git a/test/dartdoc_options_test.dart b/test/dartdoc_options_test.dart
index 6076df0..ef73ab1 100644
--- a/test/dartdoc_options_test.dart
+++ b/test/dartdoc_options_test.dart
@@ -7,7 +7,7 @@
import 'dart:io';
import 'package:dartdoc/src/dartdoc_options.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:yaml/yaml.dart';
@@ -18,7 +18,7 @@
ConvertedOption._(this.param1, this.param2, this.myContextPath);
- static ConvertedOption fromYamlMap(YamlMap yamlMap, pathLib.Context context) {
+ static ConvertedOption fromYamlMap(YamlMap yamlMap, path.Context context) {
String p1;
String p2;
String contextPath = context.current;
@@ -158,25 +158,24 @@
isFile: true, mustExist: true));
tempDir = Directory.systemTemp.createTempSync('options_test');
- firstDir = new Directory(pathLib.join(tempDir.path, 'firstDir'))
+ firstDir = new Directory(path.join(tempDir.path, 'firstDir'))..createSync();
+ firstExisting = new File(path.join(firstDir.path, 'existing.dart'))
..createSync();
- firstExisting = new File(pathLib.join(firstDir.path, 'existing.dart'))
+ secondDir = new Directory(path.join(tempDir.path, 'secondDir'))
..createSync();
- secondDir = new Directory(pathLib.join(tempDir.path, 'secondDir'))
- ..createSync();
- new File(pathLib.join(secondDir.path, 'existing.dart'))..createSync();
+ new File(path.join(secondDir.path, 'existing.dart'))..createSync();
- secondDirFirstSub = new Directory(pathLib.join(secondDir.path, 'firstSub'))
+ secondDirFirstSub = new Directory(path.join(secondDir.path, 'firstSub'))
..createSync();
- secondDirSecondSub =
- new Directory(pathLib.join(secondDir.path, 'secondSub'))..createSync();
+ secondDirSecondSub = new Directory(path.join(secondDir.path, 'secondSub'))
+ ..createSync();
dartdocOptionsOne =
- new File(pathLib.join(firstDir.path, 'dartdoc_options.yaml'));
+ new File(path.join(firstDir.path, 'dartdoc_options.yaml'));
dartdocOptionsTwo =
- new File(pathLib.join(secondDir.path, 'dartdoc_options.yaml'));
+ new File(path.join(secondDir.path, 'dartdoc_options.yaml'));
dartdocOptionsTwoFirstSub =
- new File(pathLib.join(secondDirFirstSub.path, 'dartdoc_options.yaml'));
+ new File(path.join(secondDirFirstSub.path, 'dartdoc_options.yaml'));
dartdocOptionsOne.writeAsStringSync('''
dartdoc:
@@ -233,7 +232,7 @@
dartdocOptionSetSynthetic.parseArguments([]);
expect(
dartdocOptionSetSynthetic['vegetableLoaderChecked'].valueAt(firstDir),
- orderedEquals([pathLib.canonicalize(firstExisting.path)]));
+ orderedEquals([path.canonicalize(firstExisting.path)]));
String errorMessage;
try {
@@ -244,7 +243,7 @@
expect(
errorMessage,
equals(
- 'Synthetic configuration option dartdoc from <internal>, computed as [existing.dart], resolves to missing path: "${pathLib.canonicalize(pathLib.join(tempDir.absolute.path, 'existing.dart'))}"'));
+ 'Synthetic configuration option dartdoc from <internal>, computed as [existing.dart], resolves to missing path: "${path.canonicalize(path.join(tempDir.absolute.path, 'existing.dart'))}"'));
});
test('file can override synthetic in FileSynth', () {
@@ -260,8 +259,8 @@
// Since this is an ArgSynth, it ignores the yaml option and resolves to the CWD
expect(
dartdocOptionSetSynthetic['nonCriticalFileOption'].valueAt(firstDir),
- equals(pathLib.canonicalize(
- pathLib.join(Directory.current.path, 'stuff.zip'))));
+ equals(path
+ .canonicalize(path.join(Directory.current.path, 'stuff.zip'))));
});
test('ArgSynth defaults to synthetic', () {
@@ -269,8 +268,7 @@
// This option is composed of FileOptions which make use of firstDir.
expect(
dartdocOptionSetSynthetic['nonCriticalFileOption'].valueAt(firstDir),
- equals(pathLib
- .canonicalize(pathLib.join(firstDir.path, 'existing.dart'))));
+ equals(path.canonicalize(path.join(firstDir.path, 'existing.dart'))));
});
});
@@ -289,14 +287,14 @@
expect(
errorMessage,
equals(
- 'Argument --file-option, set to override-not-existing.dart, resolves to missing path: "${pathLib.join(pathLib.canonicalize(Directory.current.path), "override-not-existing.dart")}"'));
+ 'Argument --file-option, set to override-not-existing.dart, resolves to missing path: "${path.join(path.canonicalize(Directory.current.path), "override-not-existing.dart")}"'));
});
test('validate argument can override missing file', () {
dartdocOptionSetAll.parseArguments(
- ['--file-option', pathLib.canonicalize(firstExisting.path)]);
+ ['--file-option', path.canonicalize(firstExisting.path)]);
expect(dartdocOptionSetAll['fileOption'].valueAt(secondDir),
- equals(pathLib.canonicalize(firstExisting.path)));
+ equals(path.canonicalize(firstExisting.path)));
});
test('File errors still get passed through', () {
@@ -310,8 +308,8 @@
expect(
errorMessage,
equals(
- 'Field dartdoc.fileOption from ${pathLib.canonicalize(dartdocOptionsTwo.path)}, set to not existing, resolves to missing path: '
- '"${pathLib.join(pathLib.canonicalize(secondDir.path), "not existing")}"'));
+ 'Field dartdoc.fileOption from ${path.canonicalize(dartdocOptionsTwo.path)}, set to not existing, resolves to missing path: '
+ '"${path.join(path.canonicalize(secondDir.path), "not existing")}"'));
});
test('validate override behavior basic', () {
@@ -383,7 +381,7 @@
errorMessage,
equals(
'Argument --single-file, set to not_found.txt, resolves to missing path: '
- '"${pathLib.join(pathLib.canonicalize(Directory.current.path), 'not_found.txt')}"'));
+ '"${path.join(path.canonicalize(Directory.current.path), 'not_found.txt')}"'));
});
test('DartdocOptionArgOnly checks file existence on multi-options', () {
@@ -403,7 +401,7 @@
errorMessage,
equals(
'Argument --files-flag, set to [${firstExisting.absolute.path}, other_not_found.txt], resolves to missing path: '
- '"${pathLib.join(pathLib.canonicalize(Directory.current.path), "other_not_found.txt")}"'));
+ '"${path.join(path.canonicalize(Directory.current.path), "other_not_found.txt")}"'));
});
test(
@@ -413,7 +411,7 @@
.parseArguments(['--unimportant-file', 'this-will-never-exist']);
expect(
dartdocOptionSetArgs['unimportantFile'].valueAt(tempDir),
- equals(pathLib.join(pathLib.canonicalize(Directory.current.path),
+ equals(path.join(path.canonicalize(Directory.current.path),
'this-will-never-exist')));
});
@@ -528,8 +526,7 @@
expect(converted.param1, equals('value1'));
expect(converted.param2, equals('value2'));
- expect(
- converted.myContextPath, equals(pathLib.canonicalize(firstDir.path)));
+ expect(converted.myContextPath, equals(path.canonicalize(firstDir.path)));
expect(
dartdocOptionSetFiles['convertThisMap'].valueAt(secondDir), isNull);
});
@@ -544,9 +541,9 @@
expect(
errorMessage,
equals(
- 'Field dartdoc.fileOptionList from ${pathLib.canonicalize(dartdocOptionsTwo.path)}, set to [existing.dart, thing/that/does/not/exist], resolves to missing path: '
- '"${pathLib.joinAll([
- pathLib.canonicalize(secondDir.path),
+ 'Field dartdoc.fileOptionList from ${path.canonicalize(dartdocOptionsTwo.path)}, set to [existing.dart, thing/that/does/not/exist], resolves to missing path: '
+ '"${path.joinAll([
+ path.canonicalize(secondDir.path),
'thing',
'that',
'does',
@@ -554,10 +551,8 @@
'exist'
])}"'));
// It doesn't matter that this fails.
- expect(
- dartdocOptionSetFiles['nonCriticalFileOption'].valueAt(firstDir),
- equals(pathLib
- .joinAll([pathLib.canonicalize(firstDir.path), 'whatever'])));
+ expect(dartdocOptionSetFiles['nonCriticalFileOption'].valueAt(firstDir),
+ equals(path.joinAll([path.canonicalize(firstDir.path), 'whatever'])));
});
test(
@@ -572,9 +567,9 @@
expect(
errorMessage,
equals(
- 'Field dartdoc.fileOption from ${pathLib.canonicalize(dartdocOptionsTwo.path)}, set to not existing, resolves to missing path: '
- '"${pathLib.joinAll([
- pathLib.canonicalize(secondDir.path),
+ 'Field dartdoc.fileOption from ${path.canonicalize(dartdocOptionsTwo.path)}, set to not existing, resolves to missing path: '
+ '"${path.joinAll([
+ path.canonicalize(secondDir.path),
"not existing"
])}"'));
});
@@ -583,15 +578,13 @@
expect(
dartdocOptionSetFiles['nonCriticalDirOption']
.valueAt(secondDirFirstSub),
- equals(pathLib.join(
- pathLib.canonicalize(secondDirFirstSub.path), 'not_existing')));
+ equals(path.join(
+ path.canonicalize(secondDirFirstSub.path), 'not_existing')));
});
test('DartdocOptionSetFile checks errors for directory options', () {
- expect(
- dartdocOptionSetFiles['dirOption'].valueAt(secondDir),
- equals(
- pathLib.canonicalize(pathLib.join(secondDir.path, 'firstSub'))));
+ expect(dartdocOptionSetFiles['dirOption'].valueAt(secondDir),
+ equals(path.canonicalize(path.join(secondDir.path, 'firstSub'))));
String errorMessage;
try {
dartdocOptionSetFiles['dirOption'].valueAt(firstDir);
@@ -601,8 +594,8 @@
expect(
errorMessage,
equals(
- 'Field dartdoc.dirOption from ${pathLib.canonicalize(dartdocOptionsOne.path)}, set to notHere, resolves to missing path: '
- '"${pathLib.canonicalize(pathLib.join(firstDir.path, "notHere"))}"'));
+ 'Field dartdoc.dirOption from ${path.canonicalize(dartdocOptionsOne.path)}, set to notHere, resolves to missing path: '
+ '"${path.canonicalize(path.join(firstDir.path, "notHere"))}"'));
});
test('DartdocOptionSetFile loads defaults', () {
diff --git a/test/dartdoc_test.dart b/test/dartdoc_test.dart
index 664d7df..e7bcfe9 100644
--- a/test/dartdoc_test.dart
+++ b/test/dartdoc_test.dart
@@ -12,7 +12,7 @@
import 'package:dartdoc/src/model.dart';
import 'package:dartdoc/src/tuple.dart';
import 'package:dartdoc/src/warnings.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/utils.dart';
@@ -70,8 +70,8 @@
test('generator parameters', () async {
File favicon = new File(
- pathLib.joinAll([tempDir.path, 'static-assets', 'favicon.png']));
- File index = new File(pathLib.joinAll([tempDir.path, 'index.html']));
+ path.joinAll([tempDir.path, 'static-assets', 'favicon.png']));
+ File index = new File(path.joinAll([tempDir.path, 'index.html']));
expect(favicon.readAsStringSync(),
contains('Not really a png, but a test file'));
String indexString = index.readAsStringSync();
@@ -250,7 +250,7 @@
tempDir.deleteSync(recursive: true);
});
- test('generate docs for ${pathLib.basename(testPackageDir.path)} works',
+ test('generate docs for ${path.basename(testPackageDir.path)} works',
() async {
expect(results.packageGraph, isNotNull);
PackageGraph packageGraph = results.packageGraph;
@@ -265,7 +265,7 @@
test('source code links are visible', () async {
// Picked this object as this library explicitly should never contain
// a library directive, so we can predict what line number it will be.
- File anonymousOutput = new File(pathLib.join(tempDir.path,
+ File anonymousOutput = new File(path.join(tempDir.path,
'anonymous_library', 'anonymous_library-library.html'));
expect(anonymousOutput.existsSync(), isTrue);
expect(
@@ -275,7 +275,7 @@
});
});
- test('generate docs for ${pathLib.basename(testPackageBadDir.path)} fails',
+ test('generate docs for ${path.basename(testPackageBadDir.path)} fails',
() async {
Dartdoc dartdoc = await buildDartdoc([], testPackageBadDir, tempDir);
diff --git a/test/experiment_options_test.dart b/test/experiment_options_test.dart
index d091f04..5231bb3 100644
--- a/test/experiment_options_test.dart
+++ b/test/experiment_options_test.dart
@@ -54,11 +54,13 @@
experimentOptions.parseArguments([]);
DartdocOptionContext tester =
new DartdocOptionContext(experimentOptions, emptyTempDir);
- if (defaultOnNotExpired != null)
+ if (defaultOnNotExpired != null) {
expect(tester.experimentStatus.isEnabled(defaultOnNotExpired), isTrue);
- if (defaultOffNotExpired != null)
+ }
+ if (defaultOffNotExpired != null) {
expect(
tester.experimentStatus.isEnabled(defaultOffNotExpired), isFalse);
+ }
expect(tester.experimentStatus.isEnabled(defaultOnExpired), isTrue);
expect(tester.experimentStatus.isEnabled(defaultOffExpired), isFalse);
});
@@ -71,11 +73,13 @@
]);
DartdocOptionContext tester =
new DartdocOptionContext(experimentOptions, emptyTempDir);
- if (defaultOnNotExpired != null)
+ if (defaultOnNotExpired != null) {
expect(tester.experimentStatus.isEnabled(defaultOnNotExpired), isFalse);
- if (defaultOffNotExpired != null)
+ }
+ if (defaultOffNotExpired != null) {
expect(
tester.experimentStatus.isEnabled(defaultOffNotExpired), isFalse);
+ }
expect(tester.experimentStatus.isEnabled(defaultOnExpired), isTrue);
expect(tester.experimentStatus.isEnabled(defaultOffExpired), isFalse);
});
diff --git a/test/html_generator_test.dart b/test/html_generator_test.dart
index 1f5d779..2fe8cc2 100644
--- a/test/html_generator_test.dart
+++ b/test/html_generator_test.dart
@@ -9,7 +9,7 @@
import 'package:dartdoc/src/html/html_generator.dart';
import 'package:dartdoc/src/html/templates.dart';
import 'package:dartdoc/src/html/resources.g.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
@@ -81,12 +81,12 @@
test('resources are put into the right place', () {
Directory output =
- new Directory(pathLib.join(tempOutput.path, 'static-assets'));
+ new Directory(path.join(tempOutput.path, 'static-assets'));
expect(output, doesExist);
for (var resource in resource_names.map((r) =>
- pathLib.relative(Uri.parse(r).path, from: 'dartdoc/resources'))) {
- expect(new File(pathLib.join(output.path, resource)), doesExist);
+ path.relative(Uri.parse(r).path, from: 'dartdoc/resources'))) {
+ expect(new File(path.join(output.path, resource)), doesExist);
}
});
});
diff --git a/test/model_test.dart b/test/model_test.dart
index 450ffa8..0710a86 100644
--- a/test/model_test.dart
+++ b/test/model_test.dart
@@ -22,6 +22,7 @@
String enclosingName;
@override
final String name;
+
@override
bool get isSdk => false;
@override
@@ -88,12 +89,18 @@
// when the feature is enabled by default.
group('Experiments', () {
Library main;
- TopLevelVariable aComplexSet, inferredTypeSet, specifiedSet, untypedMap, typedSet;
+ TopLevelVariable aComplexSet,
+ inferredTypeSet,
+ specifiedSet,
+ untypedMap,
+ typedSet;
setUpAll(() {
- main = packageGraphExperiments.libraries.firstWhere((lib) => lib.name == 'main');
+ main = packageGraphExperiments.libraries
+ .firstWhere((lib) => lib.name == 'main');
aComplexSet = main.constants.firstWhere((v) => v.name == 'aComplexSet');
- inferredTypeSet = main.constants.firstWhere((v) => v.name == 'inferredTypeSet');
+ inferredTypeSet =
+ main.constants.firstWhere((v) => v.name == 'inferredTypeSet');
specifiedSet = main.constants.firstWhere((v) => v.name == 'specifiedSet');
untypedMap = main.constants.firstWhere((v) => v.name == 'untypedMap');
typedSet = main.constants.firstWhere((v) => v.name == 'typedSet');
@@ -101,20 +108,28 @@
test('Set literals test', () {
expect(aComplexSet.modelType.name, equals('Set'));
- expect(aComplexSet.modelType.typeArguments.map((a) => a.name).toList(), equals(['AClassContainingLiterals']));
- expect(aComplexSet.constantValue, equals('const {const AClassContainingLiterals(3, 5)}'));
+ expect(aComplexSet.modelType.typeArguments.map((a) => a.name).toList(),
+ equals(['AClassContainingLiterals']));
+ expect(aComplexSet.constantValue,
+ equals('const {const AClassContainingLiterals(3, 5)}'));
expect(inferredTypeSet.modelType.name, equals('Set'));
- expect(inferredTypeSet.modelType.typeArguments.map((a) => a.name).toList(), equals(['num']));
+ expect(
+ inferredTypeSet.modelType.typeArguments.map((a) => a.name).toList(),
+ equals(['num']));
expect(inferredTypeSet.constantValue, equals('const {1, 2.5, 3}'));
expect(specifiedSet.modelType.name, equals('Set'));
- expect(specifiedSet.modelType.typeArguments.map((a) => a.name).toList(), equals(['int']));
+ expect(specifiedSet.modelType.typeArguments.map((a) => a.name).toList(),
+ equals(['int']));
expect(specifiedSet.constantValue, equals('const {}'));
expect(untypedMap.modelType.name, equals('Map'));
- expect(untypedMap.modelType.typeArguments.map((a) => a.name).toList(), equals(['dynamic', 'dynamic']));
+ expect(untypedMap.modelType.typeArguments.map((a) => a.name).toList(),
+ equals(['dynamic', 'dynamic']));
expect(untypedMap.constantValue, equals('const {}'));
expect(typedSet.modelType.name, equals('Set'));
- expect(typedSet.modelType.typeArguments.map((a) => a.name).toList(), equals(['String']));
- expect(typedSet.constantValue, matches(new RegExp(r'const <String>\s?{}')));
+ expect(typedSet.modelType.typeArguments.map((a) => a.name).toList(),
+ equals(['String']));
+ expect(typedSet.constantValue,
+ matches(new RegExp(r'const <String>\s?{}')));
});
});
@@ -128,7 +143,8 @@
Method invokeToolNonCanonical, invokeToolNonCanonicalSubclass;
Method invokeToolPrivateLibrary, invokeToolPrivateLibraryOriginal;
Method invokeToolParentDoc, invokeToolParentDocOriginal;
- final RegExp packageInvocationIndexRegexp = new RegExp(r'PACKAGE_INVOCATION_INDEX: (\d+)');
+ final RegExp packageInvocationIndexRegexp =
+ new RegExp(r'PACKAGE_INVOCATION_INDEX: (\d+)');
setUpAll(() {
_NonCanonicalToolUser = fakeLibrary.allClasses
@@ -165,13 +181,16 @@
packageGraph.allLocalModelElements.forEach((m) => m.documentation);
});
- test('invokes tool when inherited documentation is the only means for it to be seen', () {
+ test(
+ 'invokes tool when inherited documentation is the only means for it to be seen',
+ () {
// Verify setup of the test is correct.
expect(invokeToolParentDoc.isCanonical, isTrue);
expect(invokeToolParentDoc.documentationComment, isNull);
// Error message here might look strange due to toString() on Methods, but if this
// fails that means we don't have the correct invokeToolParentDoc instance.
- expect(invokeToolParentDoc.documentationFrom, contains(invokeToolParentDocOriginal));
+ expect(invokeToolParentDoc.documentationFrom,
+ contains(invokeToolParentDocOriginal));
// Tool should be substituted out here.
expect(invokeToolParentDoc.documentation, isNot(contains('{@tool')));
});
@@ -187,18 +206,20 @@
equals(packageInvocationIndexRegexp
.firstMatch(invokeToolNonCanonicalSubclass.documentation)
.group(1)));
- expect(invokeToolPrivateLibrary.documentation, isNot(contains('{@tool')));
+ expect(
+ invokeToolPrivateLibrary.documentation, isNot(contains('{@tool')));
expect(
invokeToolPrivateLibraryOriginal.documentation, contains('{@tool'));
});
test('Documentation borrowed from implementer case', () {
- expect(packageInvocationIndexRegexp
- .firstMatch(invokeToolParentDoc.documentation)
- .group(1),
- equals(packageInvocationIndexRegexp
- .firstMatch(invokeToolParentDocOriginal.documentation)
- .group(1)));
+ expect(
+ packageInvocationIndexRegexp
+ .firstMatch(invokeToolParentDoc.documentation)
+ .group(1),
+ equals(packageInvocationIndexRegexp
+ .firstMatch(invokeToolParentDocOriginal.documentation)
+ .group(1)));
});
});
@@ -519,9 +540,10 @@
test('multiple containers with specified sort order', () {
List<LibraryContainer> containers = [];
- for (String name in containerNames)
+ for (String name in containerNames) {
containers
.add(new TestLibraryContainer(name, sortOrderBasic, topLevel));
+ }
containers
.add(new TestLibraryContainerSdk('SDK', sortOrderBasic, topLevel));
containers.sort();
@@ -540,8 +562,9 @@
test('multiple containers, no specified sort order', () {
List<LibraryContainer> containers = [];
- for (String name in containerNames)
+ for (String name in containerNames) {
containers.add(new TestLibraryContainer(name, [], topLevel));
+ }
containers.add(new TestLibraryContainerSdk('SDK', [], topLevel));
containers.sort();
expect(
@@ -921,9 +944,10 @@
withYouTubeInvalidUrl = documentationErrors.allInstanceMethods
.firstWhere((m) => m.name == 'withYouTubeInvalidUrl')
..documentation;
- withYouTubeUrlWithAdditionalParameters = documentationErrors.allInstanceMethods
+ withYouTubeUrlWithAdditionalParameters = documentationErrors
+ .allInstanceMethods
.firstWhere((m) => m.name == 'withYouTubeUrlWithAdditionalParameters')
- ..documentation;
+ ..documentation;
});
test("warns on youtube video with missing parameters", () {
@@ -993,19 +1017,26 @@
.firstWhere((m) => m.name == 'withYouTubeInline');
});
- test("renders a YouTube video within the method documentation with correct aspect ratio", () {
- expect(withYouTubeWatchUrl.documentation,
- contains('<iframe src="https://www.youtube.com/embed/oHg5SJYRHA0?rel=0"'));
+ test(
+ "renders a YouTube video within the method documentation with correct aspect ratio",
+ () {
+ expect(
+ withYouTubeWatchUrl.documentation,
+ contains(
+ '<iframe src="https://www.youtube.com/embed/oHg5SJYRHA0?rel=0"'));
// Video is 560x315, which means height is 56.25% of width.
- expect(withYouTubeWatchUrl.documentation, contains('padding-top: 56.25%;'));
+ expect(
+ withYouTubeWatchUrl.documentation, contains('padding-top: 56.25%;'));
});
test("Doesn't place YouTube video in one line doc", () {
expect(
withYouTubeInOneLineDoc.oneLineDoc,
isNot(contains(
'<iframe src="https://www.youtube.com/embed/oHg5SJYRHA0?rel=0"')));
- expect(withYouTubeInOneLineDoc.documentation,
- contains('<iframe src="https://www.youtube.com/embed/oHg5SJYRHA0?rel=0"'));
+ expect(
+ withYouTubeInOneLineDoc.documentation,
+ contains(
+ '<iframe src="https://www.youtube.com/embed/oHg5SJYRHA0?rel=0"'));
});
test("Handles YouTube video inline properly", () {
// Make sure it doesn't have a double-space before the continued line,
@@ -3162,8 +3193,10 @@
});
test('PRETTY_COLORS', () {
- expect(prettyColorsConstant.constantValue, matches(new RegExp(
- r"const <String>\s?\[COLOR_GREEN, COLOR_ORANGE, 'blue'\]")));
+ expect(
+ prettyColorsConstant.constantValue,
+ matches(new RegExp(
+ r"const <String>\s?\[COLOR_GREEN, COLOR_ORANGE, 'blue'\]")));
});
test('MY_CAT is linked', () {
@@ -3668,7 +3701,9 @@
class StringName extends Nameable {
@override
final String name;
+
StringName(this.name);
+
@override
String toString() => name;
}
diff --git a/test/package_meta_test.dart b/test/package_meta_test.dart
index 871d546..2b2452d 100644
--- a/test/package_meta_test.dart
+++ b/test/package_meta_test.dart
@@ -7,7 +7,7 @@
import 'dart:io';
import 'package:dartdoc/src/package_meta.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
@@ -26,7 +26,7 @@
group('PackageMeta for the test package', () {
PackageMeta p = new PackageMeta.fromDir(new Directory(
- pathLib.join(Directory.current.path, 'testing', 'test_package')));
+ path.join(Directory.current.path, 'testing', 'test_package')));
test('readme with corrupt UTF-8 loads without throwing', () {
expect(p.getReadmeContents().contents,
diff --git a/test/src/utils.dart b/test/src/utils.dart
index 3cbb31f..d017431 100644
--- a/test/src/utils.dart
+++ b/test/src/utils.dart
@@ -12,7 +12,7 @@
import 'package:dartdoc/src/html/html_generator.dart';
import 'package:dartdoc/src/model.dart';
import 'package:dartdoc/src/package_meta.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
final RegExp quotables = new RegExp(r'[ "\r\n\$]');
final RegExp observatoryPortRegexp =
@@ -150,7 +150,7 @@
}
static String buildNextCoverageFilename() =>
- pathLib.join(tempDir.path, 'dart-cov-${pid}-${nextRun++}.json');
+ path.join(tempDir.path, 'dart-cov-${pid}-${nextRun++}.json');
/// Call once all coverage runs have been generated by calling runStreamed
/// on all [CoverageSubprocessLaunchers].
@@ -171,8 +171,8 @@
'-b',
'.',
'--packages=.packages',
- '--sdk-root=${pathLib.canonicalize(pathLib.join(pathLib.dirname(Platform.executable), '..'))}',
- '--out=${pathLib.canonicalize(outputFile.path)}',
+ '--sdk-root=${path.canonicalize(path.join(path.dirname(Platform.executable), '..'))}',
+ '--out=${path.canonicalize(outputFile.path)}',
'--report-on=bin,lib',
'-i',
tempDir.path,
@@ -291,7 +291,9 @@
Map result;
try {
result = json.decoder.convert(line);
- } catch (FormatException) {}
+ } catch (FormatException) {
+ // ignore
+ }
if (result != null) {
if (jsonObjects == null) {
jsonObjects = new List();
diff --git a/test/template_test.dart b/test/template_test.dart
index eecf66d..91de138 100644
--- a/test/template_test.dart
+++ b/test/template_test.dart
@@ -6,7 +6,7 @@
import 'dart:io';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:mustache/mustache.dart';
import 'package:test/test.dart';
@@ -18,7 +18,7 @@
setUp(() {
if (sitemap == null) {
var templatePath =
- pathLib.join(pathLib.current, 'test/templates/sitemap.xml');
+ path.join(path.current, 'test/templates/sitemap.xml');
File tmplFile = new File(templatePath);
var siteMapTmpl = tmplFile.readAsStringSync();
sitemap = Template(siteMapTmpl);
diff --git a/test/tool_runner_test.dart b/test/tool_runner_test.dart
index 5c9600d..6087faa 100644
--- a/test/tool_runner_test.dart
+++ b/test/tool_runner_test.dart
@@ -8,7 +8,7 @@
import 'package:dartdoc/src/dartdoc_options.dart';
import 'package:dartdoc/src/tool_runner.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:yaml/yaml.dart';
@@ -27,7 +27,7 @@
setUpAll(() async {
ProcessResult result;
tempDir = Directory.systemTemp.createTempSync('tool_runner_test_');
- var snapshotFile = pathLib.join(tempDir.path, 'drill.snapshot');
+ var snapshotFile = path.join(tempDir.path, 'drill.snapshot');
try {
result = Process.runSync(
Platform.resolvedExecutable,
@@ -46,7 +46,7 @@
stderr.writeln(result.stderr);
}
expect(result?.exitCode, equals(0));
- setupFile = File(pathLib.join(tempDir.path, 'setup.stamp'));
+ setupFile = File(path.join(tempDir.path, 'setup.stamp'));
// We use the Dart executable for our "non-dart" tool
// test, because it's the only executable that we know the
// exact location of that works on all platforms.
@@ -73,8 +73,7 @@
windows: ['C:\\Windows\\System32\\cmd.exe', '/c', 'echo']
description: 'Works on everything'
''';
- var pathContext =
- pathLib.Context(current: utils.testPackageDir.absolute.path);
+ var pathContext = path.Context(current: utils.testPackageDir.absolute.path);
toolMap = ToolConfiguration.fromYamlMap(loadYaml(yamlMap), pathContext);
// This shouldn't really happen, but if you didn't load the config from a
// yaml map (which would fail on a missing executable), or a file is deleted
diff --git a/test/warnings_test.dart b/test/warnings_test.dart
index 4e12f23..a5b98e0 100644
--- a/test/warnings_test.dart
+++ b/test/warnings_test.dart
@@ -9,7 +9,7 @@
import 'package:dartdoc/src/dartdoc_options.dart';
import 'package:dartdoc/src/warnings.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
@@ -19,21 +19,18 @@
setUpAll(() {
tempDir = Directory.systemTemp.createTempSync('warnings_test');
- testPackageOne = Directory(pathLib.join(tempDir.path, 'test_package_one'))
+ testPackageOne = Directory(path.join(tempDir.path, 'test_package_one'))
..createSync();
- testPackageTwo = Directory(pathLib.join(tempDir.path, 'test_package_two'))
+ testPackageTwo = Directory(path.join(tempDir.path, 'test_package_two'))
..createSync();
- testPackageThree =
- Directory(pathLib.join(tempDir.path, 'test_package_three'))
- ..createSync();
- pubspecYamlOne =
- new File(pathLib.join(testPackageOne.path, 'pubspec.yaml'));
+ testPackageThree = Directory(path.join(tempDir.path, 'test_package_three'))
+ ..createSync();
+ pubspecYamlOne = new File(path.join(testPackageOne.path, 'pubspec.yaml'));
pubspecYamlOne.writeAsStringSync('name: test_package_one');
- pubspecYamlTwo =
- new File(pathLib.join(testPackageTwo.path, 'pubspec.yaml'));
+ pubspecYamlTwo = new File(path.join(testPackageTwo.path, 'pubspec.yaml'));
pubspecYamlTwo.writeAsStringSync('name: test_package_two');
dartdocYamlThree =
- new File(pathLib.join(testPackageThree.path, 'dartdoc_options.yaml'));
+ new File(path.join(testPackageThree.path, 'dartdoc_options.yaml'));
dartdocYamlThree.writeAsStringSync('''
dartdoc:
warnings:
@@ -45,7 +42,7 @@
- ambiguous-reexport
''');
pubspecYamlThree =
- new File(pathLib.join(testPackageThree.path, 'pubspec.yaml'));
+ new File(path.join(testPackageThree.path, 'pubspec.yaml'));
pubspecYamlThree.writeAsStringSync('name: test_package_three');
});
diff --git a/tool/builder.dart b/tool/builder.dart
index 4ad3a21..a62b693 100644
--- a/tool/builder.dart
+++ b/tool/builder.dart
@@ -6,7 +6,7 @@
import 'package:build/build.dart';
import 'package:glob/glob.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
String _resourcesFile(Iterable<String> packagePaths) => '''
// WARNING: This file is auto-generated. Do not taunt.
@@ -30,7 +30,7 @@
packagePaths.sort();
await buildStep.writeAsString(
new AssetId(buildStep.inputId.package,
- pathLib.url.join('lib', 'src', 'html', 'resources.g.dart')),
+ path.url.join('lib', 'src', 'html', 'resources.g.dart')),
_resourcesFile(packagePaths));
}
diff --git a/tool/doc_packages.dart b/tool/doc_packages.dart
index 37e9206..20903c9 100644
--- a/tool/doc_packages.dart
+++ b/tool/doc_packages.dart
@@ -226,8 +226,9 @@
if (sdk != null) {
VersionConstraint constraint = new VersionConstraint.parse(sdk);
String version = Platform.version;
- if (version.contains(' '))
+ if (version.contains(' ')) {
version = version.substring(0, version.indexOf(' '));
+ }
if (!constraint.allows(new Version.parse(version))) {
_log('sdk constraint = ${constraint}');
return true;
diff --git a/tool/grind.dart b/tool/grind.dart
index dff46a3..8309e30 100644
--- a/tool/grind.dart
+++ b/tool/grind.dart
@@ -8,7 +8,7 @@
import 'package:dartdoc/src/io_utils.dart';
import 'package:grinder/grinder.dart';
import 'package:io/io.dart';
-import 'package:path/path.dart' as pathLib;
+import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart' as yaml;
import '../test/src/utils.dart';
@@ -18,14 +18,16 @@
/// Thrown on failure to find something in a file.
class GrindTestFailure {
final String message;
+
GrindTestFailure(this.message);
}
/// Kind of an inefficient grepper for now.
void expectFileContains(String path, List<Pattern> items) {
File source = new File(path);
- if (!source.existsSync())
+ if (!source.existsSync()) {
throw new GrindTestFailure('file not found: ${path}');
+ }
for (Pattern item in items) {
if (!new File(path).readAsStringSync().contains(item)) {
throw new GrindTestFailure('Can not find ${item} in ${path}');
@@ -62,12 +64,12 @@
// it.
await cleanFlutterDir.parent.create(recursive: true);
assert(_lockFuture == null);
- _lockFuture = new File(pathLib.join(cleanFlutterDir.parent.path, 'lock'))
+ _lockFuture = new File(path.join(cleanFlutterDir.parent.path, 'lock'))
.openSync(mode: FileMode.write)
.lock();
await _lockFuture;
File lastSynced =
- new File(pathLib.join(cleanFlutterDir.parent.path, 'lastSynced'));
+ new File(path.join(cleanFlutterDir.parent.path, 'lastSynced'));
FlutterRepo newRepo =
new FlutterRepo.fromPath(cleanFlutterDir.path, {}, 'clean');
@@ -95,31 +97,38 @@
}
Directory _dartdocDocsDir;
+
Directory get dartdocDocsDir => _dartdocDocsDir ??= createTempSync('dartdoc');
Directory _dartdocDocsDirRemote;
+
Directory get dartdocDocsDirRemote =>
_dartdocDocsDirRemote ??= createTempSync('dartdoc_remote');
Directory _sdkDocsDir;
+
Directory get sdkDocsDir => _sdkDocsDir ??= createTempSync('sdkdocs');
Directory cleanFlutterDir = new Directory(
- pathLib.join(resolveTildePath('~/.dartdoc_grinder'), 'cleanFlutter'));
+ path.join(resolveTildePath('~/.dartdoc_grinder'), 'cleanFlutter'));
Directory _flutterDir;
+
Directory get flutterDir => _flutterDir ??= createTempSync('flutter');
Directory get testPackage =>
- new Directory(pathLib.joinAll(['testing', 'test_package']));
+ new Directory(path.joinAll(['testing', 'test_package']));
+
Directory get pluginPackage =>
- new Directory(pathLib.joinAll(['testing', 'test_package_flutter_plugin']));
+ new Directory(path.joinAll(['testing', 'test_package_flutter_plugin']));
Directory _testPackageDocsDir;
+
Directory get testPackageDocsDir =>
_testPackageDocsDir ??= createTempSync('test_package');
Directory _pluginPackageDocsDir;
+
Directory get pluginPackageDocsDir =>
_pluginPackageDocsDir ??= createTempSync('test_package_flutter_plugin');
@@ -149,14 +158,13 @@
}
final Directory flutterDirDevTools =
- new Directory(pathLib.join(flutterDir.path, 'dev', 'tools'));
+ new Directory(path.join(flutterDir.path, 'dev', 'tools'));
/// Creates a throwaway pub cache and returns the environment variables
/// necessary to use it.
Map<String, String> _createThrowawayPubCache() {
final Directory pubCache = Directory.systemTemp.createTempSync('pubcache');
- final Directory pubCacheBin =
- new Directory(pathLib.join(pubCache.path, 'bin'));
+ final Directory pubCacheBin = new Directory(path.join(pubCache.path, 'bin'));
pubCacheBin.createSync();
return new Map.fromIterables([
'PUB_CACHE',
@@ -173,6 +181,7 @@
new FilePath('lib/src/third_party/pkg/mustache4dart');
final RegExp _mustache4dartPatches =
new RegExp(r'^\d\d\d-mustache4dart-.*[.]patch$');
+
@Task('Update third_party forks')
void updateThirdParty() async {
run('rm', arguments: ['-rf', _mustache4dartDir.path]);
@@ -185,10 +194,10 @@
'git@github.com:valotas/mustache4dart',
_mustache4dartDir.path,
]);
- run('rm', arguments: ['-rf', pathLib.join(_mustache4dartDir.path, '.git')]);
+ run('rm', arguments: ['-rf', path.join(_mustache4dartDir.path, '.git')]);
for (String patchFileName in new Directory(_pkgDir.path)
.listSync()
- .map((e) => pathLib.basename(e.path))
+ .map((e) => path.basename(e.path))
.where((String filename) => _mustache4dartPatches.hasMatch(filename))
.toList()
..sort()) {
@@ -236,6 +245,7 @@
final Map<String, int> warningKeyCounts;
final String branch;
final String pubCachePath;
+
WarningsCollection(this.tempDir, this.pubCachePath, this.branch)
: this.warningKeyCounts = new Map();
@@ -244,15 +254,17 @@
String _toKey(String text) {
String key = text.replaceAll(tempDir, kTempDirReplacement);
- if (pubCachePath != null)
+ if (pubCachePath != null) {
key = key.replaceAll(pubCachePath, kPubCachePathReplacement);
+ }
return key;
}
String _fromKey(String text) {
String key = text.replaceAll(kTempDirReplacement, tempDir);
- if (pubCachePath != null)
+ if (pubCachePath != null) {
key = key.replaceAll(kPubCachePathReplacement, pubCachePath);
+ }
return key;
}
@@ -394,7 +406,7 @@
'https://dart.googlesource.com/sdk.git',
sdkClone.path
]);
- File dartdocPubspec = new File(pathLib.join(dartdocSdk.path, 'pubspec.yaml'));
+ File dartdocPubspec = new File(path.join(dartdocSdk.path, 'pubspec.yaml'));
List<String> pubspecLines = await dartdocPubspec.readAsLines();
List<String> pubspecLinesFiltered = [];
for (String line in pubspecLines) {
@@ -443,7 +455,7 @@
Platform.resolvedExecutable,
[
'--enable-asserts',
- pathLib.join('bin', 'dartdoc.dart'),
+ path.join('bin', 'dartdoc.dart'),
'--output',
'${sdkDocsPath}',
'--sdk-docs',
@@ -469,7 +481,7 @@
Platform.resolvedExecutable,
[
'--enable-asserts',
- pathLib.join(cwd, 'bin', 'dartdoc.dart'),
+ path.join(cwd, 'bin', 'dartdoc.dart'),
'--output',
outputDir,
'--example-path-prefix',
@@ -563,7 +575,7 @@
'--port',
'9000',
'--path',
- pathLib.join(originalDartdocFlutter.absolute.path, 'dev', 'docs', 'doc'),
+ path.join(originalDartdocFlutter.absolute.path, 'dev', 'docs', 'doc'),
]);
Future current = launcher.runStreamed(sdkBin('pub'), [
'run',
@@ -571,7 +583,7 @@
'--port',
'9001',
'--path',
- pathLib.join(flutterDir.absolute.path, 'dev', 'docs', 'doc'),
+ path.join(flutterDir.absolute.path, 'dev', 'docs', 'doc'),
]);
await Future.wait([original, current]);
}
@@ -589,7 +601,7 @@
'--port',
'8001',
'--path',
- pathLib.join(flutterDir.path, 'dev', 'docs', 'doc'),
+ path.join(flutterDir.path, 'dev', 'docs', 'doc'),
]);
}
@@ -603,9 +615,9 @@
Map<String, String> env = _createThrowawayPubCache();
await _buildFlutterDocs(
flutterDir.path, new Future.value(Directory.current.path), env, 'docs');
- String index = new File(
- pathLib.join(flutterDir.path, 'dev', 'docs', 'doc', 'index.html'))
- .readAsStringSync();
+ String index =
+ new File(path.join(flutterDir.path, 'dev', 'docs', 'doc', 'index.html'))
+ .readAsStringSync();
stdout.write(index);
}
@@ -613,15 +625,14 @@
class FlutterRepo {
final String flutterPath;
final Map<String, String> env;
- final String bin = pathLib.join('bin', 'flutter');
+ final String bin = path.join('bin', 'flutter');
FlutterRepo._(this.flutterPath, this.env, String label) {
cacheDart =
- pathLib.join(flutterPath, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
- cachePub =
- pathLib.join(flutterPath, 'bin', 'cache', 'dart-sdk', 'bin', 'pub');
+ path.join(flutterPath, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
+ cachePub = path.join(flutterPath, 'bin', 'cache', 'dart-sdk', 'bin', 'pub');
env['PATH'] =
- '${pathLib.join(pathLib.canonicalize(flutterPath), "bin")}:${env['PATH'] ?? Platform.environment['PATH']}';
+ '${path.join(path.canonicalize(flutterPath), "bin")}:${env['PATH'] ?? Platform.environment['PATH']}';
env['FLUTTER_ROOT'] = flutterPath;
launcher =
new SubprocessLauncher('flutter${label == null ? "" : "-$label"}', env);
@@ -685,19 +696,19 @@
await flutterRepo.launcher.runStreamed(
flutterRepo.cachePub,
['get'],
- workingDirectory: pathLib.join(flutterPath, 'dev', 'tools'),
+ workingDirectory: path.join(flutterPath, 'dev', 'tools'),
);
await flutterRepo.launcher.runStreamed(
flutterRepo.cachePub,
['get'],
- workingDirectory: pathLib.join(flutterPath, 'dev', 'snippets'),
+ workingDirectory: path.join(flutterPath, 'dev', 'snippets'),
);
await flutterRepo.launcher.runStreamed(
flutterRepo.cachePub, ['global', 'activate', '-spath', '.'],
workingDirectory: await futureCwd);
return await flutterRepo.launcher.runStreamed(
flutterRepo.cacheDart,
- [pathLib.join('dev', 'tools', 'dartdoc.dart'), '-c', '--json'],
+ [path.join('dev', 'tools', 'dartdoc.dart'), '-c', '--json'],
workingDirectory: flutterPath,
);
}
@@ -714,8 +725,8 @@
if (version != null) args.addAll(<String>['-v', version]);
args.add(pubPackageName);
await launcher.runStreamed('pub', args);
- Directory cache = new Directory(
- pathLib.join(env['PUB_CACHE'], 'hosted', 'pub.dartlang.org'));
+ Directory cache =
+ new Directory(path.join(env['PUB_CACHE'], 'hosted', 'pub.dartlang.org'));
Directory pubPackageDir =
cache.listSync().firstWhere((e) => e.path.contains(pubPackageName));
await launcher.runStreamed('pub', ['get'],
@@ -724,12 +735,12 @@
Platform.resolvedExecutable,
[
'--enable-asserts',
- pathLib.join(Directory.current.absolute.path, 'bin', 'dartdoc.dart'),
+ path.join(Directory.current.absolute.path, 'bin', 'dartdoc.dart'),
'--json',
'--show-progress',
]..addAll(dartdocParameters),
workingDirectory: pubPackageDir.absolute.path);
- return pathLib.join(pubPackageDir.absolute.path, 'doc', 'api');
+ return path.join(pubPackageDir.absolute.path, 'doc', 'api');
}
@Task(
@@ -795,7 +806,7 @@
'../dartdoc_options.yaml',
'src/html/resources.g.dart',
'src/version.dart',
-].map((s) => pathLib.joinAll(pathLib.posix.split(s)));
+].map((s) => path.joinAll(path.posix.split(s)));
@Task('Verify generated files are up to date')
Future<void> checkBuild() async {
@@ -805,7 +816,7 @@
// Load original file contents into memory before running the builder;
// it modifies them in place.
for (String relPath in _generated_files_list) {
- String origPath = pathLib.joinAll(['lib', relPath]);
+ String origPath = path.joinAll(['lib', relPath]);
File oldVersion = new File(origPath);
if (oldVersion.existsSync()) {
originalFileContents[relPath] = oldVersion.readAsStringSync();
@@ -814,7 +825,7 @@
await build();
for (String relPath in _generated_files_list) {
- File newVersion = new File(pathLib.join('lib', relPath));
+ File newVersion = new File(path.join('lib', relPath));
if (!await newVersion.exists()) {
log('${newVersion.path} does not exist\n');
differentFiles.add(relPath);
@@ -827,7 +838,7 @@
if (differentFiles.isNotEmpty) {
fail('The following generated files needed to be rebuilt:\n'
- ' ${differentFiles.map((f) => pathLib.join('lib', f)).join("\n ")}\n'
+ ' ${differentFiles.map((f) => path.join('lib', f)).join("\n ")}\n'
'Rebuild them with "grind build" and check the results in.');
}
}
@@ -855,13 +866,13 @@
List<String> parameters = ['--enable-asserts'];
for (File dartFile in testFiles) {
- await testFutures.addFutureFromClosure(() => new CoverageSubprocessLauncher(
- 'dart2-${pathLib.basename(dartFile.path)}')
- .runStreamed(
- Platform.resolvedExecutable,
- <String>[]
- ..addAll(parameters)
- ..add(dartFile.path)));
+ await testFutures.addFutureFromClosure(() =>
+ new CoverageSubprocessLauncher('dart2-${path.basename(dartFile.path)}')
+ .runStreamed(
+ Platform.resolvedExecutable,
+ <String>[]
+ ..addAll(parameters)
+ ..add(dartFile.path)));
}
return CoverageSubprocessLauncher.generateCoverageToFile(
@@ -877,11 +888,11 @@
'--output',
dartdocDocsDir.path
]);
- expectFileContains(pathLib.join(dartdocDocsDir.path, 'index.html'),
+ expectFileContains(path.join(dartdocDocsDir.path, 'index.html'),
['<title>dartdoc - Dart API docs</title>']);
final RegExp object = new RegExp('<li>Object</li>', multiLine: true);
expectFileContains(
- pathLib.join(dartdocDocsDir.path, 'dartdoc', 'ModelElement-class.html'),
+ path.join(dartdocDocsDir.path, 'dartdoc', 'ModelElement-class.html'),
[object]);
}
@@ -898,10 +909,10 @@
'--output',
dartdocDocsDir.path
]);
- expectFileContains(pathLib.join(dartdocDocsDir.path, 'index.html'),
+ expectFileContains(path.join(dartdocDocsDir.path, 'index.html'),
['<title>dartdoc - Dart API docs</title>']);
expectFileContains(
- pathLib.join(dartdocDocsDir.path, 'dartdoc', 'ModelElement-class.html'),
+ path.join(dartdocDocsDir.path, 'dartdoc', 'ModelElement-class.html'),
[object]);
}
@@ -921,7 +932,7 @@
flutterRepo.cacheDart,
[
'--enable-asserts',
- pathLib.join(Directory.current.path, 'bin', 'dartdoc.dart'),
+ path.join(Directory.current.path, 'bin', 'dartdoc.dart'),
'--exclude-packages',
'Dart', // TODO(jcollins-g): dart-lang/dartdoc#1431
'--json',
@@ -948,7 +959,7 @@
}
// Verify that links to Dart SDK and Flutter SDK go to the flutter site.
expectFileContains(
- pathLib.join(
+ path.join(
pluginPackageDocsDir.path, 'testlib', 'MyAwesomeWidget-class.html'),
[
'<a href="https://docs.flutter.io/flutter/widgets/Widget-class.html">Widget</a>',
@@ -994,8 +1005,8 @@
}
log('$libsLength dart: libraries found');
- var futureConstFile = joinFile(
- sdkDocsDir, [pathLib.join('dart-async', 'Future', 'Future.html')]);
+ var futureConstFile =
+ joinFile(sdkDocsDir, [path.join('dart-async', 'Future', 'Future.html')]);
if (!futureConstFile.existsSync()) {
fail('no Future.html found for dart:async Future constructor');
}