Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambigious dartdoc version value when unspecified. #1343

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.22.1

- Fix: unspecified `--dartdoc-version` will use the latest version in an isolated
environment. To use the SDK's `dartdoc`, set the value to `sdk`.

## 0.22.0

- `ToolEnvironment`:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ Options:
--hosted Download and analyze a hosted package (from https://pub.dev).
--[no-]dartdoc Run dartdoc and score the package on documentation coverage.
(defaults to on)
--dartdoc-version The dartdoc version to use (otherwise the latest stable).
--dartdoc-version The dartdoc version to use: `sdk`, `latest` (default) or `<version constraint>`.
```
3 changes: 2 additions & 1 deletion bin/pana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ final _parser = ArgParser()
)
..addOption(
'dartdoc-version',
help: 'The dartdoc version to use (otherwise the latest stable).',
help:
'The dartdoc version to use: `sdk`, `latest` (default) or `<version constraint>`.',
)
..addOption(
'resources-output',
Expand Down
27 changes: 12 additions & 15 deletions lib/src/sdk_env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,16 @@ class ToolEnvironment {
if (sdkDir != null) ...['--sdk-dir', sdkDir],
];

PanaProcessResult pr;

if (_dartdocVersion != null) {
if (_dartdocVersion == 'sdk') {
final command =
usesFlutter ? _flutterSdk._dartSdk.dartCmd : _dartSdk.dartCmd;
return await runConstrained(
[...command, 'doc', ...args],
workingDirectory: packageDir,
environment: _dartSdk.environment,
timeout: timeout,
);
} else {
if (!_globalDartdocActivated) {
await runConstrained(
[
Expand All @@ -464,7 +471,7 @@ class ToolEnvironment {
'global',
'activate',
'dartdoc',
_dartdocVersion!,
if (_dartdocVersion != null) _dartdocVersion!,
],
environment: {
..._dartSdk.environment,
Expand All @@ -475,24 +482,14 @@ class ToolEnvironment {
_globalDartdocActivated = true;
}
final command = usesFlutter ? _flutterSdk.flutterCmd : _dartSdk.dartCmd;
pr = await runConstrained(
return await runConstrained(
[...command, 'pub', 'global', 'run', 'dartdoc', ...args],
workingDirectory: packageDir,
environment:
usesFlutter ? _flutterSdk.environment : _dartSdk.environment,
timeout: timeout,
);
} else {
final command =
usesFlutter ? _flutterSdk._dartSdk.dartCmd : _dartSdk.dartCmd;
pr = await runConstrained(
[...command, 'doc', ...args],
workingDirectory: packageDir,
environment: _dartSdk.environment,
timeout: timeout,
);
}
return pr;
}

/// Removes the `dev_dependencies` from the `pubspec.yaml`,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pana
description: PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.
version: 0.22.0
version: 0.22.1
repository: https://github.com/dart-lang/pana
topics:
- tool
Expand Down
2 changes: 1 addition & 1 deletion test/goldens/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Options:
--hosted Download and analyze a hosted package (from https://pub.dev).
--[no-]dartdoc Run dartdoc and score the package on documentation coverage.
(defaults to on)
--dartdoc-version The dartdoc version to use (otherwise the latest stable).
--dartdoc-version The dartdoc version to use: `sdk`, `latest` (default) or `<version constraint>`.