Skip to content

Commit 5f2e569

Browse files
authored
Remove wbr tags around block-displayed elements (#2320)
1 parent 3fa86a5 commit 5f2e569

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

lib/src/render/parameter_renderer.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ParameterRendererHtmlList extends ParameterRendererHtml {
2222
/// Render HTML suitable for a single, wrapped line.
2323
class ParameterRendererHtml extends ParameterRenderer {
2424
@override
25-
String listItem(String listItem) => '${listItem}<wbr>';
25+
String listItem(String listItem) => '${listItem}';
2626
@override
2727
String orderedList(String listItems) => listItems;
2828
@override

test/model_special_cases_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void main() {
209209
'Map<span class="signature">&lt;<wbr><span class="type-parameter">T?</span>, <span class="type-parameter">String?</span>&gt;</span>'));
210210
expect(aComplexSetterOnlyType.linkedReturnType, equals(
211211
// TODO(jcollins-g): fix wrong span class for setter-only return type (#2226)
212-
'<span class="parameter" id="aComplexSetterOnlyType=-param-value"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">Map<span class="signature">&lt;<wbr><span class="type-parameter">T?</span>, <span class="type-parameter">String?</span>&gt;</span>?</span>&gt;</span></span></span><wbr>'));
212+
'<span class="parameter" id="aComplexSetterOnlyType=-param-value"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">Map<span class="signature">&lt;<wbr><span class="type-parameter">T?</span>, <span class="type-parameter">String?</span>&gt;</span>?</span>&gt;</span></span></span>'));
213213
});
214214

215215
test('simple nullable elements are detected and rendered correctly', () {
@@ -231,7 +231,7 @@ void main() {
231231
expect(
232232
methodWithNullables.linkedParams,
233233
equals(
234-
'<span class="parameter" id="methodWithNullables-param-foo"><span class="type-annotation">String?</span> <span class="parameter-name">foo</span></span><wbr>'));
234+
'<span class="parameter" id="methodWithNullables-param-foo"><span class="type-annotation">String?</span> <span class="parameter-name">foo</span></span>'));
235235
expect(methodWithNullables.linkedReturnType, equals('int?'));
236236
expect(
237237
initialized.linkedReturnType,
@@ -240,7 +240,7 @@ void main() {
240240
expect(
241241
operatorStar.linkedParams,
242242
equals(
243-
'<span class="parameter" id="*-param-nullableOther"><span class="type-annotation"><a href="%%__HTMLBASE_dartdoc_internal__%%nullable_elements/NullableMembers-class.html">NullableMembers</a>?</span> <span class="parameter-name">nullableOther</span></span><wbr>'));
243+
'<span class="parameter" id="*-param-nullableOther"><span class="type-annotation"><a href="%%__HTMLBASE_dartdoc_internal__%%nullable_elements/NullableMembers-class.html">NullableMembers</a>?</span> <span class="parameter-name">nullableOther</span></span>'));
244244
});
245245
},
246246
skip: (!_nullSafetyExperimentAllowed.allows(_platformVersion) &&

test/model_test.dart

+26-18
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ void main() {
22662266
ParameterRendererHtml()
22672267
.renderLinkedParams(paramOfFutureOrNull.parameters),
22682268
equals(
2269-
'<span class="parameter" id="paramOfFutureOrNull-param-future"><span class="type-annotation">FutureOr<span class="signature">&lt;<wbr><span class="type-parameter">Null</span>&gt;</span></span> <span class="parameter-name">future</span></span><wbr>'));
2269+
'<span class="parameter" id="paramOfFutureOrNull-param-future"><span class="type-annotation">FutureOr<span class="signature">&lt;<wbr><span class="type-parameter">Null</span>&gt;</span></span> <span class="parameter-name">future</span></span>'));
22702270
});
22712271

