Browse Source

Updated docs.

Mark Sibly 8 years ago
parent
commit
e9ce99f081

+ 1 - 1
modules/mojo/docs/module.md

@@ -18,7 +18,7 @@ Once the app is running, mojo runs a simple event loop that looks like this:
 
 * Get OS events and dispatch corresponding mojo events if necessary.
 * Once there are no OS events left to process, any custom [[app.AppInstance.Idle]] handlers are called.
-* If the application has called [[app.AppInstance.RequestRender]], then the app is rendered.
+* If the application has called [[app.AppInstance.RequestRender]], the app is then rendered.
 
 The app will continue executing the event loop until [[app.AppInstance.Terminate]] is called.
 

+ 7 - 0
modules/mojo/graphics/font.monkey2

@@ -34,6 +34,13 @@ Class GlyphPage
 End
 
 #rem monkeydoc The Font class.
+
+Fonts are used when drawing text to a canvas using [[Canvas.DrawText]].
+
+To load a font, use the [[Font.Load]] function. Fonts should be in .otf, .ttf or .fon format.
+
+Once a font is loaded it can be used with a canvas via the [[Canvas.Font]] property.
+
 #end
 Class Font Extends Resource
 

+ 19 - 2
modules/mojo/graphics/image.monkey2

@@ -5,9 +5,26 @@ Using std.resource
 
 #rem monkeydoc The Image class.
 
-An image is a rectangular array of pixels that can be drawn using one of the [[Canvas.DrawImage]] methods.
+An image is a rectangular array of pixels that can be drawn to a canvas using one of the [[Canvas.DrawImage]] methods.
+
+Images are similar to pixmap's, except that they are optimized for rendering, and typically live in GPU memory. 
+
+To load an image from a file, use one of the [[Load]], [[LoadBump]] or [[LoadLight]] functions.
+
+To create an image from an existing pixmap, use the New( pixmap,... ) constructor.
+
+To create an image that is a 'window' into an existing image, use the New( image,rect... ) constructor. This allows you to use images as 'atlases',
+
+To create an 'empty' image, use the New( width,height ) constructor. You can then render to this image by creating a canvas with this image as its render target.
+
+Images also have several properties that affect how they are rendered, including:
+
+* Handle - the relative position of the image's centre (or 'pivot point') for rendering, where (0.0,0.0) means the top-left of the image while (1.0,1.0) means the bottom-right.
+* Scale - a fixed scale factor for the image.
+* BlendMode - controls how the image is blended with the contents of the canvas. If this is null, this property is ignored and the current canvas blendmode is used to render the image instead.
+* Color - when rendering an image to a canvas, this property is multiplied by the current canvas color and the result is multiplied by actual image pixel colors to achieve the final color to be rendered.
+* TextureFilter - controls how image texels are sampled. Set to TextureFilter.None for coolio retro style graphics, or TextureFilter.Mipmap for fullon super smoothing.
 
-You can load an image from a file using one of the [[Load]], [[LoadBump]] or [[LoadLight]] functions.
 
 #end
 Class Image Extends Resource

+ 17 - 7
modules/std/collections/deque.monkey2

@@ -1,22 +1,33 @@
 
 Namespace std.collections
 
-#rem monkeydoc @hidden Convenience type alias for Deque\<Int\>.
+#rem monkeydoc Convenience type alias for Deque\<Int\>.
 #end
 Alias IntDeque:Deque<Int>
 
-#rem monkeydoc @hidden Convenience type alias for Deque\<Float\>.
+#rem monkeydoc Convenience type alias for Deque\<Float\>.
 #end
 Alias FloatDeque:Deque<Float>
 
-#rem monkeydoc @hidden Convenience type alias for Deque\<String\>.
+#rem monkeydoc Convenience type alias for Deque\<String\>.
 #end
 Alias StringDeque:Deque<String>
 
-#rem monkeydoc @hidden
+#rem monkeydoc The Deque class.
+
+A deque is a 'double ended queue' (usually pronounced 'deck').
+
+You can efficiently add items to either end of a deque using [[Deque.AddFirst]] and [[Deque.AddLast]], and remove items using [[RemoveFirst]] and [[RemoveLast]].
+
+Deques implement the [[IContainer]] interface so can be used with [[Eachin]] loops.
+
+Note that you should NOT modify a deque while iterating through it with an eachin loop. Doing so while cause a 'concurrent deque modification' runtime error in debug mode. Please see [[IContainer]] for more information.
+
 #end
 Class Deque<T> Implements IContainer<T>
 
