Skip to content

Commit

Permalink
Deprecate the use of 'kind' in pub-data.json. (#1292)
Browse files Browse the repository at this point in the history
* Deprecate the use of 'kind' in pub-data.json.

* Remove fixed dartdoc version from end2end tests.

* Updated end2end tests.
  • Loading branch information
isoos committed Dec 8, 2023
1 parent 288df51 commit cc52123
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## 0.21.44

- Fix: `dart:ui_web` is now part of the SDK-detection library list.
- The use of `kind` in `pub-data.json` is deprecated, as it may contain
different value on different `dartdoc` version. The field may be
removed in a future version.

## 0.21.43

Expand Down
1 change: 1 addition & 0 deletions lib/src/dartdoc/dartdoc_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:json_annotation/json_annotation.dart';
part 'dartdoc_index.g.dart';

// TODO(https://github.com/dart-lang/pana/issues/1273): remove these and use a different pub-data.json file format.
@Deprecated('Do not use, will be removed.')
const kindNames = <int, String>{
0: 'accessor',
1: 'constant',
Expand Down
4 changes: 2 additions & 2 deletions lib/src/dartdoc/index_to_pubdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PubDartdocData dataFromDartdocIndex(DartdocIndex index) {
}
final apiElements = <ApiElement>[];
for (final e in entries) {
final kind = kindNames[e.kind!]!;
final kind = e.kind == null ? null : kindNames[e.kind!];
final showHref = e.isLibrary || e.isClass;
final parent = hrefToQualifiedNames[e.enclosedBy?.href ?? ''];
apiElements.add(ApiElement(
Expand All @@ -48,7 +48,7 @@ PubDartdocData dataFromDartdocIndex(DartdocIndex index) {
// Too much content, removing the documentation from everything except
// libraries and classes.
apiElements
.where((e) => e.kind != 'library' && e.kind != 'class')
.where((e) => !e.isLibrary && !e.isClass)
.forEach((e) => e.documentation = null);
}

Expand Down
7 changes: 6 additions & 1 deletion lib/src/dartdoc/pub_dartdoc_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class PubDartdocData {
class ApiElement {
/// The last part of the [qualifiedName].
final String name;
final String kind;
@Deprecated('Do not use, will be removed.')
final String? kind;
final String? parent;
final String? source;
final String? href;
Expand All @@ -53,6 +54,10 @@ class ApiElement {
Map<String, dynamic> toJson() => _$ApiElementToJson(this);

String get qualifiedName => parent == null ? name : '$parent.$name';

/// Wether the entry is a top-level library.
late final isLibrary = href != null && href!.endsWith('-library.html');
late final isClass = href != null && href!.endsWith('-class.html');
}

/// The documentation coverage numbers and the derived scores.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/dartdoc/pub_dartdoc_data.g.dart

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

1 change: 0 additions & 1 deletion test/end2end_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void main() {
pubCacheDir: pubCacheDir,
panaCacheDir: panaCacheDir,
pubHostedUrl: 'http://127.0.0.1:${httpServer.port}',
globalDartdocVersion: '7.0.0',
);
});

Expand Down
2 changes: 1 addition & 1 deletion test/goldens/end2end/url_launcher-6.1.12.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"grantedPoints": 20,
"maxPoints": 20,
"status": "passed",
"summary": "### [*] 10/10 points: 20% or more of the public API has dartdoc comments\n\n29 out of 33 API elements (87.9 %) have documentation comments.\n\nSome symbols that are missing documentation: `link`, `url_launcher`, `url_launcher_string`, `LaunchMode`.\n\n### [*] 10/10 points: Package has an example\n"
"summary": "### [*] 10/10 points: 20% or more of the public API has dartdoc comments\n\n29 out of 33 API elements (87.9 %) have documentation comments.\n\nSome symbols that are missing documentation: `link`, `url_launcher`, `LaunchMode`, `url_launcher_string`.\n\n### [*] 10/10 points: Package has an example\n"
},
{
"id": "platform",
Expand Down
2 changes: 1 addition & 1 deletion test/goldens/end2end/url_launcher-6.1.12.json_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Detected license: `BSD-3-Clause`.

29 out of 33 API elements (87.9 %) have documentation comments.

Some symbols that are missing documentation: `link`, `url_launcher`, `url_launcher_string`, `LaunchMode`.
Some symbols that are missing documentation: `link`, `url_launcher`, `LaunchMode`, `url_launcher_string`.

### [*] 10/10 points: Package has an example

Expand Down

0 comments on commit cc52123

Please sign in to comment.