22722272
test('function with a bound type to FutureOr', () {
@@ -2309,7 +2309,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
23092309
params,
23102310
'<span class="parameter" id="addCallback-param-callback">'
23112311
'<span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}fake/VoidCallback.html">VoidCallback</a></span> '
2312-
'<span class="parameter-name">callback</span></span><wbr>');
2312+
'<span class="parameter-name">callback</span></span>');
23132313

23142314
function =
23152315
fakeLibrary.functions.firstWhere((f) => f.name == 'addCallback2');
@@ -2318,7 +2318,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
23182318
params,
23192319
'<span class="parameter" id="addCallback2-param-callback">'
23202320
'<span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}fake/Callback2.html">Callback2</a></span> '
2321-
'<span class="parameter-name">callback</span></span><wbr>');
2321+
'<span class="parameter-name">callback</span></span>');
23222322
});
23232323

23242324
test('supports generic methods', () {
@@ -2329,8 +2329,13 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
23292329
test('can resolve functions as parameters', () {
23302330
var params = ParameterRendererHtml()
23312331
.renderLinkedParams(doAComplicatedThing.parameters);
2332-
expect(params,
2333-
'<span class="parameter" id="doAComplicatedThing-param-x"><span class="type-annotation">int</span> <span class="parameter-name">x</span>, </span><wbr><span class="parameter" id="doAComplicatedThing-param-doSomething">{<span class="type-annotation">void</span> <span class="parameter-name">doSomething</span>(<span class="parameter" id="param-aThingParameter"><span class="type-annotation">int</span> <span class="parameter-name">aThingParameter</span>, </span><wbr><span class="parameter" id="param-anotherThing"><span class="type-annotation">String</span> <span class="parameter-name">anotherThing</span></span><wbr>), </span><wbr><span class="parameter" id="doAComplicatedThing-param-doSomethingElse"><span class="type-annotation">void</span> <span class="parameter-name">doSomethingElse</span>(<span class="parameter" id="param-aThingParameter"><span class="type-annotation">int</span> <span class="parameter-name">aThingParameter</span>, </span><wbr><span class="parameter" id="param-somethingElse"><span class="type-annotation">double</span> <span class="parameter-name">somethingElse</span></span><wbr>)}</span><wbr>');
2332+
expect(
2333+
params,
2334+
'<span class="parameter" id="doAComplicatedThing-param-x"><span class="type-annotation">int</span> <span class="parameter-name">x</span>, </span>'
2335+
'<span class="parameter" id="doAComplicatedThing-param-doSomething">{<span class="type-annotation">void</span> <span class="parameter-name">doSomething</span>(<span class="parameter" id="param-aThingParameter"><span class="type-annotation">int</span> <span class="parameter-name">aThingParameter</span>, </span>'
2336+
'<span class="parameter" id="param-anotherThing"><span class="type-annotation">String</span> <span class="parameter-name">anotherThing</span></span>), </span>'
2337+
'<span class="parameter" id="doAComplicatedThing-param-doSomethingElse"><span class="type-annotation">void</span> <span class="parameter-name">doSomethingElse</span>(<span class="parameter" id="param-aThingParameter"><span class="type-annotation">int</span> <span class="parameter-name">aThingParameter</span>, </span>'
2338+
'<span class="parameter" id="param-somethingElse"><span class="type-annotation">double</span> <span class="parameter-name">somethingElse</span></span>)}</span>');
23342339
});
23352340
});
23362341

@@ -2349,8 +2354,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
23492354
.singleWhere((f) => f.name == 'explicitSetter');
23502355
// TODO(jcollins-g): really, these shouldn't be called "parameters" in
23512356
// the span class.
2352-
expect(explicitSetter.linkedReturnType,
2353-
'<span class="parameter" id="explicitSetter=-param-f"><span class="type-annotation">dynamic</span> <span class="parameter-name">Function</span>(<span class="parameter" id="param-bar"><span class="type-annotation">int</span>, </span><wbr><span class="parameter" id="param-baz"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}fake/Cool-class.html">Cool</a></span>, </span><wbr><span class="parameter" id="param-macTruck"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span></span><wbr>)</span><wbr>');
2357+
expect(
2358+
explicitSetter.linkedReturnType,
2359+
'<span class="parameter" id="explicitSetter=-param-f"><span class="type-annotation">dynamic</span> <span class="parameter-name">Function</span>(<span class="parameter" id="param-bar"><span class="type-annotation">int</span>, </span>'
2360+
'<span class="parameter" id="param-baz"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}fake/Cool-class.html">Cool</a></span>, </span>'
2361+
'<span class="parameter" id="param-macTruck"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span></span>)</span>');
23542362
});
23552363

