Back to Examples

Documentation

Annotations would be inconvenient for specifying structured documentation. Ballerina-flavored Markdown (BFM) is an additional convention on top of Markdown, which makes it more convenient for documenting Ballerina code.

// Lines starting with `#` contain structured documentation in Markdown format.
# Adds two integers.
// Documents the parameters of the function.
# + x - an integer
# + y - another integer
// Documents the return parameter of the function.
# + return - the sum of `x` and `y`
public function add(int x, int y) returns int {
    return x + y;
}
$ bal run documentation.bal
PreviousRegExp match operations
NextAnnotations