Skip to content

Commit ac4256e

Browse files
Merge main branch to NNBD (#2826)
* Refactor more documentation comment generation into DocumentationComment (#2817) * Straight move * Partial * delete experiment * rebuild * remove ??= from a cut and paste * Continuing the crushing down of documentation handling (#2818) * Straight move * Partial * delete experiment * rebuild * moved computeDocumentationComment and documentationComment * Move more documentation comment handling * remove ??= from a cut and paste * Documentation comment move for combos * better as a getter * Remove all deprecated bits in preparation for next release (#2821) * Remove all deprecated bits in preparation for next release * make some things final * documentationComment can now be non-nullable (#2819) * Straight move * Partial * delete experiment * rebuild * moved computeDocumentationComment and documentationComment * Move more documentation comment handling * remove ??= from a cut and paste * Documentation comment move for combos * better as a getter * Untangle synthetic combo documentation in preparing for non-null * rebuild * documentationComment can be made non-nullable * Update test.yaml to delete sdk check from beta branch * tab conversion error * correct name * Stop testing beta in the bots (#2824) * disable beta * try switching on stable * stable doesn't work for a lot of things now either :-( * try enabling the main bot * Change "dartfmt" -> "dart format". (#2822) Co-authored-by: Janice Collins <[email protected]> Co-authored-by: Bob Nystrom <[email protected]>
1 parent db236c1 commit ac4256e

23 files changed

+501
-555
lines changed

.github/workflows/test.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
sdk: [dev, beta]
22+
sdk: [dev, stable]
2323
job: [nnbd, flutter, sdk-analyzer, packages, sdk-docs]
2424
include:
2525
- os: macos-latest
@@ -32,10 +32,12 @@ jobs:
3232
# Do not try to run flutter against the "stable" sdk,
3333
# it is unlikely to work and produces uninteresting
3434
# results.
35-
- sdk: beta
35+
- sdk: stable
3636
job: flutter
37-
- sdk: beta
37+
- sdk: stable
3838
job: sdk-analyzer
39+
- sdk: stable
40+
job: sdk-docs
3941

4042
steps:
4143
- name: Store date

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ yet in the issue tracker, start by opening an issue. Thanks!
2424
2. When a change is user-facing, please add a new entry to the [changelog](https://github.com/dart-lang/dartdoc/blob/master/CHANGELOG.md)
2525
3. Please include a test for your change. `dartdoc` has both `package:test`-style unittests as well as integration tests. To run the unittests, use `grind test`.
2626
4. For major changes, run `grind compare-sdk-warnings` and `grind compare-flutter-warnings`, and include the summary results in your pull request.
27-
5. Be sure to format your Dart code using `dartfmt -w`, otherwise travis will complain.
27+
5. Be sure to format your Dart code using `dart format`, otherwise travis will complain.
2828
6. Use `grind presubmit` before creating a pull request to quickly check for common problems.
2929
7. Post your change via a pull request for review and integration!
3030

lib/dartdoc.dart

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,6 @@ class Dartdoc {
143143
// ignore: unnecessary_getters_setters
144144
set generator(Generator newGenerator) => _generator = newGenerator;
145145

146-
/// An asynchronous factory method that builds Dartdoc's file writers
147-
/// and returns a Dartdoc object with them.
148-
@Deprecated('Prefer fromContext() instead')
149-
static Future<Dartdoc> withDefaultGenerators(
150-
DartdocGeneratorOptionContext config,
151-
PackageBuilder packageBuilder,
152-
) async {
153-
return Dartdoc._(
154-
config,
155-
await initHtmlGenerator(config),
156-
packageBuilder,
157-
);
158-
}
159-
160146
/// Asynchronous factory method that builds Dartdoc with an empty generator.
161147
static Future<Dartdoc> withEmptyGenerator(
162148
DartdocOptionContext config,
@@ -195,15 +181,10 @@ class Dartdoc {
195181

196182
Stream<String> get onCheckProgress => _onCheckProgress.stream;
197183

198-
@Deprecated('Will be removed in 4.0.0. '
199-
'Use the return value from generateDocsBase instead.')
200-
PackageGraph packageGraph;
201-
202184
@visibleForTesting
203185
Future<DartdocResults> generateDocsBase() async {
204186
var stopwatch = Stopwatch()..start();
205187
var packageGraph = await packageBuilder.buildPackageGraph();
206-
this.packageGraph = packageGraph;
207188
var seconds = stopwatch.elapsedMilliseconds / 1000.0;
208189
var libs = packageGraph.libraries.length;
209190
logInfo("Initialized dartdoc with $libs librar${libs == 1 ? 'y' : 'ies'} "

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 179 additions & 117 deletions
Large diffs are not rendered by default.

lib/src/io_utils.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,6 @@ String getFileNameFor(String name) =>
106106
'${name.replaceAll(_libraryNameRegExp, '-')}.html';
107107

108108
final _libraryNameRegExp = RegExp('[.:]');
109-
@Deprecated('Public variable intended to be private; will be removed as early '
110-
'as Dartdoc 1.0.0')
111-
RegExp get libraryNameRegexp => _libraryNameRegExp;
112-
113-
@Deprecated('Public variable intended to be private; will be removed as early '
114-
'as Dartdoc 1.0.0')
115-
final RegExp partOfRegexp = RegExp('part of ');
116-
117-
@Deprecated('Public variable intended to be private; will be removed as early '
118-
'as Dartdoc 1.0.0')
119-
final RegExp newLinePartOfRegexp = RegExp('\npart of ');
120109

121110
typedef TaskQueueClosure<T> = Future<T> Function();
122111

lib/src/model/accessor.dart

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,57 @@ class Accessor extends ModelElement implements EnclosedElement {
7474
return _sourceCode;
7575
}
7676

77+
bool _documentationCommentComputed = false;
78+
String _documentationComment;
7779
@override
78-
String computeDocumentationComment() {
79-
String docComment;
80-
if (isSynthetic) {
81-
// If we're a setter, only display something if we have something different than the getter.
82-
// TODO(jcollins-g): modify analyzer to do this itself?
83-
if (isGetter ||
84-
definingCombo.hasNodoc ||
85-
(isSetter &&
86-
definingCombo.hasGetter &&
87-
definingCombo.getter.documentationComment !=
88-
definingCombo.documentationComment)) {
89-
docComment = definingCombo.documentationComment;
90-
} else {
91-
docComment = '';
80+
String get documentationComment => _documentationCommentComputed
81+
? _documentationComment
82+
: _documentationComment ??= () {
83+
_documentationCommentComputed = true;
84+
if (isSynthetic) {
85+
return _syntheticDocumentationComment;
86+
}
87+
return stripComments(super.documentationComment);
88+
}();
89+
90+
String /*!*/ __syntheticDocumentationComment;
91+
92+
/// Build a documentation comment for this accessor assuming it is synthetic.
93+
/// Value here is not useful if [isSynthetic] is false.
94+
String /*!*/ get _syntheticDocumentationComment =>
95+
__syntheticDocumentationComment ??= () {
96+
if (_hasSyntheticDocumentationComment) {
97+
return definingCombo.documentationComment ?? '';
98+
}
99+
return '';
100+
}();
101+
102+
/// If this is a getter, assume we want synthetic documentation.
103+
/// If the definingCombo has a nodoc tag, we want synthetic documentation
104+
/// for a synthetic accessor just in case it is inherited somewhere
105+
/// down the line due to split inheritance.
106+
bool get _hasSyntheticDocumentationComment =>
107+
(isGetter || definingCombo.hasNodoc || _comboDocsAreIndependent()) &&
108+
definingCombo.hasDocumentationComment;
109+
110+
// If we're a setter, and a getter exists, do not add synthetic
111+
// documentation if the combo's documentation is actually derived
112+
// from that getter.
113+
bool _comboDocsAreIndependent() {
114+
if (isSetter && definingCombo.hasGetter) {
115+
if (definingCombo.getter.isSynthetic ||
116+
!definingCombo.documentationFrom.contains(this)) {
117+
return true;
92118
}
93-
} else {
94-
docComment = super.computeDocumentationComment();
95-
}
96-
if (docComment != null) {
97-
return stripComments(docComment);
98119
}
99-
return null;
120+
return false;
100121
}
101122

123+
@override
124+
bool get hasDocumentationComment => isSynthetic
125+
? _hasSyntheticDocumentationComment
126+
: element.documentationComment != null;
127+
102128
@override
103129
void warn(
104130
PackageWarning kind, {

lib/src/model/canonicalization.dart

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class Canonicalization implements Locatable, Documentable {
2828
}
2929

3030
ScoredCandidate _scoreElementWithLibrary(Library lib) {
31-
var scoredCandidate = ScoredCandidate(this, lib);
31+
var scoredCandidate = ScoredCandidate(lib);
3232
Iterable<String> resplit(Set<String> items) sync* {
3333
for (var item in items) {
3434
for (var subItem in item.split('_')) {
@@ -72,44 +72,20 @@ abstract class Canonicalization implements Locatable, Documentable {
7272
scoreBoost, 'element location parts start with parts of name');
7373
return scoredCandidate;
7474
}
75-
76-
@Deprecated(
77-
'Public method intended to be private; will be removed as early as '
78-
'Dartdoc 1.0.0')
79-
ScoredCandidate scoreElementWithLibrary(Library lib) =>
80-
_scoreElementWithLibrary(lib);
8175
}
8276

8377
/// This class represents the score for a particular element; how likely
8478
/// it is that this is the canonical element.
8579
class ScoredCandidate implements Comparable<ScoredCandidate> {
8680
final List<String> _reasons = [];
8781

88-
@Deprecated(
89-
'Public field intended to be private; will be removed as early as '
90-
'Dartdoc 1.0.0')
91-
List<String> get reasons => _reasons;
92-
93-
@Deprecated(
94-
'Public field intended to be private; will be removed as early as '
95-
'Dartdoc 1.0.0')
96-
set reasons(List<String> value) => reasons = value;
97-
98-
/// The canonicalization element being scored.
99-
final Canonicalization _element;
100-
101-
@Deprecated(
102-
'Public getter intended to be private; will be removed as early as '
103-
'Dartdoc 1.0.0')
104-
Canonicalization get element => _element;
105-
10682
final Library library;
10783

10884
/// The score accumulated so far. Higher means it is more likely that this
10985
/// is the intended canonical Library.
11086
double score = 0.0;
11187

112-
ScoredCandidate(this._element, this.library);
88+
ScoredCandidate(this.library);
11389

11490
void _alterScore(double scoreDelta, String reason) {
11591
score += scoreDelta;
@@ -119,12 +95,6 @@ class ScoredCandidate implements Comparable<ScoredCandidate> {
11995
}
12096
}
12197

122-
@Deprecated(
123-
'Public method intended to be private; will be removed as early as '
124-
'Dartdoc 1.0.0')
125-
void alterScore(double scoreDelta, String reason) =>
126-
_alterScore(scoreDelta, reason);
127-
12898
@override
12999
int compareTo(ScoredCandidate other) {
130100
//assert(element == other.element);

lib/src/model/categorization.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ final RegExp _categoryRegExp = RegExp(
1010
r'[ ]*{@(api|category|subCategory|image|samples) (.+?)}[ ]*\n?',
1111
multiLine: true);
1212

13-
@Deprecated('Public variable intended to be private; will be removed as early '
14-
'as Dartdoc 1.0.0')
15-
RegExp get categoryRegexp => _categoryRegExp;
16-
1713
/// Mixin implementing dartdoc categorization for ModelElements.
1814
abstract class Categorization implements ModelElement {
1915
@override

lib/src/model/category.dart

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,18 @@ class Category extends Nameable
2727
Indexable
2828
implements Documentable {
2929
/// All libraries in [libraries] must come from [package].
30-
// TODO(srawlins): To make final, remove public getter, setter, rename to be
31-
// public, and add `final` modifier.
32-
Package _package;
30+
final Package _package;
3331

3432
@override
3533
Package get package => _package;
3634

37-
@Deprecated('Field intended to be final; setter will be removed as early as '
38-
'Dartdoc 1.0.0')
39-
set package(Package value) => _package = value;
40-
4135
final String _name;
4236

43-
// TODO(srawlins): To make final, remove public getter, setter, rename to be
44-
// public, and add `final` modifier.
45-
DartdocOptionContext _config;
37+
final DartdocOptionContext _config;
4638

4739
@override
4840
DartdocOptionContext get config => _config;
4941

50-
@Deprecated('Field intended to be final; setter will be removed as early as '
51-
'Dartdoc 1.0.0')
52-
set config(DartdocOptionContext value) => _config = value;
53-
5442
final Set<Categorization> _allItems = {};
5543

5644
final List<Class> _classes = [];
@@ -142,11 +130,6 @@ class Category extends Nameable
142130

143131
String get _fileType => package.fileType;
144132

145-
@Deprecated(
146-
'Public field intended to be private; will be removed as early as '
147-
'Dartdoc 1.0.0')
148-
String get fileType => _fileType;
149-
150133
String get filePath => 'topics/$name-topic.$_fileType';
151134

152135
@override

lib/src/model/container_member.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ mixin ContainerMember on ModelElement implements EnclosedElement {
7575
// TODO(jcollins-g): split Field documentation up between accessors
7676
// and resolve the pieces with different scopes. dart-lang/dartdoc#2693.
7777
// Until then, just pretend we're handling this correctly.
78-
yield documentationFrom.first.definingLibrary;
78+
yield (documentationFrom.first as ModelElement).definingLibrary;
7979
// TODO(jcollins-g): Wean users off of depending on canonical library
8080
// resolution. dart-lang/dartdoc#2696
8181
if (canonicalLibrary != null) yield canonicalLibrary;

0 commit comments

Comments
 (0)