@@ -20,6 +20,7 @@ import 'dart:io';
20
20
import 'package:analyzer/dart/element/element.dart' ;
21
21
import 'package:args/args.dart' ;
22
22
import 'package:dartdoc/dartdoc.dart' ;
23
+ import 'package:dartdoc/src/experiment_options.dart' ;
23
24
import 'package:dartdoc/src/io_utils.dart' ;
24
25
import 'package:dartdoc/src/tool_runner.dart' ;
25
26
import 'package:dartdoc/src/tuple.dart' ;
@@ -489,8 +490,8 @@ abstract class DartdocOption<T> {
489
490
/// and requires that one of [isDir] or [isFile] is set.
490
491
final bool mustExist;
491
492
492
- DartdocOption ._ (this .name, this .defaultsTo, this .help, this .isDir,
493
- this .isFile, this . mustExist, this ._convertYamlToType) {
493
+ DartdocOption (this .name, this .defaultsTo, this .help, this .isDir, this .isFile ,
494
+ this .mustExist, this ._convertYamlToType) {
494
495
assert (! (isDir && isFile));
495
496
if (isDir || isFile) assert (_isString || _isListString || _isMapString);
496
497
if (mustExist) {
@@ -674,7 +675,7 @@ class DartdocOptionFileSynth<T> extends DartdocOption<T>
674
675
bool isFile = false ,
675
676
bool parentDirOverridesChild,
676
677
T Function (YamlMap , pathLib.Context ) convertYamlToType})
677
- : super ._ (name, null , help, isDir, isFile, mustExist, convertYamlToType) {
678
+ : super (name, null , help, isDir, isFile, mustExist, convertYamlToType) {
678
679
_parentDirOverridesChild = parentDirOverridesChild;
679
680
}
680
681
@@ -721,7 +722,7 @@ class DartdocOptionArgSynth<T> extends DartdocOption<T>
721
722
bool isFile = false ,
722
723
bool negatable = false ,
723
724
bool splitCommas})
724
- : super ._ (name, null , help, isDir, isFile, mustExist, null ) {
725
+ : super (name, null , help, isDir, isFile, mustExist, null ) {
725
726
_hide = hide;
726
727
_negatable = negatable;
727
728
_splitCommas = splitCommas;
@@ -767,7 +768,7 @@ class DartdocOptionSyntheticOnly<T> extends DartdocOption<T>
767
768
String help = '' ,
768
769
bool isDir = false ,
769
770
bool isFile = false })
770
- : super ._ (name, null , help, isDir, isFile, mustExist, null );
771
+ : super (name, null , help, isDir, isFile, mustExist, null );
771
772
}
772
773
773
774
abstract class DartdocSyntheticOption <T > implements DartdocOption <T > {
@@ -801,7 +802,7 @@ typedef Future<List<DartdocOption>> OptionGenerator();
801
802
/// A [DartdocOption] that only contains other [DartdocOption] s and is not an option itself.
802
803
class DartdocOptionSet extends DartdocOption <Null > {
803
804
DartdocOptionSet (String name)
804
- : super ._ (name, null , null , false , false , false , null );
805
+ : super (name, null , null , false , false , false , null );
805
806
806
807
/// Asynchronous factory that is the main entry point to initialize Dartdoc
807
808
/// options for use.
@@ -852,7 +853,7 @@ class DartdocOptionArgOnly<T> extends DartdocOption<T>
852
853
bool isFile = false ,
853
854
bool negatable = false ,
854
855
bool splitCommas})
855
- : super ._ (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
856
+ : super (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
856
857
_hide = hide;
857
858
_negatable = negatable;
858
859
_splitCommas = splitCommas;
@@ -888,7 +889,7 @@ class DartdocOptionArgFile<T> extends DartdocOption<T>
888
889
bool negatable = false ,
889
890
bool parentDirOverridesChild: false ,
890
891
bool splitCommas})
891
- : super ._ (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
892
+ : super (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
892
893
_abbr = abbr;
893
894
_hide = hide;
894
895
_negatable = negatable;
@@ -938,7 +939,7 @@ class DartdocOptionFileOnly<T> extends DartdocOption<T>
938
939
bool isFile = false ,
939
940
bool parentDirOverridesChild: false ,
940
941
T Function (YamlMap , pathLib.Context ) convertYamlToType})
941
- : super ._ (name, defaultsTo, help, isDir, isFile, mustExist,
942
+ : super (name, defaultsTo, help, isDir, isFile, mustExist,
942
943
convertYamlToType) {
943
944
_parentDirOverridesChild = parentDirOverridesChild;
944
945
}
@@ -1258,12 +1259,22 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
1258
1259
}
1259
1260
}
1260
1261
1262
+ /// All DartdocOptionContext mixins should implement this, as well as any other
1263
+ /// DartdocOptionContext mixins they use for calculating synthetic options.
1264
+ abstract class DartdocOptionContextBase {
1265
+ DartdocOptionSet get optionSet;
1266
+ Directory get context;
1267
+ }
1268
+
1261
1269
/// An [DartdocOptionSet] wrapped in nice accessors specific to Dartdoc, which
1262
1270
/// automatically passes in the right directory for a given context. Usually,
1263
1271
/// a single [ModelElement] , [Package] , [Category] and so forth has a single context
1264
1272
/// and so this can be made a member variable of those structures.
1265
- class DartdocOptionContext {
1273
+ class DartdocOptionContext extends DartdocOptionContextBase
1274
+ with DartdocExperimentOptionContext {
1275
+ @override
1266
1276
final DartdocOptionSet optionSet;
1277
+ @override
1267
1278
Directory context;
1268
1279
1269
1280
// TODO(jcollins-g): Allow passing in structured data to initialize a
@@ -1561,5 +1572,7 @@ Future<List<DartdocOption>> createDartdocOptions() async {
1561
1572
'exist. Executables for different platforms are specified by '
1562
1573
'giving the platform name as a key, and a list of strings as the '
1563
1574
'command.' ),
1564
- ];
1575
+ // TODO(jcollins-g): refactor so there is a single static "create" for
1576
+ // each DartdocOptionContext that traverses the inheritance tree itself.
1577
+ ]..addAll (await createExperimentOptions ());
1565
1578
}
0 commit comments