Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 50837e5

Browse files
authored
Fix doc comments (#256)
Update comments that set off a false positive in the `unintended_html_in_doc_comment` lint. For references to core Dart types with generics, replace the square braces with backticks since it isn't useful to constantly link them. For the comments that are edited, and a few nearby, update for style: - Separate out a header as it's own paragraph. - Reduce repetitive phrasing and redundant links to the same arguments. Use a trailing comma for a long argument list, and re-order the arguments so that the always-useful arguments are at the top, and the arguments only pertaining to certain uses follow.
1 parent 0da420c commit 50837e5

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

lib/parser.dart

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import 'src/tokenizer.dart';
2626
import 'src/treebuilder.dart';
2727
import 'src/utils.dart';
2828

29-
/// Parse the [input] html5 document into a tree. The [input] can be
30-
/// a [String], [List<int>] of bytes or an [HtmlTokenizer].
29+
/// Parse an html5 document into a tree.
30+
///
31+
/// The [input] can be a `String`, a `List<int>` of bytes, or an
32+
/// [HtmlTokenizer].
3133
///
3234
/// If [input] is not a [HtmlTokenizer], you can optionally specify the file's
3335
/// [encoding], which must be a string. If specified that encoding will be
@@ -44,9 +46,12 @@ Document parse(dynamic input,
4446
return p.parse();
4547
}
4648

47-
/// Parse the [input] html5 document fragment into a tree. The [input] can be
48-
/// a [String], [List<int>] of bytes or an [HtmlTokenizer]. The [container]
49-
/// element can optionally be specified, otherwise it defaults to "div".
49+
/// Parse an html5 document fragment into a tree.
50+
///
51+
/// The [input] can be a `String`, a `List<int>` of bytes, or an
52+
/// [HtmlTokenizer].
53+
/// The [container] element can optionally be specified, otherwise it defaults
54+
/// to "div".
5055
///
5156
/// If [input] is not a [HtmlTokenizer], you can optionally specify the file's
5257
/// [encoding], which must be a string. If specified, that encoding will be used,
@@ -126,8 +131,13 @@ class HtmlParser {
126131
late final _afterAfterBodyPhase = AfterAfterBodyPhase(this);
127132
late final _afterAfterFramesetPhase = AfterAfterFramesetPhase(this);
128133

129-
/// Create an HtmlParser and configure the [tree] builder and [strict] mode.
130-
/// The [input] can be a [String], [List<int>] of bytes or an [HtmlTokenizer].
134+
/// Create and configure an HtmlParser.
135+
///
136+
/// The [input] can be a `String`, a `List<int>` of bytes, or an
137+
/// [HtmlTokenizer].
138+
///
139+
/// The [strict], [tree] builder, and [generateSpans] arguments configure
140+
/// behavior for any type of input.
131141
///
132142
/// If [input] is not a [HtmlTokenizer], you can specify a few more arguments.
133143
///
@@ -141,16 +151,17 @@ class HtmlParser {
141151
/// automatic conversion of element and attribute names to lower case. Note
142152
/// that standard way to parse HTML is to lowercase, which is what the browser
143153
/// DOM will do if you request `Element.outerHTML`, for example.
144-
HtmlParser(dynamic input,
145-
{String? encoding,
146-
bool parseMeta = true,
147-
bool lowercaseElementName = true,
148-
bool lowercaseAttrName = true,
149-
this.strict = false,
150-
this.generateSpans = false,
151-
String? sourceUrl,
152-
TreeBuilder? tree})
153-
: tree = tree ?? TreeBuilder(true),
154+
HtmlParser(
155+
dynamic input, {
156+
TreeBuilder? tree,
157+
this.strict = false,
158+
this.generateSpans = false,
159+
String? encoding,
160+
bool parseMeta = true,
161+
bool lowercaseElementName = true,
162+
bool lowercaseAttrName = true,
163+
String? sourceUrl,
164+
}) : tree = tree ?? TreeBuilder(true),
154165
tokenizer = input is HtmlTokenizer
155166
? input
156167
: HtmlTokenizer(input,
@@ -166,6 +177,7 @@ class HtmlParser {
166177
bool get innerHTMLMode => innerHTML != null;
167178

168179
/// Parse an html5 document into a tree.
180+
///
169181
/// After parsing, [errors] will be populated with parse errors, if any.
170182
Document parse() {
171183
innerHTML = null;
@@ -174,6 +186,7 @@ class HtmlParser {
174186
}
175187

176188
/// Parse an html5 document fragment into a tree.
189+
///
177190
/// Pass a [container] to change the type of the containing element.
178191
/// After parsing, [errors] will be populated with parse errors, if any.
179192
DocumentFragment parseFragment([String container = 'div']) {

lib/src/html_input_stream.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class HtmlInputStream {
4848
/// HtmlInputStream(source, [encoding]) -> Normalized stream from source
4949
/// for use by html5lib.
5050
///
51-
/// [source] can be either a [String] or a [List<int>] containing the raw
51+
/// [source] can be either a `String` or a `List<int>` containing the raw
5252
/// bytes.
5353
///
5454
/// The optional encoding parameter must be a string that indicates

lib/src/list_proxy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ library;
44
import 'dart:collection';
55

66
abstract class ListProxy<E> extends ListBase<E> {
7-
/// The inner [List<T>] with the actual storage.
7+
/// The proxied list with actual storage.
88
final List<E> _list = <E>[];
99

1010
@override

0 commit comments

Comments
 (0)