XML comments are added to source code by prefixing the XML comment lines with three forward slashes. Visual Studio will automatically insert a documentation template whenever three forward slashes are typed within a C# source code file. Visual Studio's intellisense system also works within XML comments, using the comments to enhance the information presented about a class, constructor or other member.
An example of a function documented with XML comments is shown below:
/// <summary>
///<para>Non-HTML files like Adobe Acrobat PDF files and Word
///documents are stored with their original URLs partially
///encoded in their filenames. This function will return the
///original URL of the file.</para>
///<para>The encoding done by the Index Server Companion removes
///characters that cannot be present in Windows filenames
///(these are: \/:*?"<>|). The decoding performed is:</para>
/// <list type="table">
/// <listheader><term>Find</term><description>Replace</description></listheader>
/// <item><term>^f</term><description>\</description></item>
/// <item><term>^b</term><description>/</description></item>
/// <item><term>^c</term><description>:</description></item>
/// <item><term>^s</term><description>*</description></item>
/// <item><term>^q</term><description>?</description></item>
/// <item><term>^d</term><description>\</description></item>
/// <item><term>^l</term><description><</description></item>
/// <item><term>^g</term><description>></description></item>
/// <item><term>^p</term><description>|</description></item>
/// </list>
/// </summary>
/// <param name="FileName">The document's original filename.</param>
/// <returns>Decoded filename</returns>
/// <exception cref="System.Exception">Throws an exception when something goes wrong.</exception>
private string CreateURLFromFileName(string FileName)
{
}
To get the resulting XML Documentation file, we call the csc compiler with the /doc option.
csc /doc:HelloWorld.xml helloworld.cs
HTML Web Pages
You may be asking yourself: how do I get nicely formatted web pages? Well, you could write your own XSL to transform the XML documentation file, or you could use Visual Studio.NET. By using the Tools -> Build Comment Web Pages option, you can get a set of html files detailing your entire project or solution. Here is a screen shot by building web pages for our HelloWorld example:
Predefined Tag Used for
<c> a way to indicate that text within a description should be marked as code
<code> a way to indicate multiple lines as code
<example> lets you specify an example of how to use a method or other library member
<exception> lets you document an exception class
<include> lets you refer to comments in another file, using XPath syntax, that describe the types and members in your source code.
<list> Used to insert a list into the documentation file
<para> Used to insert a paragraph into the documentation file
<param> Describes a parameter
<paramref> gives you a way to indicate that a word is a parameter
<permission> lets you document access permissions
<remarks> where you can specify overview information about the type
<returns> describe the return value of a method
<see> lets you specify a link
<seealso> lets you specify the text that you might want to appear in a See Also section
<summary> used for a general description
<value> lets you describe a property
Reference : http://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?article=21
http://www.winnershtriangle.com/w/Articles.XMLCommentsInCSharp.asp
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment