From 41198ce17b8d4388105a021c1645823b8d24324b Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Wed, 30 Aug 2023 10:31:41 +0200 Subject: docs: document what has been ASCII-lowercased --- src/attr.rs | 9 +++++++++ src/emitter.rs | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/attr.rs b/src/attr.rs index 48ae5b0..a4a3428 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -61,6 +61,7 @@ pub struct Attribute<'a, O> { #[derive(Debug, PartialEq, Eq)] pub struct AttributeOwned { /// The attribute name. + /// Uppercase ASCII characters (A-Z) have been converted to lowercase. pub name: String, /// The attribute value. pub value: String, @@ -76,6 +77,9 @@ pub struct AttributeOwned { impl AttributeMap { /// Returns the attribute with the given name. + /// + /// The name must not contain any uppercase ASCII character (A-Z) + /// or the method will always return `None`. pub fn get(&self, name: &str) -> Option> { self.inner .get_key_value(name) @@ -85,6 +89,7 @@ impl AttributeMap { impl<'a, O: Offset> Attribute<'a, O> { /// Returns the attribute name. + /// Uppercase ASCII characters (A-Z) have been converted to lowercase. pub fn name(&self) -> &'a str { self.name } @@ -122,6 +127,10 @@ impl<'a, O: Offset> Attribute<'a, O> { impl Index<&str> for AttributeMap { type Output = str; + /// Returns the attribute value with the given name. + /// + /// The name must not contain any uppercase ASCII character (A-Z) + /// or the method will always panic. fn index(&self, name: &str) -> &Self::Output { &self.inner[name].value } diff --git a/src/emitter.rs b/src/emitter.rs index b75334a..3fbb9e2 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -456,7 +456,8 @@ pub struct StartTag { /// expected. pub self_closing: bool, - /// The start tag's name, such as `"p"` or `"a"`. + /// The tag name. + /// Uppercase ASCII characters (A-Z) have been converted to lowercase. pub name: String, /// A mapping for any HTML attributes this start tag may have. @@ -480,7 +481,8 @@ impl StartTag { /// An HTML end/close tag, such as `

` or ``. #[derive(Debug, Eq, PartialEq)] pub struct EndTag { - /// The ending tag's name, such as `"p"` or `"a"`. + /// The tag name. + /// Uppercase ASCII characters (A-Z) have been converted to lowercase. pub name: String, /// The source code span of the tag. @@ -524,7 +526,8 @@ pub struct Doctype { /// [force-quirks flag]: https://html.spec.whatwg.org/multipage/parsing.html#force-quirks-flag pub force_quirks: bool, - /// The doctype's name. For HTML documents this should be "html". + /// The doctype's name. Uppercase ASCII characters (A-Z) have been + /// converted to lowercase. For HTML documents this should be "html". pub name: String, /// The doctype's public identifier. -- cgit v1.2.3