@@ -154,7 +154,21 @@ def parse_int(
154154 default : int | None = None ,
155155 check_name : str | None = None ,
156156) -> int :
157- """Parse integer value from XML with comprehensive validation."""
157+ """Parse integer value from XML with comprehensive validation.
158+
159+ Args:
160+ text: String to parse
161+ attribute_name: Context for error messages
162+ default: Default value if text is None
163+ check_name: Alias for attribute_name for consistent reporting
164+
165+ Returns:
166+ Parsed integer
167+
168+ Raises:
169+ RobotMathError: If input format is invalid or value is out of range
170+ RobotValidationError: If attribute is missing and no default is provided
171+ """
158172 report_name = check_name or attribute_name
159173
160174 if text is not None and not text .strip ():
@@ -178,7 +192,18 @@ def parse_int(
178192
179193
180194def parse_vector3 (text : str ) -> Vector3 :
181- """Parse space-separated vector3 string."""
195+ """Parse space-separated vector3 string.
196+
197+ Args:
198+ text: Space-separated string (e.g. "1.0 2.0 3.0")
199+
200+ Returns:
201+ Vector3 model
202+
203+ Raises:
204+ RobotValidationError: If vector format is invalid or components are missing
205+ RobotMathError: If component values are invalid
206+ """
182207 parts = text .strip ().split ()
183208 if len (parts ) != 3 :
184209 raise RobotValidationError (check_name = "Vector3" , value = text , reason = "Expected 3 values" )
@@ -194,14 +219,36 @@ def parse_vector3(text: str) -> Vector3:
194219
195220
196221def parse_optional_bool (elem : ET .Element , tag : str , default : str = "false" ) -> bool | None :
197- """Parse optional boolean element."""
222+ """Parse optional boolean element.
223+
224+ Args:
225+ elem: Parent XML element
226+ tag: Sub-element tag to find
227+ default: Default string value if tag is found but content is empty
228+
229+ Returns:
230+ Boolean value if tag exists, else None
231+ """
198232 if elem .find (tag ) is not None :
199233 return elem .findtext (tag , default ).lower () == "true"
200234 return None
201235
202236
203237def parse_optional_float (elem : ET .Element , tag : str , default : float | None = 0.0 ) -> float | None :
204- """Parse optional float element."""
238+ """Parse optional float element.
239+
240+ Args:
241+ elem: Parent XML element
242+ tag: Sub-element tag to find
243+ default: Default float value if tag content is missing
244+
245+ Returns:
246+ Parsed float if tag exists, else None
247+
248+ Raises:
249+ RobotMathError: If input value is invalid or out of range
250+ RobotValidationError: If parsing logic fails
251+ """
205252 if elem .find (tag ) is not None :
206253 text = elem .findtext (tag )
207254 return parse_float (text , tag , default = default )
0 commit comments