@param

Summary

Documents a function or method parameter.

Syntax

@param name description

Parameters

name
The name of the parameter to document. This must match the name of the parameter at the current index.
description
The documentation for the parameter.

Description

The @param tag is used to document individual parameters of a function or method.

@param tags must be defined in order. Thus, the second parameter for a method cannot be documented before the first parameter. The first argument the @param tag expects is the name of the parameter. This must match the name of the parameter (in the order they were defined); otherwise, an error will be generated. The name must be repeated in the documentation for maintainability - it makes it easy to identify if we are documenting the wrong parameter.

It is not necessary to include information about the parameter type. The parameter type is automatically included in the generated documentation.

Examples

Documenting an 'add' Method
1
2
3
4
5
6
7
8
9
10
11
12
13
class Calculator
{
    /**
     * Adds two numbers together and returns the result.
     *
     * @param x The first number in the addition operation.
     * @param y The second number in the addition operation.
     */
    int add(int x, int y)
    {
        return x + y;
    }
}

See Also

Share

HTML | BBCode | Direct Link