Skip to content

Commit 9d3fd55

Browse files
committed
Remove the include-externals option
1 parent f41bd3a commit 9d3fd55

File tree

7 files changed

+15
-96
lines changed

7 files changed

+15
-96
lines changed

lib/src/dartdoc.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ class Dartdoc {
188188
runtimeStats.startPerfTask('buildPackageGraph');
189189
var packageGraph = await packageBuilder.buildPackageGraph();
190190
runtimeStats.endPerfTask();
191-
if (packageBuilder.includeExternalsWasSpecified) {
192-
packageGraph.defaultPackage.warn(
193-
PackageWarning.deprecated,
194-
message:
195-
"The '--include-externals' option is deprecated, and will soon be "
196-
'removed.',
197-
);
198-
}
199191
var libs = packageGraph.libraryCount;
200192
logInfo("Initialized dartdoc with $libs librar${libs == 1 ? 'y' : 'ies'}");
201193

lib/src/dartdoc_options.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,6 @@ class DartdocOptionContext extends DartdocOptionContextBase
11791179
late final Set<String> include =
11801180
Set.of(optionSet['include'].valueAt(context));
11811181

1182-
List<String> get includeExternal =>
1183-
optionSet['includeExternal'].valueAt(context);
1184-
11851182
bool get includeSource => optionSet['includeSource'].valueAt(context);
11861183

11871184
bool get injectHtml => optionSet['injectHtml'].valueAt(context);
@@ -1399,7 +1396,7 @@ List<DartdocOption> createDartdocOptions(
13991396
DartdocOptionArgOnly<bool>(
14001397
'autoIncludeDependencies', false, resourceProvider,
14011398
help: 'Include all the used libraries into the docs, even the ones not '
1402-
'in the current package or "include-external"',
1399+
'in the current package',
14031400
negatable: true),
14041401
DartdocOptionArgFile<List<String>>(
14051402
'categoryOrder', const [], resourceProvider,
@@ -1431,12 +1428,6 @@ List<DartdocOption> createDartdocOptions(
14311428
mustExist: true),
14321429
DartdocOptionArgFile<List<String>>('include', [], resourceProvider,
14331430
help: 'Names of libraries to document.', splitCommas: true),
1434-
DartdocOptionArgFile<List<String>>('includeExternal', [], resourceProvider,
1435-
optionIs: OptionKind.file,
1436-
help: 'Additional (external) dart files to include; use '
1437-
'"<directory name>/<file name>", as in "lib/material.dart".',
1438-
mustExist: true,
1439-
splitCommas: true),
14401431
DartdocOptionArgOnly<bool>('includeSource', true, resourceProvider,
14411432
help: 'Show source code blocks.', negatable: true),
14421433
DartdocOptionArgOnly<bool>('injectHtml', false, resourceProvider,

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25738,7 +25738,6 @@ const _invisibleGetters = {
2573825738
'flutterRoot',
2573925739
'hashCode',
2574025740
'include',
25741-
'includeExternal',
2574225741
'includeSource',
2574325742
'injectHtml',
2574425743
'inputDir',

lib/src/model/package_builder.dart

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ import 'package:path/path.dart' as p show Context;
3737
abstract class PackageBuilder {
3838
// Builds package graph to be used by documentation generator.
3939
Future<PackageGraph> buildPackageGraph();
40-
41-
/// The `include-external` option is deprecated, so we track whether it was
42-
/// used, to report it.
43-
bool get includeExternalsWasSpecified;
4440
}
4541

4642
/// A package builder that understands pub package format.
@@ -283,11 +279,6 @@ class PubPackageBuilder implements PackageBuilder {
283279
processedLibraries.add(resolvedLibrary.element);
284280
}
285281
files.addAll(newFiles);
286-
var externals = _includedExternalsFrom(newFiles);
287-
if (externals.isNotEmpty) {
288-
includeExternalsWasSpecified = true;
289-
}
290-
files.addAll(externals);
291282

292283
var packages = _packageMetasForFiles(files.difference(_knownParts));
293284
filesInCurrentPass = {...files.difference(_knownParts)};
@@ -384,25 +375,11 @@ class PubPackageBuilder implements PackageBuilder {
384375
return dirs;
385376
}
386377

387-
/// Calculates 'includeExternal' based on a list of files.
388-
///
389-
/// Assumes each file might be part of a [DartdocOptionContext], and loads
390-
/// those objects to find any [DartdocOptionContext.includeExternal]
391-
/// configurations therein.
392-
List<String> _includedExternalsFrom(Iterable<String> files) => [
393-
for (var file in files)
394-
...DartdocOptionContext.fromContext(
395-
_config,
396-
_config.resourceProvider.getFile(file),
397-
_config.resourceProvider,
398-
).includeExternal,
399-
];
400-
401378
/// Returns the set of files that may contain elements that need to be
402379
/// documented.
403380
///
404-
/// This takes into account the 'auto-include-dependencies' option, the
405-
/// 'exclude' option, and the 'include-external' option.
381+
/// This takes into account the 'auto-include-dependencies' option, and the
382+
/// 'exclude' option.
406383
Future<Set<String>> _getFilesToDocument() async {
407384
if (_config.topLevelPackageMeta.isSdk) {
408385
return _sdkFilesToDocument
@@ -412,12 +389,7 @@ class PubPackageBuilder implements PackageBuilder {
412389
var packagesToDocument = await _findPackagesToDocument(
413390
_config.inputDir,
414391
);
415-
var files = _findFilesToDocumentInPackage(packagesToDocument).toList();
416-
var externals = _includedExternalsFrom(files);
417-
if (externals.isNotEmpty) {
418-
includeExternalsWasSpecified = true;
419-
files = [...files, ...externals];
420-
}
392+
var files = _findFilesToDocumentInPackage(packagesToDocument);
421393
return {
422394
...files.map(
423395
(s) => _pathContext.absolute(_resourceProvider.getFile(s).path)),
@@ -446,9 +418,6 @@ class PubPackageBuilder implements PackageBuilder {
446418
};
447419
}
448420

449-
@override
450-
bool includeExternalsWasSpecified = false;
451-
452421
Iterable<String> get _embedderSdkFiles => [
453422
for (var dartUri in _embedderSdkUris)
454423
_pathContext.absolute(_resourceProvider

lib/src/model/package_graph.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,14 @@ class PackageGraph with CommentReferable, Nameable {
170170
e.canonicalModelElement == null ||
171171
e is Library ||
172172
e.enclosingElement!.isCanonical) {
173-
for (var d in e.documentationFrom
174-
.where((d) => d.hasDocumentationComment)) {
173+
for (var d
174+
in e.documentationFrom.where((d) => d.hasDocumentationComment)) {
175175
if (d.needsPrecache && !precachedElements.contains(d)) {
176176
precachedElements.add(d as ModelElement);
177177
futures.add(d.precacheLocalDocs());
178178
// [TopLevelVariable]s get their documentation from getters and
179179
// setters, so should be precached if either has a template.
180-
if (e is TopLevelVariable &&
181-
!precachedElements.contains(e)) {
180+
if (e is TopLevelVariable && !precachedElements.contains(e)) {
182181
precachedElements.add(e);
183182
futures.add(e.precacheLocalDocs());
184183
}
@@ -647,7 +646,8 @@ class PackageGraph with CommentReferable, Nameable {
647646
checkAndAddContainer(modelElement, container);
648647
}
649648
} else if (container is Mixin) {
650-
for (var modelElement in container.superclassConstraints.modelElements) {
649+
for (var modelElement
650+
in container.superclassConstraints.modelElements) {
651651
checkAndAddContainer(modelElement, container);
652652
}
653653
}
@@ -752,8 +752,7 @@ class PackageGraph with CommentReferable, Nameable {
752752
// TODO(keertip): Find a better way to exclude members of extensions
753753
// when libraries are specified using the "--include" flag.
754754
if (library != null && library.isDocumented) {
755-
return getModelFor(e, library,
756-
enclosingContainer: preferredClass);
755+
return getModelFor(e, library, enclosingContainer: preferredClass);
757756
}
758757
}
759758
// TODO(jcollins-g): The data structures should be changed to eliminate
@@ -778,8 +777,7 @@ class PackageGraph with CommentReferable, Nameable {
778777
var setterElement = setter2 == null
779778
? null
780779
: getModelFor(setter2, library) as Accessor;
781-
canonicalModelElement = getModelForPropertyInducingElement(
782-
e, library,
780+
canonicalModelElement = getModelForPropertyInducingElement(e, library,
783781
getter: getterElement, setter: setterElement);
784782
} else {
785783
canonicalModelElement = getModelFor(e, library);
@@ -791,8 +789,7 @@ class PackageGraph with CommentReferable, Nameable {
791789
}
792790
}
793791
// Prefer fields and top-level variables.
794-
if (e is PropertyAccessorElement2 &&
795-
canonicalModelElement is Accessor) {
792+
if (e is PropertyAccessorElement2 && canonicalModelElement is Accessor) {
796793
canonicalModelElement = canonicalModelElement.enclosingCombo;
797794
}
798795
return canonicalModelElement;
@@ -804,8 +801,8 @@ class PackageGraph with CommentReferable, Nameable {
804801
var elem = modelElement.element;
805802
var candidates = <ModelElement>{};
806803
if (lib != null) {
807-
var constructedWithKey = allConstructedModelElements[
808-
ConstructedModelElementsKey(elem, null)];
804+
var constructedWithKey =
805+
allConstructedModelElements[ConstructedModelElementsKey(elem, null)];
809806
if (constructedWithKey != null) {
810807
candidates.add(constructedWithKey);
811808
}

test/packages_test.dart

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -330,35 +330,6 @@ dartdoc:
330330
packageGraph.packages.singleWhere((p) => p.name == 'one');
331331
expect(packageOne.documentedWhere, equals(DocumentLocation.missing));
332332
});
333-
334-
test(
335-
'includes external remote elements when includeExternal is specified',
336-
() async {
337-
packageOneRoot
338-
.getChildAssumingFile('dartdoc_options.yaml')
339-
.writeAsStringSync('''
340-
dartdoc:
341-
includeExternal:
342-
- bin/script.dart
343-
linkTo:
344-
url: 'https://mypub.topdomain/%n%/%v%'
345-
''');
346-
var packageGraph = await utils.bootBasicPackage(
347-
packageTwoRoot.path, packageMetaProvider, packageConfigProvider,
348-
additionalArguments: ['--link-to-remote']);
349-
350-
expect(packageGraph.packages, hasLength(3));
351-
var packageOne =
352-
packageGraph.packages.singleWhere((p) => p.name == 'one');
353-
expect(packageOne.documentedWhere, equals(DocumentLocation.remote));
354-
// TODO(srawlins): Why is there more than one?
355-
var libraryScript = packageOne.allLibraries.named('script');
356-
var classScript = libraryScript.classesAndExceptions.named('Script');
357-
expect(
358-
classScript.href,
359-
equals(
360-
'https://mypub.topdomain/one/0.0.1/script/Script-class.html'));
361-
});
362333
});
363334

364335
group('SDK package', () {

test/src/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Future<DartdocOptionContext> contextFromArgv(
4747
'dartdoc', [createDartdocOptions], packageMetaProvider);
4848
optionSet.parseArguments(argv);
4949
return DartdocOptionContext.fromDefaultContextLocation(
50-
optionSet, pubPackageMetaProvider.resourceProvider);
50+
optionSet, packageMetaProvider.resourceProvider);
5151
}
5252

5353
/// Convenience factory to build a [DartdocGeneratorOptionContext] and

0 commit comments

Comments
 (0)