23562364
test('parameterized type from field is correctly displayed', () {
@@ -2398,7 +2406,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
23982406
// TODO(jcollins-g): really, these shouldn't be called "parameters" in
23992407
// the span class.
24002408
expect(aInheritedSetter.enclosingCombo.linkedReturnType,
2401-
'<span class="parameter" id="aInheritedSetter=-param-thingToSet"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a><span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span></span></span><wbr>');
2409+
'<span class="parameter" id="aInheritedSetter=-param-thingToSet"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a><span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span></span></span>');
24022410
});
24032411

24042412
test(
@@ -2446,7 +2454,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
24462454
expect(
24472455
ParameterRendererHtml()
24482456
.renderLinkedParams(aInheritedAdditionOperator.parameters),
2449-
'<span class="parameter" id="+-param-other"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/ParameterizedClass-class.html">ParameterizedClass</a><span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span></span> <span class="parameter-name">other</span></span><wbr>');
2457+
'<span class="parameter" id="+-param-other"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/ParameterizedClass-class.html">ParameterizedClass</a><span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span></span> <span class="parameter-name">other</span></span>');
24502458
});
24512459

24522460
test('', () {});
@@ -2509,7 +2517,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
25092517
expect(
25102518
getAFunctionReturningVoid.linkedReturnType,
25112519
equals(
2512-
'void Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">T1</span>, </span><wbr><span class="parameter" id="param-"><span class="type-annotation">T2</span></span><wbr>)</span>'));
2520+
'void Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">T1</span>, </span><span class="parameter" id="param-"><span class="type-annotation">T2</span></span>)</span>'));
25132521
});
25142522

25152523
test(
@@ -2518,7 +2526,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
25182526
expect(
25192527
getAFunctionReturningBool.linkedReturnType,
25202528
equals(
2521-
'bool Function&lt;<wbr><span class="type-parameter">T4</span>&gt;<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">String</span>, </span><wbr><span class="parameter" id="param-"><span class="type-annotation">T1</span>, </span><wbr><span class="parameter" id="param-"><span class="type-annotation">T4</span></span><wbr>)</span>'));
2529+
'bool Function&lt;<wbr><span class="type-parameter">T4</span>&gt;<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">String</span>, </span><span class="parameter" id="param-"><span class="type-annotation">T1</span>, </span><span class="parameter" id="param-"><span class="type-annotation">T4</span></span>)</span>'));
25222530
});
25232531

25242532
test('has a fully qualified name', () {
@@ -3125,11 +3133,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
31253133
// TODO(jcollins-g): after analyzer 0.39.5 change to 'num' in first
31263134
// group.
31273135
matches(RegExp(
3128-
r'(dynamic|num) Function<span class="signature">\(<span class="parameter" id="param-a"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">num</span>&gt;</span></span> <span class="parameter-name">a</span></span><wbr>\)</span>')));
3136+
r'(dynamic|num) Function<span class="signature">\(<span class="parameter" id="param-a"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">num</span>&gt;</span></span> <span class="parameter-name">a</span></span>\)</span>')));
31293137
expect(
31303138
importantComputations.linkedReturnType,
31313139
matches(RegExp(
3132-
r'Map<span class="signature">&lt;<wbr><span class="type-parameter">int</span>, <span class="type-parameter">(dynamic|num) Function<span class="signature">\(<span class="parameter" id="param-a"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">num</span>&gt;</span></span> <span class="parameter-name">a</span></span><wbr>\)</span></span>&gt;</span>')));
3140+
r'Map<span class="signature">&lt;<wbr><span class="type-parameter">int</span>, <span class="type-parameter">(dynamic|num) Function<span class="signature">\(<span class="parameter" id="param-a"><span class="type-annotation">List<span class="signature">&lt;<wbr><span class="type-parameter">num</span>&gt;</span></span> <span class="parameter-name">a</span></span>\)</span></span>&gt;</span>')));
31333141
});
31343142

