Code Documentation


Intro

My notes on how to document C# code.

 


XML Documentation

“XML documentation comments are a special kind of comment, added above the definition of any user-defined type or member. They are special because they can be processed by the compiler to generate an XML documentation file at compile time. The compiler-generated XML file can be distributed alongside your .NET assembly so that Visual Studio and other IDEs can use IntelliSense to show quick information about types or members. Additionally, the XML file can be run through tools like DocFX and Sandcastle to generate API reference websites.” Source: Document your code with XML comments. In this document, you will find the XML syntax to use to describe your code.

XML documentation comments use triple forward slashes (///) and an XML formatted comment body. For example:

/// <summary> /// This class does something. /// </summary> public class SomeClass { }

Visual Studio Auto-Documentation

 

Visual Studio can help you document code elements such as classes and methods, by automatically generating the standard XML documentation comment structure. 

 


Comparison of Documentation Generators

Wikipedia has this table comparing different documentation generators for different languages: Comparison of documentation generators