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

Pre-compute missing documentation symbol before pruning the results. #1283

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Fix: limit number of documentation entries exported in `pub-data.json`.
- Fix: Add `dart:js_interop_unsafe` as a web library.
- Pre-compute missing documentation symbol before pruning the results.

## 0.21.42

Expand Down
6 changes: 2 additions & 4 deletions lib/src/dartdoc/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ Future<Subsection> createDocumentationCoverageSection(
PubDartdocData data) async {
final documented = data.coverage?.documented ?? 0;
final total = data.coverage?.total ?? 0;
final symbolsMissingDocumentation = data.apiElements
?.where((e) => e.documentation == null || e.documentation!.isEmpty)
.map((e) => e.name)
.toList();
final symbolsMissingDocumentation =
data.coverage?.symbolsMissingDocumentation;

final maxPoints = 10;
final ratio = total <= 0 ? 1.0 : documented / total;
Expand Down
7 changes: 7 additions & 0 deletions lib/src/dartdoc/index_to_pubdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ PubDartdocData dataFromDartdocIndex(DartdocIndex index) {
}

final documented = apiElements.where((e) => e.documentation != null).length;
final symbolsMissingDocumentation = apiElements
.where((e) => e.documentation == null)
.map((e) => e.name)
.take(5)
.toList();

if (documented > 1000) {
// Too much content, removing the documentation from everything except
// libraries and classes.
Expand All @@ -50,6 +56,7 @@ PubDartdocData dataFromDartdocIndex(DartdocIndex index) {
coverage: Coverage(
documented: documented,
total: apiElements.length,
symbolsMissingDocumentation: symbolsMissingDocumentation,
),
apiElements: apiElements,
);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/dartdoc/pub_dartdoc_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ class Coverage {
/// The number of API elements with accepted documentation.
final int documented;

/// Some of the API symbols that are without accepted documentation.
///
/// To limit the output size, we only store the a subset of the missing symbols.
isoos marked this conversation as resolved.
Show resolved Hide resolved
final List<String>? symbolsMissingDocumentation;

Coverage({
required this.total,
required this.documented,
required this.symbolsMissingDocumentation,
});

factory Coverage.fromJson(Map<String, dynamic> json) =>
Expand Down
24 changes: 20 additions & 4 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.