|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionDocumentation has been always a neglected task in the software development life cycle. While developing applications, most of the software developing professionals including senior professionals tend to forget about documentation although everyone is aware about the difficulties that are faced during code maintenance application. Documentation is a very important aspect specially when developing large and very big applications involving a number of modules. When developing an application with C#, we can minimize the effort of making and maintaining the application documentation. As a C# application developer, it is common to give inline comments, these inline comments can be the source to generate a strong and more accurate documentation. Inline comments are the most important part of any code as they provide valuable information about the part of the code that is written. And most importantly it is written when the system is constructed. One of the wonderful features of the C# compiler is that it supports automatic creation of documentation using comments written in the code, the only distinction being that the documentation is produced in XML. Unlike other automated documentation provided by various programming languages, that generates HTML based documentation, C# produces in XML but there are tools available that take XML files as the input and produce HTML based documentation. As the C# stores all the comments in an XML file, users have the flexibility to develop excellent documentation from C#. Code comments, user manuals, developer manuals, test plans, and many other documents can be generated from a single source using XML tags. The process of generating an XML based documentation is done by adding comments to various parts of the code. The process can be described in the following manner: Source file (.cs) -> C# Compiler (csc.exe) -> XML Documentation (doc.xml)
-> HTML/ Visual Studio Based Documentation
In-depth of C# DocumentationBefore we proceed in depth about the automated documentation part, let's see some of the important aspects that are required to be known when developing the XML based documentation. The main point is that the comments needs to start with " /// <Summary>
/// this is a place where something is done
/// </Summary>
There are various predefined tags that are available for the purpose of generating the document. The developer has the freedom to use any type of XML tags to document the code, only thing is that these tags need to adhere to the XML syntax. The predefined tag indicates the type of documentary information that is being given, and the compiler validates these tags against certain aspects of these and produces the output. Other elements are used for the layout and/or formatting purpose. The C# compiler takes these comments embedded inside the XML tags and builds the XML based documentation. It generates errors when a false reference is encountered. The following lists describe the main documentation elements provided and are available for usage. The important thing to remember is that each element should be written between its opening and closing tags, Also, some of the tags take some further mandatory attributes. For example, the '
Some of the formatting tags are as follows:
C# Documentation ExampleLet's take an example and then try to use the above information to get an automated documentation file. The above is a typical example of an application during the construction phase and then we struggle at the time of maintenance as to what the function or the class was supposed to do! Let's give some comments and do the needful. using System;
using System.Data;
namespace ExampleDocumentation
{
/// <summary>
/// DocumentationClass: Is the class that will be used for explaining the
/// example of automated documentation
/// </summary>
public class DocumentationClass
{
/// <summary>
/// public DocumentationClass () :
/// Is the constructor used for DocumentationClass class
/// </summary>
public DocumentationClass ()
{
}
/// <summary>
/// public void DocumentationClassMethod: Is a void method
/// that does not return anything and takes no parameters.
/// It does the functionality of some addition and subtraction to
/// get the result
/// </summary>
public void DocumentationClassMethod ()
{
}
}
}
As you can see above, now we have added some valuable comments that tend to have lots of value. Now to generate the documentation we can have the following command <Directory>\Microsoft.NET\Framework\v1.1.4322>
In the above, command /doc instructs the compiler to produce the documentation named doc.xml. And this will produce the following output: <?xml version="1.0"?>
<doc>
<assembly>
<name> DocumentationClass</name>
</assembly>
<members>
<member name="T:ExampleDocumentation.DocumentationClass">
<summary>
DocumentationClass: Is the class that will be used
for explaining the example of automated documentation
</summary>
</member>
<member name="M:ExampleDocumentation.DocumentationClass.#ctor">
<summary>
public DocumentationClass () :
Is the constructor used for DocumentationClass class
</summary>
</member>
<member name=
"M:ExampleDocumentation.DocumentationClass.DocumentationClassMethod">
<summary>
public void DocumentationClassMethod:
Is a void method that does not return anything
/// and takes no parameters.
///It does the functionality of some addition and substation to
get the result
</summary>
</member>
</members>
</doc>
Some pointsSome of the constants are attached usually with the commented object, these are the ID's that are used to identify the type code and part. Usually these are categorised in the following manner:
Generation of C# documentation with Visual Studio NET 2000 IDEThe documentation can be generated in the following way from the Visual Studio NET 2000 IDE:
Generating HTML based Documentation with Visual Studio .NETThe XML based on the C# compiler can be used to generate the HTML based documentation. Visual Studio takes the doc.xml file generated by the C# compiler and produces whole documentation of HTML pages. To do this we need to follow the same process and then go to the Tools menu in Visual Studio .NET and select Build Comment Web Pages, there will be a dialog box that will appear. In this, select the projects to create the documentation. There is also the possibility to choose the specific part of the solution to generate the documentation. Problems with the C# DocumenterThe automated documentation in C# has some flaws; following are some of them that need to be taken into consideration:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||