In YARDoc documentation, I've noticed that usually we use the @param
tag as @param variable_name [VariableType] some plain English description
. However, in some parts of the documentation, I see that the variable name and variable type are switched, i.e. @param [VariableType] variable_name some plain English description
. Is this intentional? Are both formats allowed? Is there some debate on this? Which format is more popular?
In YARDoc documentation, both formats for the @param
tag are allowed and considered valid. The format @param variable_name [VariableType] some plain English description
is called the "Ruby Style" and is the default format used by YARDoc. The format @param [VariableType] variable_name some plain English description
is called the "Java Style" and is also supported by YARDoc.
There is some debate on which format is better, but ultimately it comes down to personal preference and the conventions of the codebase being documented. Some developers prefer the Ruby Style because it follows the natural order of the parameter declaration in Ruby, while others prefer the Java Style because it puts the type information up front and can be easier to read.
In general, the Ruby Style is more popular in the Ruby community and is the default format used by YARDoc, so you'll see it more often. However, both formats are valid and supported by YARDoc, so you should choose the one that works best for you and your project.