+	#rem monkeydoc The Deque.Iterator struct.
+	#end
 	Struct Iterator Implements IIterator<T>
 	
 		Private
@@ -135,7 +146,7 @@ Class Deque<T> Implements IContainer<T>
 	
 	If a deque's length equals its capacity, then the next Add or Insert operation will need to allocate more memory to 'grow' the deque.
 	
-	You don't normally need to worry about deque capacity, but it can be useful to use [[Reserve]] to preallocate deque storage if you know in advance
+	You don't normally need to worry about deque capacity, but it can be useful to [[Reserve]] deque storage if you know in advance
 	how many values a deque is likely to contain, in order to prevent the overhead of excessive memory allocation.
 	
 	@return The current deque capacity.
@@ -209,8 +220,7 @@ Class Deque<T> Implements IContainer<T>
 	
 	If a deque's length equals its capacity, then the next Add, Insert or Push operation will need to allocate more memory to 'grow' the deque.
 	
-	You don't normally need to worry about deque capacity, but it can be useful to use [[Reserve]] to preallocate deque storage if you know in advance
-	how many values a deque is likely to contain, in order to prevent the overhead of excessive memory allocation.
+	You don't normally need to worry about deque capacity, but it can be useful to use [[Reserve]] to preallocate deque storage if you know in advance how many values a deque is likely to contain, in order to prevent excessive memory allocation.
 	
 	@param capacity The new capacity.
 	

+ 1 - 2
modules/std/collections/stack.monkey2

@@ -17,8 +17,7 @@ Alias StringStack:Stack<String>
 
 A stack is an 'array like' container that grows dynamically as necessary.
 
-It is very cheap to add values to the end of a stack, but insertion or removal of values requires higher indexed values to be 
-'shifted down'.
+It is very cheap to add values to the end of a stack, but insertion or removal of values requires higher indexed values to be 'shifted' up or down so is slower.
 
 Stacks implement the [[IContainer]] interface so can be used with [[Eachin]] loops.
 

+ 5 - 8
modules/std/fiber/fiber.monkey2

@@ -27,22 +27,19 @@ Function GetCurrentFiber:Int()="bbFiber::getCurrentFiber"
 
 Public
 
-#rem monkeydoc Fibers provides support for cooperative multitasking.
+#rem monkeydoc Fibers provide support for asynchronous programming.
 
 A Fiber is a lightweight 'thread of execution' that can be used to achieve a form of cooperative multitasking.
 
 A fiber can be in one of 4 states:
 
-* Running. There is only ever one fiber in the running state at a time. This is the fiber returned by [[Current]].
+* Running. There is only ever one fiber in the running state at a time. This is the fiber returned by [[Fiber.Current]].
 
-* Suspended. A fiber is in the suspended state if it has called [[Suspend]]. A suspended fiber can only be returned to the running state
-by some other fiber calling [[Resume]] on it.
+* Suspended. A fiber is in the suspended state if it has called [[Fiber.Suspend]]. A suspended fiber can only be returned to the running state by some other fiber calling [[Resume]] on it.
 
-* Paused. A fiber is in the paused state after it has called [[Resume]] on another fiber and that fiber has resumed running. A paused
-fiber will continue running when the fiber it resumed calls [[Suspend]] or exits normally. A fiber is also paused after creating a new 
-fiber, ie: creating a new fiber also implicty resumes the new fiber.
+* Paused. A fiber is in the paused state after it has called [[Resume]] on another fiber and that fiber has resumed running. A paused fiber will continue running when the fiber it resumed calls [[Suspend]] or exits normally.
 
-* Terminated. The fiber has either returned from it's entry function, or has been explicitly terminated via a call to [[Terminate]].
+* Terminated. The fiber has either returned from i's entry function, or has been explicitly terminated via a call to [[Terminate]].
 
 #end
 Struct Fiber

+ 3 - 3
modules/std/fiber/future.monkey2

