Browse Source

more documentation.

Nicolas Cannasse 19 years ago
parent
commit
9c614ca205
8 changed files with 254 additions and 32 deletions
  1. 5 6
      std/Array.hx
  2. 27 0
      std/Date.hx
  3. 1 1
      std/IntHash.hx
  4. 3 0
      std/Math.hx
  5. 32 5
      std/StdTypes.hx
  6. 29 4
      std/String.hx
  7. 19 9
      std/Type.hx
  8. 138 7
      std/Xml.hx

+ 5 - 6
std/Array.hx

@@ -76,7 +76,7 @@ extern class Array<T> {
 		negative to count from the end: -1 is the last item in
 		the array.
 	**/
-	function slice( pos : Int, end : Int ) : Array<T>; // sub
+	function slice( pos : Int, end : Int ) : Array<T>;
 
 	/**
 		Sort the Array according to the comparison function [f].
@@ -86,10 +86,9 @@ extern class Array<T> {
 	function sort( f : T -> T -> Int ) : Void;
 
 	/**
-		Removes [len] elements starting from [pos].
+		Removes [len] elements starting from [pos] an returns them.
 	**/
-	function splice( pos : Int, len : Int ) : Array<T>; // removed elts
-	// no toSource (js specific)
+	function splice( pos : Int, len : Int ) : Array<T>;
 
 	/**
 		Returns a displayable representation of the Array content.
@@ -100,7 +99,6 @@ extern class Array<T> {
 		Adds the element [x] at the start of the array.
 	**/
 	function unshift( x : T ) : Void;
-	// no valueOf (js specific)
 
 	/**
 		Inserts the element [x] at the position [pos].
@@ -111,6 +109,7 @@ extern class Array<T> {
 	/**
 		Removes the first occurence of [x].
 		Returns false if [x] was not present.
+		Elements are compared by using standard equality.
 	**/
 	function remove( x : T ) : Bool;
 
@@ -121,7 +120,7 @@ extern class Array<T> {
 	function copy() : Array<T>;
 
 	/**
-		Returns an iterator of Array values.
+		Returns an iterator of the Array values.
 	**/
 	function iterator() : Iterator<T>;
 

+ 27 - 0
std/Date.hx

@@ -41,12 +41,39 @@ extern class Date
 	**/
 	function getTime() : Float;
 
+	/**
+		Returns the hours value of the date (0-23 range).
+	**/
 	function getHours() : Int;
+	
+	/**
+		Returns the minutes value of the date (0-59 range).
+	**/	
 	function getMinutes() : Int;
+	
+	/**
+		Returns the seconds of the date (0-59 range).
+	**/	
 	function getSeconds() : Int;
+	
+	/**
+		Returns the full year of the date.
+	**/	
 	function getFullYear() : Int;
+	
+	/**
+		Returns the month of the date (0-11 range).
+	**/	
 	function getMonth() : Int;
+	
+	/**
+		Returns the day of the date (1-31 range).
+	**/	
 	function getDate() : Int;
+	
+	/**
+		Returns the week day of the date (0-6 range).
+	**/
 	function getDay() : Int;
 
 	/**

+ 1 - 1
std/IntHash.hx

@@ -44,7 +44,7 @@ class IntHash<T> {
 		untyped if( h.__proto__ != null ) {
 			h.__proto__ = null;
 			__js__("delete")(h.__proto__);
-		}
+		};
 		#else error
 		#end
 	}

+ 3 - 0
std/Math.hx

@@ -23,6 +23,9 @@
  * DAMAGE.
  */
 
+/**
+	This class defines mathematical functions and constants.
+**/
 extern class Math
 {
 	static var PI : Float;

+ 32 - 5
std/StdTypes.hx

@@ -25,35 +25,62 @@
 
 // standard haXe types
 
+/**
+	The standard Void type. Only [null] values can be of the type [Void].
+**/
 extern enum Void { }
 
+/**
+	The standard Float type, this is a double-precision IEEE 64bit float.
+**/
 extern class Float { }
 
+/**
+	The standard Int type. Its precision depends on the platform.
+**/
 extern class Int extends Float { }
 
-#if flash9
-typedef UInt = Int
-#else flash9doc
+#if (flash9 || flash9doc)
+/**
+	The unsigned Int type is only defined for Flash9. It's currently
+	handled the same as a normal Int.
+**/
 typedef UInt = Int
 #end
 
+/**
+	The standard Boolean type is represented as an enum with two choices.
+**/
 extern enum Bool {
 	true;
 	false;
 }
 
+/**
+	Dynamic is an internal compiler type which has special behavior.
+	See the haXe language reference for more informations.
+**/
 extern enum Dynamic<T> {
 }
 
+/**
+	An Iterator is a structure that permits to list a given container
+	values. It can be used by your own data structures. See the haXe
+	documentation for more informations.
+**/
 typedef Iterator<T> = {
 	function hasNext() : Bool;
 	function next() : T;
 }
 
+/**
+	ArrayAccess is used to indicate a class that can be accessed using brackets.
+	The type parameter represent the type of the elements stored.
+**/
 extern interface ArrayAccess<T> { }
 
 /**
    Protected represent the type parameter that cannot be used when using variance annotations.
-*/
-extern enum Protected {	
+**/
+extern enum Protected {
 }

+ 29 - 4
std/String.hx

@@ -33,6 +33,9 @@ extern class String {
 	**/
 	var length(default,null) : Int;
 
+	/**
+		Creates a copy from a given String.
+	**/
 	function new(string:String) : Void;
 
 	/**
@@ -46,22 +49,44 @@ extern class String {
 	function toLowerCase() : String;
 
 	/**
-		Returns the character at the given [index].
-		Returns the empty String if
+		Returns the character at the given position.
+		Returns the empty String if outside of String bounds.
 	**/
 	function charAt( index : Int) : String;
+	
+	/**
+		Returns the character code at the given position.
+		Returns [null] if outside of String bounds.
+	**/
 	function charCodeAt( index : Int) : Int;
 
 	/**
 		Returns the index of first occurence of [value]
-		If [value] is not found, will return -1
-		The optional [startIndex] parameter allows you to specify which character to start searching. The position returned is still relative to the beginning of the string.
+		Returns [1-1] if [value] is not found.
+		The optional [startIndex] parameter allows you to specify at which character to start searching.
+		The position returned is still relative to the beginning of the string.
 	**/
 	function indexOf( value : String, ?startIndex : Int ) : Int;
+
+	/**
+		Similar to [indexOf] but returns the latest index.
+	**/
 	function lastIndexOf( value : String, ?startIndex : Int ) : Int;
+
+	/**
+		Split the string using the specified delimiter.
+	**/
 	function split( delimiter : String ) : Array<String>;
+
+	/**
+		Returns a part of the String, taking [len] characters starting from [pos].
+		If [len] is not specified, it takes all the remaining characters.
+	**/
 	function substr( pos : Int, ?len : Int ) : String;
 
+	/**
+		Returns the String itself.
+	**/
 	function toString() : String;
 
 }

+ 19 - 9
std/Type.hx

@@ -1,18 +1,21 @@
 
 /**
 	An abstract type that represents a Class.
+	See [Type] for the haXe Reflection API.
 **/
 enum Class {
 }
 
 /**
 	An abstract type that represents an Enum.
+	See [Type] for the haXe Reflection API.
 **/
 enum Enum {
 }
 
 /**
 	The diffent possible runtime types of a value.
+	See [Type] for the haXe Reflection API.
 **/
 enum ValueType {
 	TNull;
@@ -26,10 +29,14 @@ enum ValueType {
 	TUnknown;
 }
 
+/**
+	The haXe Reflection API enables you to retreive informations about any value,
+	Classes and Enums at runtime.
+**/
 class Type {
 
 	/**
-		Returns the class of an object
+		Returns the class of a value or [null] if this value is not a Class instance.
 	**/
 	public static function getClass( o : Dynamic ) : Class untyped {
 		#if flash9
@@ -64,7 +71,7 @@ class Type {
 	}
 
 	/**
-		Returns the class of an object
+		Returns the enum of a value or [null] if this value is not an Enum instance.
 	**/
 	public static function getEnum( o : Dynamic ) : Enum untyped {
 		#if flash9
@@ -94,7 +101,7 @@ class Type {
 
 
 	/**
-		Returns the super-class of a class
+		Returns the super-class of a class, or null if no super class.
 	**/
 	public static function getSuperClass( c : Class ) : Class untyped {
 		#if flash9
@@ -109,7 +116,7 @@ class Type {
 
 
 	/**
-		Returns the complete name of the class of an object
+		Returns the complete name of a class.
 	**/
 	public static function getClassName( c : Class ) : String {
 		if( c == null )
@@ -126,7 +133,7 @@ class Type {
 	}
 
 	/**
-		Returns the complete name of the class of an object
+		Returns the complete name of an enum.
 	**/
 	public static function getEnumName( e : Enum ) : String {
 		#if flash9
@@ -139,7 +146,8 @@ class Type {
 	}
 
 	/**
-		Evaluates a class from a name
+		Evaluates a class from a name. The class must have been compiled
+		to be accessible.
 	**/
 	public static function resolveClass( name : String ) : Class {
 		var cl : Class;
@@ -180,7 +188,8 @@ class Type {
 
 
 	/**
-		Evaluates an enum from a name
+		Evaluates an enum from a name. The enum must have been compiled
+		to be accessible.
 	**/
 	public static function resolveEnum( name : String ) : Enum {
 		var e : Dynamic;
@@ -222,6 +231,7 @@ class Type {
 
 	/**
 		Similar to [Reflect.createInstance] excepts that the constructor is not called.
+		This enables you to create an instance without any side-effect.
 	**/
 	public static function createEmptyInstance( cl : Class ) untyped {
 		#if flash9
@@ -257,7 +267,7 @@ class Type {
 	#end
 
 	/**
-		Returns the list of instance fields
+		Returns the list of instance fields.
 	**/
 	public static function getInstanceFields( c : Class ) : Array<String> {
 		#if flash9
@@ -280,7 +290,7 @@ class Type {
 	}
 
 	/**
-		Returns the list of class static fields
+		Returns the list of a class static fields.
 	**/
 	public static function getClassFields( c : Class ) : Array<String> {
 		#if flash9

+ 138 - 7
std/Xml.hx

@@ -33,61 +33,192 @@ enum XmlType {
 }
 
 /**
-	Xml class and parsing.
+	The standard Xml class and parsing.
+	More API to manipulate XML are available in the [haxe.xml] package.
 **/
 extern class Xml {
 
+	/**
+		A type of Xml node.
+	**/
 	static var Element(default,null) : XmlType;
+
+	/**
+		A type of Xml node.
+	**/
 	static var PCData(default,null) : XmlType;
+
+	/**
+		A type of Xml node.
+	**/
 	static var CData(default,null) : XmlType;
+
+	/**
+		A type of Xml node.
+	**/
 	static var Comment(default,null) : XmlType;
+
+	/**
+		A type of Xml node.
+	**/
 	static var DocType(default,null) : XmlType;
+
+	/**
+		A type of Xml node.
+	**/
 	static var Prolog(default,null) : XmlType;
+
+	/**
+		A type of Xml node.
+	**/
 	static var Document(default,null) : XmlType;
 
+	/**
+		Parse a String into an Xml object.
+	**/
 	static function parse( s : String ) : Xml;
 
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createElement( name : String ) : Xml;
+
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createPCData( data : String ) : Xml;
+	
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createCData( data : String ) : Xml;
+
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createComment( data : String ) : Xml;
+
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createDocType( data : String ) : Xml;
+
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createProlog( data : String ) : Xml;
+
+	/**
+		Creates a node of the given type.
+	**/	
 	static function createDocument() : Xml;
 
+	/**
+		Returns the type of the Xml Node. This should be used before
+		accessing other functions since some might raise an exception
+		if the node type is not correct.
+	**/
 	var nodeType(default,null) : XmlType;
 
-	// nodeName : only works for Node
+	/**
+		Returns the node name of an Element.
+	**/
 	var nodeName(getNodeName,setNodeName) : String;
 	private function getNodeName() : String;
 	private function setNodeName( name : String ) : String;
 
-	// nodeValue : only works for not Node and not Document
+	/**
+		Returns the node value. Only works if the Xml node is not an Element or a Document.
+	**/
 	var nodeValue(getNodeValue,setNodeValue) : String;
 	private function getNodeValue() : String;
 	private function setNodeValue( name : String ) : String;
 
-	// attributes : only works for Node
+	/**
+		Get the given attribute of an Element node. Returns [null] if not found.
+		Attributes are case-sensitive.
+	**/
 	function get( att : String ) : String; // check case insensitivy
+
+	/**
+		Set the given attribute value for an Element node.
+		Attributes are case-sensitive.
+	**/
 	function set( att : String, value : String ) : Void;
+	
+	/**
+		Removes an attribute for an Element node.
+		Attributes are case-sensitive.
+	**/	
 	function remove( att : String ) : Void;
+	
+	/**
+		Tells if the Element node has a given attribute.
+		Attributes are case-sensitive.
+	**/	
 	function exists( att : String ) : Bool;
+	
+	/**
+		Returns an [Iterator] on all the attributes values.
+	**/	
 	function attributes() : Iterator<String>;
 
-	// children method : only works for Node and Document
+	/**
+		Returns the parent object in the Xml hierarchy.
+		The parent can be [null], an Element or a Document.
+	**/
 	var parent(getParent,null) : Xml;
 	private function getParent() : Xml;
 
+	/**
+		Returns an iterator of all child nodes.
+		Only works if the current node is an Element or a Document.
+	**/
 	function iterator() : Iterator<Xml>;
+
+	/**
+		Returns an iterator of all child nodes which are Elements.
+		Only works if the current node is an Element or a Document.
+	**/	
 	function elements() : Iterator<Xml>;
-	function elementsNamed( name : String ) : Iterator<Xml>; // only nodes with this nodeName
+	
+	/**
+		Returns an iterator of all child nodes which are Elements with the given nodeName.
+		Only works if the current node is an Element or a Document.
+	**/		
+	function elementsNamed( name : String ) : Iterator<Xml>;
+	
+	/**
+		Returns the first child node.
+	**/
 	function firstChild() : Xml;
+
+	/**
+		Returns the first child node which is an Element.
+	**/	
 	function firstElement() : Xml;
-	// exception if child is Document (can't add Documents together)
+
+	
+	/**
+		Adds a child node to the Document or Element.
+		One node can only be inside one given node which is indicated by the [parent] property.
+	**/	
 	function addChild( x : Xml ) : Void;
+
+	/**
+		Removes a child from the Document or Element.
+		Returns true if the child was successfuly removed.
+	**/	
 	function removeChild( x : Xml ) : Bool;
+	
+	/**
+		Inserts a child at the given position among the other childs.
+	**/
 	function insertChild( x : Xml, pos : Int ) : Void;
 
+	/**
+		Returns a String representation of the Xml node.
+	**/
 	function toString() : String;
 
 	static function __init__() : Void untyped {