Comments#
Line comments#
Line comments can be added using the ' character (ASCII-Code: 39, Hex: $27).
Everything to the right of a single quote ('), until the end of a line, will be interpreted as a comment.
Comments will be ignored during compilation time.
1 2 3 4 | ' ' Example showing line comments ' Print "hello!" ' this is a line comment |
Block comments#
Multiline comments can be made by using the #Rem and #End preprocessor directives.
#Rem initiates a block-comment and #End ends the block.
#Rem and #End both need to be at the start of the line. They can not be used within code lines.
1 2 3 4 5 6 7 8 | #Rem This is a multi-line block comment in Monkey2. #End Function Main() Print "Using #Rem..#End you can write block comments!" End |
Monkeydoc#
#Rem and #End can also be used for documentation of source-code. This is especially useful for documenting modules/libraries.
- A 'monkeydoc' comment starts with
#Rem monkeydocand ends with#End. - Directly after 'monkeydoc' follows the short description. The short description ends with the current line:
1 2 3 4 5 6 7 8 | #Rem monkeydoc Add two integer numbers ...Detailed description... #End Function Add:Int( a:Int, b:Int ) Return a + b End |
Directly after the monkeydoc-block follows the entity to be documented.
Monkeydoc can be used with:
- Namespaces (currently ignored)
- Interfaces, Classes, Structs, Enums
- Functions, Methods, Properties, Fields
- Aliases, Consts
Detailed description#
In the detailed description you can use the following special Monkeydoc entities, each on a separate line:
@param name description- used for documenting function/method parameters@return description- used for describing what a function/method returns.@example..@end- Used for inserting multi-line examples into the docs.
Markdown#
You can use Markdown syntax for monkeydoc:
- ` is used for code blocks
- * creates lists
Including tables#
You can create tables using the usual Markdown syntax:
1 2 3 4 5 | | Header Cell 1 | Header Cell 2 | Header Cell 3 |:----------------|:----------------|:--------------- | Row 1, Column 1 | Row 1, Column 2 | Row 1, Column 3 | Row 2, Column 1 | Row 2, Column 2 | Row 2, Column 3 | Row 3, Column 1 | Row 3, Column 2 | Row 3, Column 3 |
Links#
You can use links to other monkeydocs. Links are enclosed in [[ and ]]. An optional title can be set after a '|' character:
1 | [[ link | Title ]] |
To create a link to another function in the same file you simply use the name of the function:
1 | [[FunctionName]] |
To create a link to a class in another module you use the module name and the full name of the entity, including the namespace:
1 2 3 | [[mojo:mojo.app.AppInstance|mojo.AppInstance]] [[mojo3d:mojo3d.Renderer|mojo3d.Renderer]] |
The part after the '|' character is the text that is displayed for the link.
Monkeydoc for overloaded functions/methods#
Overloaded functions are not documented separately. Monkeydoc is written for the first of the overloaded functions/methods and all '@params' are included in this one monkeydoc.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #Rem monkeydoc Shows a message box The message box is opened in modal mode and the user needs to confirm it by pressing the 'OK' button. @example MsgBox("Get ready!") MsgBox(10,10,"Oh no, you lost!") @end @param x the x-position for the window @param y the y-position for the window @param msg The message for the dialog window @return This function does not return a value #End Function MsgBox( x:Int, y:Int, msg:String ) End Function MsgBox( msg:String ) End |
Deprecated docs#
Deprecated monkeydoc is marked with @deprecated:
1 2 3 4 | #Rem monkeydoc @deprecated #End Function old_func() End |
Hidden docs#
To skip the documentation of an entity you can use the short description @hidden:
1 2 3 4 5 6 7 | #Rem monkeydoc @hidden This is not included in the documentation. #End Function xample() End |