@@ -99,6 +99,9 @@ Future<void> main(List<String> args) async {
9999 final pkgDir = Directory (p.join (pkgDownloadDir.path, '$package -$version ' ));
100100 final detected = await _detectSdks (pkgDir.path);
101101
102+ final dartdocVersion =
103+ (await _overrideDartdocVersion (pkgDir.path)) ?? _dartdocVersion;
104+
102105 final toolEnv = await ToolEnvironment .create (
103106 dartSdkConfig: SdkConfig (
104107 rootPath: detected.dartSdkPath,
@@ -109,7 +112,7 @@ Future<void> main(List<String> args) async {
109112 configHomePath: _configHomePath ('flutter' , detected.configKind),
110113 ),
111114 pubCacheDir: pubCache,
112- dartdocVersion: _dartdocVersion ,
115+ dartdocVersion: dartdocVersion ,
113116 );
114117
115118 //final dartdocOutputDir =
@@ -191,6 +194,21 @@ String? _configHomePath(String sdk, String kind) {
191194 return path;
192195}
193196
197+ /// Detects the package dependencies and overrides the dartdoc version to
198+ /// 8.3.0 if macros is being used.
199+ ///
200+ /// TODO: remove this after the 3.6 SDK is released.
201+ Future <String ?> _overrideDartdocVersion (String pkgDir) async {
202+ final pubspecFile = File (p.join (pkgDir, 'pubspec.yaml' ));
203+ final pubspec = Pubspec .parseYaml (await pubspecFile.readAsString ());
204+ final minMacrosVersion = pubspec.getDependencyContraintRangeMin ('macros' );
205+ if (minMacrosVersion != null &&
206+ minMacrosVersion.compareTo (Version .parse ('0.1.3-main.0' )) >= 0 ) {
207+ return '8.3.0' ;
208+ }
209+ return null ;
210+ }
211+
194212Future <({String configKind, String ? dartSdkPath, String ? flutterSdkPath})>
195213 _detectSdks (String pkgDir) async {
196214 // Load the pubspec so we detect which SDK to use for analysis
0 commit comments