Skip to content

Commit

Permalink
Pre-compute missing documentation symbol before pruning the results. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos committed Nov 20, 2023
1 parent e9c0619 commit 2bfda1a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
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 a subset of the missing symbols.
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.

0 comments on commit 2bfda1a

Please sign in to comment.