31353143
test(
@@ -3138,7 +3146,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
31383146
expect(
31393147
complicatedReturn.linkedReturnType,
31403148
equals(
3141-
'<a href="${HTMLBASE_PLACEHOLDER}fake/ATypeTakingClass-class.html">ATypeTakingClass</a><span class="signature">&lt;<wbr><span class="type-parameter">String Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">int</span></span><wbr>)</span></span>&gt;</span>'));
3149+
'<a href="${HTMLBASE_PLACEHOLDER}fake/ATypeTakingClass-class.html">ATypeTakingClass</a><span class="signature">&lt;<wbr><span class="type-parameter">String Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">int</span></span>)</span></span>&gt;</span>'));
31423150
});
31433151

31443152
test('@nodoc on simple property works', () {
@@ -3423,7 +3431,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
34233431
ParameterRendererHtml().renderLinkedParams(aVoidParameter.parameters,
34243432
showMetadata: true, showNames: true),
34253433
equals(
3426-
'<span class="parameter" id="aVoidParameter-param-p1"><span class="type-annotation">Future<span class="signature">&lt;<wbr><span class="type-parameter">void</span>&gt;</span></span> <span class="parameter-name">p1</span></span><wbr>'));
3434+
'<span class="parameter" id="aVoidParameter-param-p1"><span class="type-annotation">Future<span class="signature">&lt;<wbr><span class="type-parameter">void</span>&gt;</span></span> <span class="parameter-name">p1</span></span>'));
34273435
});
34283436

34293437
test('a class that extends Future<void>', () {
@@ -3505,7 +3513,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
35053513
expect(
35063514
ParameterRendererHtml().renderLinkedParams(theConstructor.parameters),
35073515
equals(
3508-
'<span class="parameter" id="-param-x"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/ParameterizedTypedef.html">ParameterizedTypedef</a><span class="signature">&lt;<wbr><span class="type-parameter">double</span>&gt;</span></span> <span class="parameter-name">x</span></span><wbr>'));
3516+
'<span class="parameter" id="-param-x"><span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/ParameterizedTypedef.html">ParameterizedTypedef</a><span class="signature">&lt;<wbr><span class="type-parameter">double</span>&gt;</span></span> <span class="parameter-name">x</span></span>'));
35093517
});
35103518

35113519
test('anonymous nested functions inside typedefs are handled', () {
@@ -3522,7 +3530,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
35223530
expect(
35233531
aComplexTypedef.linkedReturnType,
35243532
equals(
3525-
'void Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">A1</span>, </span><wbr><span class="parameter" id="param-"><span class="type-annotation">A2</span>, </span><wbr><span class="parameter" id="param-"><span class="type-annotation">A3</span></span><wbr>)</span>'));
3533+
'void Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">A1</span>, </span><span class="parameter" id="param-"><span class="type-annotation">A2</span>, </span><span class="parameter" id="param-"><span class="type-annotation">A3</span></span>)</span>'));
35263534
expect(
35273535
aComplexTypedef.linkedParamsLines,
35283536
equals(
@@ -3690,7 +3698,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
36903698
params,
36913699
equals('<span class="parameter" id="methodWithTypedefParam-param-p">'
36923700
'<span class="type-annotation"><a href="${HTMLBASE_PLACEHOLDER}ex/processMessage.html">processMessage</a></span> '
3693-
'<span class="parameter-name">p</span></span><wbr>'));
3701+
'<span class="parameter-name">p</span></span>'));
36943702
});
36953703
});
36963704

0 commit comments

Comments
 (0)