Whenever you write classes and functions in Visual Studio, it is a good practice to write XML comments for documentation. For example, before a function starts, you can document which parameters the function expects, briefly describe them, and explain what the function does exactly. Creating such XML comments for an entire project is particularly useful because it allows others to generate comprehensive documentation for the project.
A few code-checking tools like StyleCop also expect developers to write the proper documentation during development. A useful alternative is a free tool called GhostDoc, which automates the process of writing code comments, and it integrates into Visual Studio 2005/2008/2010. The rest of this tip explains how to use GhostDoc to generate Visual Studio code documentation automatically.
After installing GhostDoc, open your Visual Studio.NET project and select the function name for which you want to generate the documentation (
ProcessLogin in this example). Right click to generate the context menu, and select "Document this". The function documentation will be added automatically, as shown below:
/// Processes the login.
/// <param name="verificationKey">The verification key.</param>
/// <param name="objOutput">The obj output.</param>
public static void ProcessLogin(string verificationKey, ref LoginOutput objOutput)
You can generate documentation for classes, functions, etc. easily with this tool and then edit it as required. Using GhostDoc is much faster than writing the documentation from scratch. You can also use the shortcut key (default: Ctrl+Shift_D) instead of the context menu to generate the documentation.