Skip to content

Commit f7c85d0

Browse files
authored
Support top level declarations with templates (#1984)
* Support top level declarations with templates * Add a comment
1 parent 91aee23 commit f7c85d0

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

lib/src/model.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4912,6 +4912,12 @@ class PackageGraph {
49124912
!precachedElements.contains(d)) {
49134913
precachedElements.add(d);
49144914
yield d._precacheLocalDocs();
4915+
// TopLevelVariables get their documentation from getters and setters,
4916+
// so should be precached if either has a template.
4917+
if (m is TopLevelVariable) {
4918+
precachedElements.add(m);
4919+
yield m._precacheLocalDocs();
4920+
}
49154921
}
49164922
}
49174923
}

test/model_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
30953095
});
30963096

30973097
test('found five properties', () {
3098-
expect(exLibrary.publicProperties, hasLength(5));
3098+
expect(exLibrary.publicProperties, hasLength(7));
30993099
});
31003100

31013101
test('linked return type is a double', () {

testing/test_package/lib/example.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ const incorrectDocReference = 'same name as const from fake';
3131
/// This should [not work].
3232
const incorrectDocReferenceFromEx = 'doh';
3333

34+
/// top level declarations with templates/macros
35+
///
36+
/// {@template ex1}
37+
/// ex2 macro content
38+
/// {@endtemplate}
39+
int myNumber = 3;
40+
41+
/// {@macro ex1}
42+
void testMacro() {}
43+
44+
/// {@template ex2}
45+
/// ex2 macro content
46+
/// {@endtemplate}
47+
bool get isCheck => true;
48+
49+
3450
/// A custom annotation.
3551
class aThingToDo {
3652
final String who;

0 commit comments

Comments
 (0)