Share via


Creating CHM Help Files Using Sandcastle

Its common nature that, every body writes comments in their codes. But, little know that, these comments in your class can help lot if properly done. Means, creating help files automatically from the class like Microsoft styles CHM (Microsoft Compiled HTML file).

** **First, write the proper comments in your class, properties

 Make sure that, you are writing the comments in a stipulated format (XML style, please refer http://msdn.microsoft.com/en-us/magazine/cc302121.aspx)

Some sample comments,

 /// <summary>
/// Information about FOP of credit card
/// </summary>

Install the sandcastle Download the sandcastle from http://shfb.codeplex.com/releases/view/29710) and install it. This will be installed in the “C:\Program Files\Sandcastle”. Please make sure the installed folder contains “Examples\generic” as this folder contains the GUI form of the sandcastle interface. You can also, use the command prompt commands to create the CHM file.

Creating Comments XML  You need to pass the comments written in C# in XML format. This can be done by using Doc property of the C# compiler.

  • Go to the command prompt from Visual studio command prompt

  • Run this below command

** C:\Program Files\Microsoft Visual Studio 9.0\VC>csc /t:library /recurse: D:\WORKS\Classes\.cs  /doc:comments.xml**

  • /T:Library  - to create a library after compilation
  • /recurse:<Folder Path of c#> will take all the C# classes from the root and also, sub folders
  • /doc : Comments.xml   -- The file name of where all the comments will be stored (name can be your choice)

This will create “Comments.XML” and also, the DLL file which comprises of entire class included.

You can also use the DLL which you compiled from your VS 2005 / 2008 and use only the Comments.xml.

Please make sure all the properties which are exposed as PUBLIC are having XML comments, otherwise, the compiler will throw compilation error.

**Creating CHM Files
**Go to the folder where you installed the sandcastle (C:\Program Files\Sandcastle) and go to Examples\generic in the same folder.

 

You will find an exe named “SandcastleGui.exe” and execute it

 

 In the assemblies, tab, click the add button and select the Dll file

  • **In the comments, tab, add the Comments.XML **
  • In the text box, give a proper name for your CHM file
  • Click the Build button
  • Now, it will open up a window and ask for *.SCProj type, browse to  “C:\Program Files\Sandcastle\Examples\generic” and select the test.scproj
  • Asking for overwrite, say yes.
  • The build will start and create a folder called in the “C:\Program Files\Sandcastle\Examples “ folder
  • Open up the folder you may see “VS2005” and CHM folder

Double click the CHM and see the details…

A good looking….help file……………