@@ -3,11 +3,11 @@ Namespace std.fiber
 
 #if __TARGET__<>"emscripten"
 
-#rem monkeydoc Futures provides support for simple fiber synchronization.
+#rem monkeydoc Futures provide support for simple fiber synchronization.
 
 A future allows you to synchronize two fibers by providing a way for one fiber to signal to another that an operation has completed.
 
-The general usage pattern of future is:
+The general usage pattern of futures is:
 
 * Fiber A creates a future and passes it to fiber B.
 
@@ -15,7 +15,7 @@ The general usage pattern of future is:
 
 * Fiber B performs some operation, then calls [[Set]] on the future. This will resume Fiber A.
 
-A future can be resued - each time [[Get]] is called, the fiber will suspend until another fiber calls [[Set]].
+A future can be resued. Each time [[Get]] is called, the fiber will suspend until another fiber calls [[Set]].
 
 #end
 Class Future<T>

+ 6 - 4
modules/std/misc/json.monkey2

@@ -3,13 +3,15 @@
 
 JSON (JavaScript Object Notation) is a lightweight data-interchange format.
 
-\## Reading JSON data
+To load a json object from a file, use the [[JsonObject.Load]] function.
 
-Use the [[JsonObject.Load]] function to load JSON data from a file, or [[JsonObject.Parse]] to parse JSON data from a string.
+To convert a string to a json object, use the [[JsonObject.Parse]] function.
 
-\## Writing JSON data
+To convert a json object to a string, use the [[JsonObject.ToString]] method.
 
-To save a JSON object, use the [[JsonObject.Save]] function.
+You can inspect the members of a json object using methods such as [[JsonObject.GetString]], [[JsonObject.GetNumber]] etc.
+
+You can modify the members of a json object using methods such as [[JsonObject.SetString]], [[JsonObject.SetNumber]] etc.
 
 #end
 Namespace std.json

+ 33 - 3
modules/std/socket/socket.monkey2

@@ -76,20 +76,41 @@ Function socket_sockaddrname:Int( addr:Void Ptr,addrlen:Int,host:libc.char_t Ptr
 
 Public
 
-Enum SocketType
+#rem monkeydoc The SocketType enum.
+
+| SocketType	| Description
+|:--------------|:-----------
+| `Stream`		| Reliable stream, eg: TCP.
+| `Datagram`	| Unreliable datagram, eg: UDP.
 
+#end
+Enum SocketType
 	Stream=0
 	Datagram=1
-
 End
 
+#rem monkeydoc The SocketAddress class.
+
+A socket address encapsulates the hostname and service of a socket.
+
+Socket address objects are returned by the [[Socket.Address]] and [[Socket.PeerAddress]] properties, and indirectly returned by [[Socket.ReceiveFrom]].
+
+#end
 Class SocketAddress
 
-	#rem monkeydoc Creates a new socket address.
+	#rem monkeydoc Creates a new empty socket address.
+	
+	The new socket address can be used with [[Socket.ReceiveFrom]].
+	 
 	#end
 	Method New()
 	End
+
+	#rem monkeydoc Creates a copy of an existing socket address.
+	
+	Creates and returns a copy of `address`.
 	
+	#end
 	Method New( address:SocketAddress )
 		_addr=address._addr.Slice( 0 )
 		_addrlen=address._addrlen
@@ -179,6 +200,15 @@ Class SocketAddress
 	
 End
 
+#rem monkeydoc The Socket class.
+
+The socket class provides a thin wrapper around native Winsock and BSD sockets.
+
+Sockets support asynchronous programming through the use of fibers. To connect, send or receive asynchronously, simply run the relevant socket code on its own fiber. Control will be returned to the 'main' gui fiber will the operation is busy.
+
+Sockets are ipv4/ipv6 compatible.
+
+#end
 Class Socket
 
 	#rem Not on Windows...

+ 5 - 0
modules/std/socket/socketstream.monkey2

@@ -1,6 +1,11 @@
 
 Namespace std.socket
 
+#rem monkeydoc The SocketStream class.
+
+A socket stream provides a 'wrapper' around a socket that lets you read and write the socket as if it was a stream.
+
+#end
 Class SocketStream Extends std.stream.Stream
 
 	#rem monkeydoc Creates a new socketsteam from an existing socket.