2Lang has built-in support for automatic documentation generation.
It is heavily inspired by Java Doc and JSDoc.
To create a DocGen comment, you will need to use a block comment with two starting asterisk's.
/** Your DocGen comment here */
/**
* @description
* Add a simple description of your macro
*/
#(MY::MACRO) (STD::PRINT) "Hello, World!"
/**
* @param name
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @return An int32 value
*/
#(MY::MACRO) 42
/**
* @example
* (MY::MACRO) "World"
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @see https://wwww.google.com
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @since 1.0.0
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @deprecated
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @author John Doe
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @version 1.0.0
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
/**
* @license MIT
*/
#(MY::MACRO) (STD::PRINT) "Hello, $!"
Possible values: compiler
or runtime
This is useful for documenting if a macro will modify the runtime behavior of a program.
A macro is typically defined as "modifying the runtime behavior of a program" if it writes to the output/assembled file.
Additionally, while it is a convention (not a requirement), runtime macros are typically scoped with round brackets "()", while compile time macros are typically scoped with square brackets "[]".
/**
* @description
* Deletes a file at compile time
*
* @targets compiler
*/
#[MY::REMOVE_FILE] @!/bin/sh{ rm $ }