Skip to content

Commit d7bf682

Browse files
committed
fix linking to typedefs, add tests
1 parent 8b4d154 commit d7bf682

36 files changed

+1821
-1575
lines changed

lib/src/model.dart

Lines changed: 1474 additions & 1472 deletions
Large diffs are not rendered by default.

test/model_test.dart

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ library dartdoc.model_test;
77
import 'dart:io';
88

99
import 'package:cli_util/cli_util.dart' as cli_util;
10+
import 'package:dartdoc/src/config.dart';
1011
import 'package:dartdoc/src/model.dart';
1112
import 'package:dartdoc/src/model_utils.dart';
1213
import 'package:dartdoc/src/package_meta.dart';
13-
import 'package:dartdoc/src/config.dart';
1414
import 'package:test/test.dart';
1515

1616
import 'src/utils.dart' as utils;
@@ -392,12 +392,17 @@ void main() {
392392

393393
test('no references', () {
394394
expect(
395-
Apple.documentationAsHtml, '<p>Sample class <code>String</code></p>');
395+
Apple.documentationAsHtml,
396+
'<p>Sample class <code>String</code></p><pre class="prettyprint lang-dart"> A\n'
397+
' B\n'
398+
'</pre>');
396399
});
397400

398401
test('single ref to class', () {
399-
expect(B.documentationAsHtml,
400-
'<p>Extends class <a href="ex/Apple-class.html">Apple</a>, use <a href="ex/Apple/Apple.html">new Apple</a> or <a href="ex/Apple/Apple.fromString.html">new Apple.fromString</a></p>');
402+
expect(
403+
B.documentationAsHtml.contains(
404+
'<p>Extends class <a href="ex/Apple-class.html">Apple</a>, use <a href="ex/Apple/Apple.html">new Apple</a> or <a href="ex/Apple/Apple.fromString.html">new Apple.fromString</a></p>'),
405+
isTrue);
401406
});
402407

403408
test('doc ref to class in SDK does not render as link', () {
@@ -579,7 +584,7 @@ void main() {
579584
});
580585

581586
test('inherited methods,including from Object ', () {
582-
expect(B.inheritedMethods, hasLength(5));
587+
expect(B.inheritedMethods, hasLength(6));
583588
expect(B.hasInheritedMethods, isTrue);
584589
});
585590

@@ -1323,7 +1328,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
13231328

13241329
group('Parameter', () {
13251330
Class c, fClass;
1326-
Method isGreaterThan, asyncM, methodWithGenericParam, paramFromExportLib;
1331+
Method isGreaterThan,
1332+
asyncM,
1333+
methodWithGenericParam,
1334+
paramFromExportLib,
1335+
methodWithTypedefParam;
13271336
Parameter intNumber, intCheckOptional;
13281337

13291338
setUp(() {
@@ -1341,6 +1350,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
13411350
fClass = exLibrary.classes.firstWhere((c) => c.name == 'F');
13421351
methodWithGenericParam = fClass.instanceMethods
13431352
.singleWhere((m) => m.name == 'methodWithGenericParam');
1353+
methodWithTypedefParam = c.instanceMethods
1354+
.singleWhere((m) => m.name == 'methodWithTypedefParam');
13441355
});
13451356

13461357
test('has parameters', () {
@@ -1378,6 +1389,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
13781389
expect(param.name, equals('helper'));
13791390
expect(param.library.name, equals('ex'));
13801391
});
1392+
1393+
test('typdef param is linked', () {
1394+
var params = methodWithTypedefParam.linkedParams();
1395+
expect(params.contains('<a href="ex/processMessage.html">'), isTrue);
1396+
});
13811397
});
13821398

13831399
group('Implementors', () {

0 commit comments

Comments
 (0)