Skip to content

Commit 4acd663

Browse files
committed
Use html parsing in customization.
1 parent 8b63c60 commit 4acd663

6 files changed

+46
-47
lines changed

app/lib/dartdoc/customization.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import 'dart:async';
66
import 'dart:io';
77

8+
import 'package:html/dom.dart';
9+
import 'package:html/parser.dart' as html_parser;
10+
811
class DartdocCustomizer {
912
final String packageName;
1013
final String packageVersion;
@@ -23,7 +26,8 @@ class DartdocCustomizer {
2326
}
2427

2528
String customizeHtml(String html) {
26-
return null;
29+
final doc = html_parser.parse(html);
30+
return doc.outerHtml;
2731
}
2832
}
2933

app/test/dartdoc/golden/pana_0.10.2_index.out.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
1+
<!DOCTYPE html><html lang="en"><head>
42
<meta charset="utf-8">
53
<meta http-equiv="X-UA-Compatible" content="IE=edge">
64
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -26,7 +24,7 @@
2624
</ol>
2725
<div class="self-name">pana</div>
2826
<form class="search navbar-right" role="search">
29-
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
27+
<input type="text" id="search-box" autocomplete="off" disabled="" class="form-control typeahead" placeholder="Loading search...">
3028
</form>
3129
</header>
3230

@@ -100,6 +98,7 @@ <h2>Libraries</h2>
10098
<script src="static-assets/script.js"></script>
10199

102100

103-
</body>
104101

105-
</html>
102+
103+
104+
</body></html>

app/test/dartdoc/golden/pana_0.10.2_license_file_class.out.html

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
1+
<!DOCTYPE html><html lang="en"><head>
42
<meta charset="utf-8">
53
<meta http-equiv="X-UA-Compatible" content="IE=edge">
64
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -30,7 +28,7 @@
3028
</ol>
3129
<div class="self-name">LicenseFile</div>
3230
<form class="search navbar-right" role="search">
33-
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
31+
<input type="text" id="search-box" autocomplete="off" disabled="" class="form-control typeahead" placeholder="Loading search...">
3432
</form>
3533
</header>
3634

@@ -144,55 +142,55 @@ <h2>Properties</h2>
144142
<dl class="properties">
145143
<dt id="hashCode" class="property">
146144
<span class="name"><a href="pana/LicenseFile/hashCode.html">hashCode</a></span>
147-
<span class="signature">&#8594; int</span>
145+
<span class="signature"> int</span>
148146
</dt>
149147
<dd>
150148
The hash code for this object. <a href="pana/LicenseFile/hashCode.html">[...]</a>
151149
<div class="features">read-only</div>
152150
</dd>
153151
<dt id="name" class="property">
154152
<span class="name"><a href="pana/LicenseFile/name.html">name</a></span>
155-
<span class="signature">&#8594; String</span>
153+
<span class="signature"> String</span>
156154
</dt>
157155
<dd>
158156

159157
<div class="features">final</div>
160158
</dd>
161159
<dt id="path" class="property">
162160
<span class="name"><a href="pana/LicenseFile/path.html">path</a></span>
163-
<span class="signature">&#8594; String</span>
161+
<span class="signature"> String</span>
164162
</dt>
165163
<dd>
166164

167165
<div class="features">final</div>
168166
</dd>
169167
<dt id="shortFormatted" class="property">
170168
<span class="name"><a href="pana/LicenseFile/shortFormatted.html">shortFormatted</a></span>
171-
<span class="signature">&#8594; String</span>
169+
<span class="signature"> String</span>
172170
</dt>
173171
<dd>
174172

175173
<div class="features">read-only</div>
176174
</dd>
177175
<dt id="url" class="property">
178176
<span class="name"><a href="pana/LicenseFile/url.html">url</a></span>
179-
<span class="signature">&#8594; String</span>
177+
<span class="signature"> String</span>
180178
</dt>
181179
<dd>
182180

183181
<div class="features">@JsonKey(includeIfNull: false), final</div>
184182
</dd>
185183
<dt id="version" class="property">
186184
<span class="name"><a href="pana/LicenseFile/version.html">version</a></span>
187-
<span class="signature">&#8594; String</span>
185+
<span class="signature"> String</span>
188186
</dt>
189187
<dd>
190188

