1.3. YCP Functions

The function header should describe all needed pieces of information about the function. Such as parameters, return value, function's textual description, examples, etc.

Example 1.12. Simple Example of Function Description

/**
 * Returns number of just connected users to the server.
 * You can filter these users by defining the filtering parameter.
 *
 * @param part_of_ip ("192.168.") that users are connected from
 * @return integer number of connected users
 *
 * @see AnotherFunction()
 */
global integer GetCountOfConnectedUsers (string part_of_ip) {
    ...
}

Function description tags:

1.3.1. Description tag @deprecated

Defines that the function has been deprecated. Additionaly defines another function as the replacement.

Example 1.13. @deprecated tag

@deprecated AnotherFunction()

1.3.2. Description tag @descr

Complete description of the function. It might describe the environment or detailed behavior.

Example 1.14. Standard description

@descr This is a standard multi-line description
       of a function.

Example 1.15. Automatic description

/**
* This first line is identified as @short
*
* This multi-line @descr (after a newline) is automatically
* taken as the function description.
*
* Additionally, this multi-line text is automatically taken as another paragraph
* of the function @descr (the number of paragraphs is unlimited).
*/

1.3.3. Description tag @example

Block of examples of usage, they are as exported as they are written (like <pre> in HTML).

Example 1.16. Multiline @example block

@example
list <string> servers = GetListOfNSServers("example.com.");
boolean success = AddNewNSServer("ns4.example.com.", "example.com.");

1.3.4. Description tag @param

Describes the parameter of the function. The order of @param tags is significant.

Example 1.17. @param tag

/**
 * Adds a new NS Server into list of domain NS servers.
 *
 * @param new_ns_server FQDN
 * @param domain
 * @return boolean successfull
 */
global boolean AddNewNSServer (string new_ns_server, string domain) {
   ...
   return success;
}

1.3.5. Description tag @ref

Single-line version of @see tag.

Example 1.18. @ref tag

@ref AddNewNSServer()

1.3.6. Description tag @return

Description of the return value.

Example 1.19. @return tag

/**
 * Removes the NS Server from list of domain NS servers.
 *
 * @param ns_server FQDN
 * @param domain
 * @return boolean successfull
 */
global boolean RemoveNSServer (string ns_server, string domain) {
   ...
   boolean success = true;

   return success;
}

1.3.7. Description tag @short

Short single-line description of the function.

Example 1.20. Standard description

@short This function does nothing valuable

Example 1.21. Automatic description

/**
* This first line is identified as @short
*
* This multi-line @descr (after a newline) is automatically
* taken as the function description.
*/

See the @descr tag.

1.3.8. Description tag @since

Since which version thix function exists. This is not a commonly used tag.

Example 1.22. @since tag

@since: 2.12.65

1.3.9. Description tag @stable

Defines that the function has a stable API and we don't plan to change it for years.

See tag @unstable.

This tag might changes the default value of the file's stability of the API (just for the current function).

Example 1.23. @stable tag

@stable

1.3.10. Description tag @struct

This tag is used to represent the used data-structure closer. It's as represented as it's written (such as the <pre> HTML tag).

Example 1.24. @struct tag

@struct returns $[
    // example.com.
    "domain"     : "domain name",

    // list of NS servers assigned to the domain
    "ns_servers" : [ "ns1", "ns2", ... ],

    // map of MX servers $[ "server_name" : priority ]
    "mx_servers" : $[ "mx1" : 10, "mx2" : 5 ],
]

1.3.11. Description tag @unstable

Defines that the function has unknown of unstable API and we plan (or might) to change it in the future.

See the @stable tag.

Example 1.25. @unstable tag

@unstable