|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThis article shows how to create documentation in C# in a simple and fast way. Like my previous articles, this one too focuses beginner to intermediate level. Advance developers please scroll to the bottom of this article. Remember the days when programmers used to work hard to do the documentation? Trust me, it's a huge difference nowadays. Now, all a programmer need to do is to embed the XML documentation right into the code and let Visual Studio .NET perform the rest. Note: If you are very new to XML, click here to checkout my previous article on XML walkthrough. To start with, just follow the instructions step by step. Step By Step Walkthrough:
Creating a simple class XML file (the class which will have the comments which will be read by our Visual Studio .NET to create the XML documentation)Replace the code in the class with the following: using System;
namespace TestXMLdoc
{
/// <summary>
/// This project shows how to create XMl documentation in C#
/// </summary>
public class TestXMLdoc
{
/// <summary>
/// m_iTestVar is a module level test variable for storing int
/// </summary>
private int m_iTestVar;
/// <summary>
/// m_sTestVar is a module level test variable for storing string
/// </summary>
private string m_sTestVar;
/// <summary>
/// TestXMLdoc is the constructor
/// </summary>
public TestXMLdoc()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// TestReturnBack is a test method which
/// simply takes a name and returns it back.
/// </summary>
/// <param name="sName"></param>
/// <returns></returns>
public string TestReturnBack(string sName)
{
return "Your name is " + sName;
}
}
}
Compiling your application after specifying the documentation filenameNote: If you are not using the Visual Studio .NET IDE, you should go for the first one from the following optionss:
Unlike Java, Microsoft Visual C# generates XML documentation instead of HTML, and as we know about XML, it's mould-able and later can be used anywhere else we need. The following is a list of tags along with their description which can be used in creation of XML documentation.
Opening the XML documentation file
Creating an HTML document file automaticallyWasn't that fun? It was.. I know. But that was just a trailer, let's see the whole movie.
That's the result of your patience, hard work and cooperation. Note: The above example was for people who need a tool to suffice their minimum requirements. For advance documentation, you would like to opt for a more sophisticated tool like NDoc Code Documentation Generator for .NET. NDoc generates class library documentation from .NET assemblies and the XML documentation files generated by the C# compiler (or with an add-on tool for VB.NET). And the output looks like the following:
NDoc uses pluggable documenters to generate documentation in several different formats, including the MSDN-style HTML Help format (.chm), the Visual Studio .NET Help format (HTML Help 2), and MSDN-online style web pages. You can download the latest version: NDOC 1.3 Beta or NDOC 1.2. Thanks to Ms. Manisha Mahajani for reviewing the article for errors. Njoi programming!! ;)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||