Skip to content

Commit 37c95d7

Browse files
jdkorenkeertip
authored andcommitted
Revert "Add configuration option for output format (#1996)" (#2003)
This reverts commit e68de51.
1 parent 5284c19 commit 37c95d7

File tree

6 files changed

+16
-45
lines changed

6 files changed

+16
-45
lines changed

lib/dartdoc.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'dart:convert';
1313
import 'dart:io';
1414

1515
import 'package:dartdoc/src/dartdoc_options.dart';
16-
import 'package:dartdoc/src/empty_generator.dart';
1716
import 'package:dartdoc/src/generator.dart';
1817
import 'package:dartdoc/src/html/html_generator.dart';
1918
import 'package:dartdoc/src/logging.dart';
@@ -69,9 +68,9 @@ class Dartdoc extends PackageBuilder {
6968
return new Dartdoc._(config, generators);
7069
}
7170

72-
/// An asynchronous factory method that builds an EmptyGenerator.
71+
/// An asynchronous factory method that builds
7372
static Future<Dartdoc> withEmptyGenerator(DartdocOptionContext config) async {
74-
List<Generator> generators = [await createEmptyGenerator(config)];
73+
List<Generator> generators = await initEmptyGenerators(config);
7574
return new Dartdoc._(config, generators);
7675
}
7776

lib/src/dartdoc_options.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,6 @@ class DartdocOptionContext extends DartdocOptionContextBase
14221422

14231423
bool isPackageExcluded(String name) =>
14241424
excludePackages.any((pattern) => name == pattern);
1425-
1426-
String get format => optionSet['format'].valueAt(context);
14271425
}
14281426

14291427
/// Instantiate dartdoc's configuration file and options parser with the
@@ -1626,8 +1624,6 @@ Future<List<DartdocOption>> createDartdocOptions() async {
16261624
'exist. Executables for different platforms are specified by '
16271625
'giving the platform name as a key, and a list of strings as the '
16281626
'command.'),
1629-
// TODO(jdkoren): unhide when this feature is in working order.
1630-
new DartdocOptionArgOnly<String>('format', 'html', hide: true)
16311627
// TODO(jcollins-g): refactor so there is a single static "create" for
16321628
// each DartdocOptionContext that traverses the inheritance tree itself.
16331629
]

lib/src/empty_generator.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ library dartdoc.empty_generator;
22

33
import 'dart:async';
44

5-
import 'package:dartdoc/dartdoc.dart';
65
import 'package:dartdoc/src/generator.dart';
76
import 'package:dartdoc/src/model.dart';
87
import 'package:dartdoc/src/model_utils.dart';
@@ -40,7 +39,3 @@ class EmptyGenerator extends Generator {
4039
@override
4140
Set<String> get writtenFiles => new Set();
4241
}
43-
44-
Future<Generator> createEmptyGenerator(DartdocOptionContext config) async {
45-
return EmptyGenerator();
46-
}

lib/src/generator.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ library dartdoc.generator;
77

88
import 'dart:async' show Stream, Future;
99

10-
import 'package:dartdoc/dartdoc.dart';
11-
import 'package:dartdoc/src/empty_generator.dart';
1210
import 'package:dartdoc/src/model.dart' show PackageGraph;
13-
import 'package:dartdoc/src/html/html_generator.dart';
1411

1512
/// An abstract class that defines a generator that generates documentation for
1613
/// a given package.
@@ -27,17 +24,3 @@ abstract class Generator {
2724
/// Fetches all filenames written by this generator.
2825
Set<String> get writtenFiles;
2926
}
30-
31-
/// Initialize and setup the generators.
32-
Future<List<Generator>> initGenerators(GeneratorContext config) async {
33-
// TODO(jdkoren) this could support multiple generators.
34-
var format = config.format;
35-
switch (format) {
36-
case 'html':
37-
return [await createHtmlGenerator(config)];
38-
case 'md':
39-
return [await createEmptyGenerator(config)];
40-
default:
41-
throw DartdocFailure('Unsupported output format: ${format}');
42-
}
43-
}

lib/src/html/html_generator.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'dart:io' show Directory, File;
99
import 'dart:isolate';
1010

1111
import 'package:dartdoc/dartdoc.dart';
12+
import 'package:dartdoc/src/empty_generator.dart';
1213
import 'package:dartdoc/src/generator.dart';
1314
import 'package:dartdoc/src/html/html_generator_instance.dart';
1415
import 'package:dartdoc/src/html/template_data.dart';
@@ -131,8 +132,12 @@ class HtmlGeneratorOptions implements HtmlOptions {
131132
: this.toolVersion = toolVersion ?? 'unknown';
132133
}
133134

135+
Future<List<Generator>> initEmptyGenerators(DartdocOptionContext config) async {
136+
return [EmptyGenerator()];
137+
}
138+
134139
/// Initialize and setup the generators.
135-
Future<HtmlGenerator> createHtmlGenerator(GeneratorContext config) async {
140+
Future<List<Generator>> initGenerators(GeneratorContext config) async {
136141
// TODO(jcollins-g): Rationalize based on GeneratorContext all the way down
137142
// through the generators.
138143
HtmlGeneratorOptions options = new HtmlGeneratorOptions(
@@ -142,12 +147,14 @@ Future<HtmlGenerator> createHtmlGenerator(GeneratorContext config) async {
142147
faviconPath: config.favicon,
143148
prettyIndexJson: config.prettyIndexJson);
144149

145-
return await HtmlGenerator.create(
146-
options: options,
147-
headers: config.header,
148-
footers: config.footer,
149-
footerTexts: config.footerTextPaths,
150-
);
150+
return [
151+
await HtmlGenerator.create(
152+
options: options,
153+
headers: config.header,
154+
footers: config.footer,
155+
footerTexts: config.footerTextPaths,
156+
)
157+
];
151158
}
152159

153160
Uri _sdkFooterCopyrightUri;

test/dartdoc_test.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,5 @@ void main() {
364364
dart_bear.allClasses.map((cls) => cls.name).contains('Bear'), isTrue);
365365
expect(p.packageMap["Dart"].publicLibraries, hasLength(3));
366366
});
367-
368-
test('generate docs with unsupported format fails', () async {
369-
try {
370-
await buildDartdoc(['--format', 'bad'], testPackageOptions, tempDir);
371-
fail('dartdoc should fail on unsupported format');
372-
} catch (e) {
373-
expect(e is DartdocFailure, isTrue);
374-
}
375-
});
376367
}, timeout: new Timeout.factor(8));
377368
}

0 commit comments

Comments
 (0)