Part 21 - Documentation
|
A communicable material used to explain some attributes of an object, system or procedure. |
I've saved the most important for last, as documentation is itself, just as important as the code which it describes.
When documenting your code, be sure to remember:
- All your documents should be in English.
- Use full sentences.
- Avoid spelling/grammar mistakes.
- Use present tense.
Documentation is placed in tripled double-quoted strings right below what you are documenting.
That "docstring" is the least you can do to document your code. It gave a simple summary.
If your docstring spans more than one line, then the quotes should go on their own lines.
You may have noticed that 'Says "hello" to the world.' is not a full sentence. For the first sentence in a summary, you can imply "This member".
Parameters should also be documented.
To read it to yourself, it goes as such: 'Say "hello" to the given name. Parameter name is defined as the name to say hello to.'
This keeps in line with using full sentences.
If describing the parameter takes more than one line, you should move it all to a new line and indent.
The same goes with any block.
Here is a list of all the tags that can be used
Tag |
Description |
|---|---|
No tag |
A summary of the member. |
|
This specifies the parameter |
|
This describes what the method returns. |
|
This provides descriptive text about the member. |
|
Gives a reason why an |
|
Provides an example. |
|
Includes an excerpt from another file. |
|
Describe a required Permission. |
|
Lets you specify the reference that you might want to appear in a See Also section. |
And a list of inline tags
Tag |
Description |
|---|---|
|
Bullet list |
|
Numbered List |
|
Provides an inline link to a reference. e.g. <int> or <string> would link. |
|
References to a parameter of the method. |
Here's some examples of proper documentation:
This should give you a good view on how to document your code.
I think Dick Brandon said it best:
Quote: Dick Brandon
Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing.
Go on to Part 22 - Useful Links
