Is there a standard convention (like phpdoc or python's docstring) for commenting C# code so that class documentation can be automatically generated from the source code?
A python comment may be a single line comment or a multiline comment written using single line comments or multiline string constants. Document strings or docstrings are also multiline string constants in python but they have very specific properties unlike python comment.
A quick recap on comments vs docstrings: Use comments to explain how code works. Comments are great for leaving notes for people working on your program. Docstrings provide documentation about functions, classes, and modules. Use docstrings to teach other developers how to use your program.
In programming, a docstring is a string literal specified in source code that is used, like a comment, to document a specific segment of code.
You can use XML style comments, and use tools to pull those comments out into API documentation.
Here is an example of the comment style:
/// <summary> /// Authenticates a user based on a username and password. /// </summary> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <returns> /// True, if authentication is successful, otherwise False. /// </returns> /// <remarks> /// For use with local systems /// </remarks> public override bool Authenticate(string username, string password)
Some items to facilitate this are:
GhostDoc, which give a single shortcut key to automatically generate comments for a class or method. Sandcastle, which generates MSDN style documentation from XML comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With