I guess what I'm asking is, what would be the best way to make sure my code is sufficiently documented and worded right for other people to use?
As open source, the most important comments of all are the copyright and license agreement comment. Rather than a big long comment at the start of every file, you might want to use a short and sweet one that briefly specifies copyright and refers the reader to license.txt in the root directory.
I know you should always comment everything and I'm going to be putting in the @params feature for every method, but are there any other tips in general?
Comment everything? No. Comment that code which truly does need commentary. Comment sparingly. As a potential user of a chunk of code, which of the following two versions of a class definition would you prefer to see?
Version A:
class Foo {
private:
SomeType some_name; //!< State machine state
public:
...
/**
* Get the some_name data member.
* @return Value of the some_name data member.
*/
SomeType get_some_name () const { return some_name; }
...
};
Version B:
/**
* A big long comment that describes the class. This class header comment is very
* important, but also is the most overlooked. The class is not self-documenting.
* Why is that class here? Your comments inside the class will say what individual parts
* do, but not what the class as a whole does. For a class, the whole is, or should be,
* greater than the parts. Do not forget to write this very important comment.
*/
class Foo {
private:
/**
* A big long comment that describes the variable. Just because the variable is
* private doesn't mean you don't have to describe it. You might have getters and
* setters for the variable, for example.
*/
SomeType some_name;
public:
...
// Getters and setters
...
// Getter for some_name. Note that there is no setter.
SomeType get_some_name () const { return some_name; }
...
};
In version A I've documented everything -- except the class itself. A class in general is not self-documenting. The comments that are present in version A are absolutely useless, or even worse than useless. That's the key problem with the "comment everything" attitude. That little terse comment on the private data member communicates nothing, and the doxygen comments on the getter has negative value. The getter get_some_name() doesn't really need a comment. What it does and what it returns is patently obvious from the code. That there is no setter -- you have to infer that because it's not there.
In version B I've documented that which needs commenting. The getter doesn't have a doxygen comment, but it does have a comment mentioning that there is no setter.
Make your comments count, and beware that comments oftentimes are not maintained to reflect changes to the code.