191189
<div class="features">@JsonKey(includeIfNull: false), final</div>
192190
</dd>
193191
<dt id="runtimeType" class="property inherited">
194192
<span class="name"><a href="pana/LicenseFile/runtimeType.html">runtimeType</a></span>
195-
<span class="signature">&#8594; Type</span>
193+
<span class="signature"> Type</span>
196194
</dt>
197195
<dd class="inherited">
198196
A representation of the runtime type of the object.
@@ -206,7 +204,7 @@ <h2>Methods</h2>
206204
<dl class="callables">
207205
<dt id="change" class="callable">
208206
<span class="name"><a href="pana/LicenseFile/change.html">change</a></span><span class="signature">(<wbr>{<span class="parameter" id="change-param-url"><span class="type-annotation">String</span> <span class="parameter-name">url</span></span> })
209-
<span class="returntype parameter">&#8594; <a href="pana/LicenseFile-class.html">LicenseFile</a></span>
207+
<span class="returntype parameter"> <a href="pana/LicenseFile-class.html">LicenseFile</a></span>
210208
</span>
211209
</dt>
212210
<dd>
@@ -215,7 +213,7 @@ <h2>Methods</h2>
215213
</dd>
216214
<dt id="toString" class="callable">
217215
<span class="name"><a href="pana/LicenseFile/toString.html">toString</a></span><span class="signature">(<wbr>)
218-
<span class="returntype parameter">&#8594; String</span>
216+
<span class="returntype parameter"> String</span>
219217
</span>
220218
</dt>
221219
<dd>
@@ -224,7 +222,7 @@ <h2>Methods</h2>
224222
</dd>
225223
<dt id="noSuchMethod" class="callable inherited">
226224
<span class="name"><a href="pana/LicenseFile/noSuchMethod.html">noSuchMethod</a></span><span class="signature">(<wbr><span class="parameter" id="noSuchMethod-param-invocation"><span class="type-annotation">Invocation</span> <span class="parameter-name">invocation</span></span>)
227-
<span class="returntype parameter">&#8594; dynamic</span>
225+
<span class="returntype parameter"> dynamic</span>
228226
</span>
229227
</dt>
230228
<dd class="inherited">
@@ -233,7 +231,7 @@ <h2>Methods</h2>
233231
</dd>
234232
<dt id="toJson" class="callable inherited">
235233
<span class="name"><a href="pana/LicenseFile/toJson.html">toJson</a></span><span class="signature">(<wbr>)
236-
<span class="returntype parameter">&#8594; Map<span class="signature">&lt;String, dynamic&gt;</span></span>
234+
<span class="returntype parameter"> Map<span class="signature">&lt;String, dynamic&gt;</span></span>
237235
</span>
238236
</dt>
239237
<dd class="inherited">
@@ -248,7 +246,7 @@ <h2>Operators</h2>
248246
<dl class="callables">
249247
<dt id="operator ==" class="callable">
250248
<span class="name"><a href="pana/LicenseFile/operator_equals.html">operator ==</a></span><span class="signature">(<wbr><span class="parameter" id="==-param-other"><span class="type-annotation">Object</span> <span class="parameter-name">other</span></span>)
251-
<span class="returntype parameter">&#8594; bool</span>
249+
<span class="returntype parameter"> bool</span>
252250
</span>
253251
</dt>
254252
<dd>
@@ -310,6 +308,7 @@ <h2>Operators</h2>
310308
<script src="static-assets/script.js"></script>
311309

312310

313-
</body>
314311

315-
</html>
312+
313+
314+
</body></html>

app/test/dartdoc/golden/pana_0.10.2_license_file_constructor.out.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
1+
<!DOCTYPE html><html lang="en"><head>
42
<meta charset="utf-8">
53
<meta http-equiv="X-UA-Compatible" content="IE=edge">
64
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -31,7 +29,7 @@
3129
</ol>
3230
<div class="self-name">LicenseFile</div>
3331
<form class="search navbar-right" role="search">
34-
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
32+
<input type="text" id="search-box" autocomplete="off" disabled="" class="form-control typeahead" placeholder="Loading search...">
3533
</form>
3634
</header>
3735

@@ -104,6 +102,7 @@ <h2><span>Implementation</span> </h2>
104102
<script src="static-assets/script.js"></script>
105103

106104

107-
</body>
108105

109-
</html>
106+
107+
108+
</body></html>

app/test/dartdoc/golden/pana_0.10.2_license_file_name_field.out.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
1+
<!DOCTYPE html><html lang="en"><head>
42
<meta charset="utf-8">
53
<meta http-equiv="X-UA-Compatible" content="IE=edge">
64
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -31,7 +29,7 @@
3129
</ol>
3230
<div class="self-name">name</div>
3331
<form class="search navbar-right" role="search">
34-
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
32+
<input type="text" id="search-box" autocomplete="off" disabled="" class="form-control typeahead" placeholder="Loading search...">
3533
</form>
3634
</header>
3735

@@ -105,6 +103,7 @@ <h2><span>Implementation</span> </h2>
105103
<script src="static-assets/script.js"></script>
106104

107105

108-
</body>
109106

110-
</html>
107+
108+
109+
</body></html>

app/test/dartdoc/golden/pana_0.10.2_pretty_json.out.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
1+
<!DOCTYPE html><html lang="en"><head>
42
<meta charset="utf-8">
53
<meta http-equiv="X-UA-Compatible" content="IE=edge">
64
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -30,7 +28,7 @@
3028
</ol>
3129
<div class="self-name">prettyJson</div>
3230
<form class="search navbar-right" role="search">
33-
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
31+
<input type="text" id="search-box" autocomplete="off" disabled="" class="form-control typeahead" placeholder="Loading search...">
3432
</form>
3533
</header>
3634

@@ -114,17 +112,17 @@ <h1>prettyJson function</h1>
114112
<h2><span>Implementation</span> </h2>
115113
<pre class="language-dart"><code class="language-dart">String prettyJson(obj) {
116114
try {
117-
return const JsonEncoder.withIndent(&#39; &#39;).convert(obj);
115+
return const JsonEncoder.withIndent(' ').convert(obj);
118116
} on JsonUnsupportedObjectError catch (e) {
119117
var error = e;
120118

121119
while (error is JsonUnsupportedObjectError) {
122120
stderr.writeln([
123121
error,
124-
&quot;${error.unsupportedObject} - (${error.unsupportedObject.runtimeType})&quot;,
125-
error.cause == null ? null : &quot;Nested cause: ${error.cause}&quot;,
122+
"${error.unsupportedObject} - (${error.unsupportedObject.runtimeType})",
123+
error.cause == null ? null : "Nested cause: ${error.cause}",
126124
error.stackTrace
127-
].where((i) =&gt; i != null).join(&#39;\n&#39;));
125+
].where((i) =&gt; i != null).join('\n'));
128126

129127
error = error.cause;
130128
}
@@ -154,6 +152,7 @@ <h2><span>Implementation</span> </h2>
154152
<script src="static-assets/script.js"></script>
155153

156154

157-
</body>
158155

159-
</html>
156+
157+
158+
</body></html>

0 commit comments

Comments
 (0)