@@ -20,6 +20,7 @@ import 'dart:io';
2020import 'package:analyzer/dart/element/element.dart' ;
2121import 'package:args/args.dart' ;
2222import 'package:dartdoc/dartdoc.dart' ;
23+ import 'package:dartdoc/src/experiment_options.dart' ;
2324import 'package:dartdoc/src/io_utils.dart' ;
2425import 'package:dartdoc/src/tool_runner.dart' ;
2526import 'package:dartdoc/src/tuple.dart' ;
@@ -489,8 +490,8 @@ abstract class DartdocOption<T> {
489490 /// and requires that one of [isDir] or [isFile] is set.
490491 final bool mustExist;
491492
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) {
494495 assert (! (isDir && isFile));
495496 if (isDir || isFile) assert (_isString || _isListString || _isMapString);
496497 if (mustExist) {
@@ -674,7 +675,7 @@ class DartdocOptionFileSynth<T> extends DartdocOption<T>
674675 bool isFile = false ,
675676 bool parentDirOverridesChild,
676677 T Function (YamlMap , pathLib.Context ) convertYamlToType})
677- : super ._ (name, null , help, isDir, isFile, mustExist, convertYamlToType) {
678+ : super (name, null , help, isDir, isFile, mustExist, convertYamlToType) {
678679 _parentDirOverridesChild = parentDirOverridesChild;
679680 }
680681
@@ -721,7 +722,7 @@ class DartdocOptionArgSynth<T> extends DartdocOption<T>
721722 bool isFile = false ,
722723 bool negatable = false ,
723724 bool splitCommas})
724- : super ._ (name, null , help, isDir, isFile, mustExist, null ) {
725+ : super (name, null , help, isDir, isFile, mustExist, null ) {
725726 _hide = hide;
726727 _negatable = negatable;
727728 _splitCommas = splitCommas;
@@ -767,7 +768,7 @@ class DartdocOptionSyntheticOnly<T> extends DartdocOption<T>
767768 String help = '' ,
768769 bool isDir = false ,
769770 bool isFile = false })
770- : super ._ (name, null , help, isDir, isFile, mustExist, null );
771+ : super (name, null , help, isDir, isFile, mustExist, null );
771772}
772773
773774abstract class DartdocSyntheticOption <T > implements DartdocOption <T > {
@@ -801,7 +802,7 @@ typedef Future<List<DartdocOption>> OptionGenerator();
801802/// A [DartdocOption] that only contains other [DartdocOption] s and is not an option itself.
802803class DartdocOptionSet extends DartdocOption <Null > {
803804 DartdocOptionSet (String name)
804- : super ._ (name, null , null , false , false , false , null );
805+ : super (name, null , null , false , false , false , null );
805806
806807 /// Asynchronous factory that is the main entry point to initialize Dartdoc
807808 /// options for use.
@@ -852,7 +853,7 @@ class DartdocOptionArgOnly<T> extends DartdocOption<T>
852853 bool isFile = false ,
853854 bool negatable = false ,
854855 bool splitCommas})
855- : super ._ (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
856+ : super (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
856857 _hide = hide;
857858 _negatable = negatable;
858859 _splitCommas = splitCommas;
@@ -888,7 +889,7 @@ class DartdocOptionArgFile<T> extends DartdocOption<T>
888889 bool negatable = false ,
889890 bool parentDirOverridesChild: false ,
890891 bool splitCommas})
891- : super ._ (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
892+ : super (name, defaultsTo, help, isDir, isFile, mustExist, null ) {
892893 _abbr = abbr;
893894 _hide = hide;
894895 _negatable = negatable;
@@ -938,7 +939,7 @@ class DartdocOptionFileOnly<T> extends DartdocOption<T>
938939 bool isFile = false ,
939940 bool parentDirOverridesChild: false ,
940941 T Function (YamlMap , pathLib.Context ) convertYamlToType})
941- : super ._ (name, defaultsTo, help, isDir, isFile, mustExist,
942+ : super (name, defaultsTo, help, isDir, isFile, mustExist,
942943 convertYamlToType) {
943944 _parentDirOverridesChild = parentDirOverridesChild;
944945 }
@@ -1258,12 +1259,22 @@ abstract class _DartdocArgOption<T> implements DartdocOption<T> {
12581259 }
12591260}
12601261
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+
12611269/// An [DartdocOptionSet] wrapped in nice accessors specific to Dartdoc, which
12621270/// automatically passes in the right directory for a given context. Usually,
12631271/// a single [ModelElement] , [Package] , [Category] and so forth has a single context
12641272/// 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
12661276 final DartdocOptionSet optionSet;
1277+ @override
12671278 Directory context;
12681279
12691280 // TODO(jcollins-g): Allow passing in structured data to initialize a
@@ -1561,5 +1572,7 @@ Future<List<DartdocOption>> createDartdocOptions() async {
15611572 'exist. Executables for different platforms are specified by '
15621573 'giving the platform name as a key, and a list of strings as the '
15631574 '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 ());
15651578}
0 commit comments