@@ -842,12 +842,25 @@ class DartdocOptionContext {
842842 // ignore: unused_element
843843 String get _input => optionSet['input' ].valueAt (context);
844844 String get inputDir => optionSet['inputDir' ].valueAt (context);
845+ bool get linkToExternal => optionSet['linkTo' ]['external' ].valueAt (context);
846+ String get linkToExternalUrl =>
847+ optionSet['linkTo' ]['externalUrl' ].valueAt (context);
848+
849+ /// _linkToHosted is only used to construct synthetic options.
850+ // ignore: unused_element
851+ String get _linkToHosted => optionSet['linkTo' ]['hosted' ].valueAt (context);
852+
853+ /// _linkToUrl is only used to construct synthetic options.
854+ // ignore: unused_element
855+ String get _linkToUrl => optionSet['linkTo' ]['url' ].valueAt (context);
845856 String get output => optionSet['output' ].valueAt (context);
846- List <String > get packageOrder => optionSet['packageOrder' ].valueAt (context);
847857 PackageMeta get packageMeta => optionSet['packageMeta' ].valueAt (context);
858+ List <String > get packageOrder => optionSet['packageOrder' ].valueAt (context);
848859 bool get sdkDocs => optionSet['sdkDocs' ].valueAt (context);
849860 String get sdkDir => optionSet['sdkDir' ].valueAt (context);
850861 bool get showWarnings => optionSet['showWarnings' ].valueAt (context);
862+ PackageMeta get topLevelPackageMeta =>
863+ optionSet['topLevelPackageMeta' ].valueAt (context);
851864 bool get useCategories => optionSet['useCategories' ].valueAt (context);
852865 bool get validateLinks => optionSet['validateLinks' ].valueAt (context);
853866 bool get verboseWarnings => optionSet['verboseWarnings' ].valueAt (context);
@@ -936,9 +949,59 @@ Future<List<DartdocOption>> createDartdocOptions() async {
936949 help: 'Path to source directory (with override if --sdk-docs)' ,
937950 isDir: true ,
938951 mustExist: true ),
952+ new DartdocOptionSet ('linkTo' )
953+ ..addAll ([
954+ new DartdocOptionArgOnly <bool >('external' , false ,
955+ help: 'Allow links to be generated for packages outside this one.' ,
956+ negatable: true ),
957+ new DartdocOptionSynthetic <String >('externalUrl' ,
958+ (DartdocOptionSynthetic option, Directory dir) {
959+ String url = option.parent['url' ].valueAt (dir);
960+ if (url != null ) {
961+ return url;
962+ }
963+ String hostedAt =
964+ option.parent.parent['packageMeta' ].valueAt (dir).hostedAt;
965+ if (hostedAt != null ) {
966+ Map <String , String > hostMap = option.parent['hosted' ].valueAt (dir);
967+ if (hostMap.containsKey (hostedAt)) return hostMap[hostedAt];
968+ }
969+ return '' ;
970+ }, help: 'Url to use for this particular package.' ),
971+ new DartdocOptionArgOnly <Map <String , String >>(
972+ 'hosted' ,
973+ {
974+ 'pub.dartlang.org' :
975+ 'https://pub.dartlang.org/documentation/%n%/%v%'
976+ },
977+ help: 'Specify URLs for hosted pub packages' ),
978+ new DartdocOptionFileOnly <String >('url' , null ,
979+ help: 'Use external linkage for this package, with this base url' ),
980+ ]),
939981 new DartdocOptionArgOnly <String >('output' , pathLib.join ('doc' , 'api' ),
940982 isDir: true , help: 'Path to output directory.' ),
941- new DartdocOptionSynthetic <PackageMeta >('packageMeta' ,
983+ new DartdocOptionSynthetic <PackageMeta >(
984+ 'packageMeta' ,
985+ (DartdocOptionSynthetic option, Directory dir) {
986+ PackageMeta packageMeta = new PackageMeta .fromDir (dir);
987+ if (packageMeta == null ) {
988+ throw new DartdocOptionError (
989+ 'Unable to determine package for directory: ${dir .path }' );
990+ }
991+ return packageMeta;
992+ },
993+ ),
994+ new DartdocOptionArgOnly <List <String >>('packageOrder' , [],
995+ help:
996+ 'A list of package names to place first when grouping libraries in packages. '
997+ 'Unmentioned categories are sorted after these.' ),
998+ new DartdocOptionArgOnly <bool >('sdkDocs' , false ,
999+ help: 'Generate ONLY the docs for the Dart SDK.' , negatable: false ),
1000+ new DartdocOptionArgOnly <String >('sdkDir' , defaultSdkDir.absolute.path,
1001+ help: 'Path to the SDK directory.' , isDir: true , mustExist: true ),
1002+ new DartdocOptionArgOnly <bool >('showWarnings' , false ,
1003+ help: 'Display all warnings.' , negatable: false ),
1004+ new DartdocOptionSynthetic <PackageMeta >('topLevelPackageMeta' ,
9421005 (DartdocOptionSynthetic option, Directory dir) {
9431006 PackageMeta packageMeta = new PackageMeta .fromDir (
9441007 new Directory (option.parent['inputDir' ].valueAt (dir)));
@@ -952,16 +1015,6 @@ Future<List<DartdocOption>> createDartdocOptions() async {
9521015 }
9531016 return packageMeta;
9541017 }, help: 'PackageMeta object for the default package.' ),
955- new DartdocOptionArgOnly <List <String >>('packageOrder' , [],
956- help:
957- 'A list of package names to place first when grouping libraries in packages. '
958- 'Unmentioned categories are sorted after these.' ),
959- new DartdocOptionArgOnly <bool >('sdkDocs' , false ,
960- help: 'Generate ONLY the docs for the Dart SDK.' , negatable: false ),
961- new DartdocOptionArgOnly <String >('sdkDir' , defaultSdkDir.absolute.path,
962- help: 'Path to the SDK directory' , isDir: true , mustExist: true ),
963- new DartdocOptionArgOnly <bool >('showWarnings' , false ,
964- help: 'Display all warnings.' , negatable: false ),
9651018 new DartdocOptionArgOnly <bool >('useCategories' , true ,
9661019 help: 'Display categories in the sidebar of packages' ,
9671020 negatable: false ),
0 commit comments