summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-10 06:51:26 +0200
committerMartin Fischer <martin@push-f.com>2023-09-28 10:36:08 +0200
commita580ee9311f1277dba15a235b0ec4364f70e3d23 (patch)
tree25c29b1e3b5618589bfa93b7112f81959cd1c3b4
parentc63b39bc78f1047b717d4c7b775047e86318d590 (diff)
docs: put Emitter methods in a more logical order
-rw-r--r--src/emitter.rs126
1 files changed, 63 insertions, 63 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index 7a567b4..25e0209 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -27,52 +27,57 @@ pub trait Emitter<O> {
/// Reports a parse error.
fn report_error(&mut self, error: Error, span: Range<O>);
- /// The state machine has reached the end of the file.
- fn emit_eof(&mut self);
-
/// Emits the given character as a character token.
fn emit_char(&mut self, c: char);
+ /// The state machine has reached the end of the file.
+ fn emit_eof(&mut self);
+
/// Set the _current token_ to a start tag.
fn init_start_tag(&mut self, tag_offset: O, name_offset: O);
/// Set the _current token_ to an end tag.
fn init_end_tag(&mut self, tag_offset: O, name_offset: O);
- /// Set the _current token_ to a comment.
- fn init_comment(&mut self, data_start_offset: O);
-
- /// Emit the _current token_, assuming it is a tag.
- ///
- /// Also get the current attribute and append it to the to-be-emitted tag. See docstring for
- /// [`Emitter::init_attribute_name`] for how duplicates should be handled.
- ///
- /// If an end tag is emitted with attributes, an [`Error::EndTagWithAttributes`]
- /// error should be emitted.
+ /// Assuming the _current token_ is a start/end tag, append a string to the current tag's name.
///
- /// If the current token is not a start/end tag, this method may panic.
- fn emit_current_tag(&mut self, offset: O);
+ /// If the current token is not a start or end tag, this method may panic.
+ fn push_tag_name(&mut self, s: &str);
- /// Emit the _current token_, assuming it is a comment.
+ /// Called after the last [`push_tag_name`] call for a tag name.
///
- /// If the current token is not a comment, this method may panic.
- fn emit_current_comment(&mut self, data_end_offset: O);
+ /// [`push_tag_name`]: Self::push_tag_name
+ fn terminate_tag_name(&mut self, offset: O) {}
- /// Emit the _current token_, assuming it is a doctype.
+ /// Set the _current attribute_ to a new one, starting with empty name and value strings.
///
- /// If the current token is not a doctype, this method may panic.
- fn emit_current_doctype(&mut self, offset: O);
+ /// The old attribute, if any, should be put on the _current token_. If an attribute with that
+ /// name already exists, WHATWG says the new one should be ignored and a
+ /// [`Error::DuplicateAttribute`] error should be emitted.
+ ///
+ /// If the current token is no tag at all, this method may panic.
+ fn init_attribute_name(&mut self, offset: O);
- /// Called after the last [`push_tag_name`] call for a tag name.
+ /// Append a string to the current attribute's name.
///
- /// [`push_tag_name`]: Self::push_tag_name
- fn terminate_tag_name(&mut self, offset: O) {}
+ /// If there is no current attribute, this method may panic.
+ fn push_attribute_name(&mut self, s: &str);
/// Called after the last [`push_attribute_name`] call for an attribute name.
///
/// [`push_attribute_name`]: Self::push_attribute_name
fn terminate_attribute_name(&mut self, offset: O) {}
+ /// Called before the first push_attribute_value call.
+ ///
+ /// If there is no current attribute, this method may panic.
+ fn init_attribute_value(&mut self, syntax: AttrValueSyntax, offset: O) {}
+
+ /// Append a string to the current attribute's value.
+ ///
+ /// If there is no current attribute, this method may panic.
+ fn push_attribute_value(&mut self, s: &str);
+
/// Called after the last [`push_attribute_value`] call for an attribute value.
///
/// [`push_attribute_value`]: Self::push_attribute_value
@@ -86,25 +91,29 @@ pub trait Emitter<O> {
/// [`Error::EndTagWithTrailingSolidus`] error.
fn set_self_closing(&mut self, slash_span: Range<O>);
- /// Assuming the _current token_ is a doctype, set its "force quirks" flag to true.
+ /// Emit the _current token_, assuming it is a tag.
///
- /// If the current token is not a doctype, this method pay panic.
- fn set_force_quirks(&mut self);
-
- /// Assuming the _current token_ is a start/end tag, append a string to the current tag's name.
+ /// Also get the current attribute and append it to the to-be-emitted tag. See docstring for
+ /// [`Emitter::init_attribute_name`] for how duplicates should be handled.
///
- /// If the current token is not a start or end tag, this method may panic.
- fn push_tag_name(&mut self, s: &str);
+ /// If an end tag is emitted with attributes, an [`Error::EndTagWithAttributes`]
+ /// error should be emitted.
+ ///
+ /// If the current token is not a start/end tag, this method may panic.
+ fn emit_current_tag(&mut self, offset: O);
+
+ /// Set the _current token_ to a comment.
+ fn init_comment(&mut self, data_start_offset: O);
/// Assuming the _current token_ is a comment, append a string to the comment's contents.
///
/// If the current token is not a comment, this method may panic.
fn push_comment(&mut self, s: &str);
- /// Assuming the _current token_ is a doctype, append a string to the doctype's name.
+ /// Emit the _current token_, assuming it is a comment.
///
- /// If the current token is not a doctype, this method may panic.
- fn push_doctype_name(&mut self, s: &str);
+ /// If the current token is not a comment, this method may panic.
+ fn emit_current_comment(&mut self, data_end_offset: O);
/// Set the _current token_ to a new doctype token:
///
@@ -114,35 +123,16 @@ pub trait Emitter<O> {
/// * the "force quirks" flag should be `false`
fn init_doctype(&mut self, offset: O);
- /// Set the _current attribute_ to a new one, starting with empty name and value strings.
- ///
- /// The old attribute, if any, should be put on the _current token_. If an attribute with that
- /// name already exists, WHATWG says the new one should be ignored and a
- /// [`Error::DuplicateAttribute`] error should be emitted.
- ///
- /// If the current token is no tag at all, this method may panic.
- fn init_attribute_name(&mut self, offset: O);
-
- /// Called before the first push_attribute_value call.
- ///
- /// If there is no current attribute, this method may panic.
- fn init_attribute_value(&mut self, syntax: AttrValueSyntax, offset: O) {}
-
- /// Append a string to the current attribute's name.
- ///
- /// If there is no current attribute, this method may panic.
- fn push_attribute_name(&mut self, s: &str);
-
- /// Append a string to the current attribute's value.
- ///
- /// If there is no current attribute, this method may panic.
- fn push_attribute_value(&mut self, s: &str);
-
/// Assuming the _current token_ is a doctype, set its name to the empty string.
///
/// If the current token is not a doctype, this method may panic.
fn init_doctype_name(&mut self, offset: O) {}
+ /// Assuming the _current token_ is a doctype, append a string to the doctype's name.
+ ///
+ /// If the current token is not a doctype, this method may panic.
+ fn push_doctype_name(&mut self, s: &str);
+
/// Called after the last [`push_doctype_name`] call for a DOCTYPE name.
///
/// [`push_doctype_name`]: Self::push_doctype_name
@@ -153,6 +143,11 @@ pub trait Emitter<O> {
/// If the current token is not a doctype, this method may panic.
fn init_doctype_public_id(&mut self, offset: O);
+ /// Assuming the _current token_ is a doctype, append a string to its "public identifier" to the given string.
+ ///
+ /// If the current token is not a doctype, this method may panic.
+ fn push_doctype_public_id(&mut self, s: &str);
+
/// Called after the last [`push_doctype_public_id`] call for a DOCTYPE public identifier.
///
/// [`push_doctype_public_id`]: Self::push_doctype_public_id
@@ -163,11 +158,6 @@ pub trait Emitter<O> {
/// If the current token is not a doctype, this method may panic.
fn init_doctype_system_id(&mut self, offset: O);
- /// Assuming the _current token_ is a doctype, append a string to its "public identifier" to the given string.
- ///
- /// If the current token is not a doctype, this method may panic.
- fn push_doctype_public_id(&mut self, s: &str);
-
/// Assuming the _current token_ is a doctype, append a string to its "system identifier" to the given string.
///
/// If the current token is not a doctype, this method may panic.
@@ -177,4 +167,14 @@ pub trait Emitter<O> {
///
/// [`push_doctype_system_id`]: Self::push_doctype_system_id
fn terminate_doctype_system_id(&mut self, offset: O) {}
+
+ /// Assuming the _current token_ is a doctype, set its "force quirks" flag to true.
+ ///
+ /// If the current token is not a doctype, this method pay panic.
+ fn set_force_quirks(&mut self);
+
+ /// Emit the _current token_, assuming it is a doctype.
+ ///
+ /// If the current token is not a doctype, this method may panic.
+ fn emit_current_doctype(&mut self, offset: O);
}