Skip to content

Latest commit

 

History

History
130 lines (99 loc) · 1.78 KB

docgen.md

File metadata and controls

130 lines (99 loc) · 1.78 KB

DocGen Specification

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 */

Keywords

@description

/**
 * @description
 * Add a simple description of your macro
 */
#(MY::MACRO) (STD::PRINT) "Hello, World!"

@param

/**
 * @param name
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@return

/**
 * @return An int32 value
 */
#(MY::MACRO) 42

@example

/**
 * @example
 * (MY::MACRO) "World"
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@see

/**
 * @see https://wwww.google.com
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@since

/**
 * @since 1.0.0
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@deprecated

/**
 * @deprecated
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@author

/**
 * @author John Doe
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@version

/**
 * @version 1.0.0
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@license

/**
 * @license MIT
 */
#(MY::MACRO) (STD::PRINT) "Hello, $!"

@target

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 $ }