Sandcastle Documentation Generation

At work I have been the champion of an Integration Framework for our Archive One product. This is a set of API’s, events and open file formats embedded into the Archive One products that allow customization ‘around the edge’.

The kind of thing that can be done with the Integration Framework is running searches, interworking with the AD schema, running archive policies, integration into Network Management Systems or Document Management Systems and the like – it really opens the product to other business systems as either the slave (other systems controlling Archive One) or the master (other systems being controlled by Archive One).

We have been writing up the API documentation recently and had initially started this as a (Word) document we would publish to customers and developers. I looked into NDoc which now seems dead (at least for VS2005 and .NET2.0) and then came across Sandcastle. Sandcastle is Microsoft’s answer to NDoc, it allows the collation and generation of documentation from the XML comments embedded in your code

Right now it is at CTP stage and is command line driven – a few projects have sprung up which provide a UI for it (backing on to the CLI). One is a VS2005 add in (which I installed but it wasn’t immediately obvious how to use it, so I didn’t really pursue) and other is SandcastleGUI – this provides a single form where you choose the options, point it to the folders containing the Sandcastle app, the code DLLs and where you want the docs to end up and then simply kick it off.

When you hit ‘Start Documenting’ it closes the form and fires off a command prompt window (batch files) which in turn fires off other command prompt windows until it’s collated everything and built the documentation.

It allows you to generate html documents – a whole website, multiple pages, images etc or a compiled help file (.chm) or even both if you wish.

Another of the options is ‘Online MSDN Links’ this provides a MSDN link for every object type it can find in the base class library. Be warned enabling this option means it has to reflect through about 14500 classes / objects in the framework so that they can be indexed and used if found in your app / library. Enabling this option increases the time to generate from about 1 minute (on my Dual Core laptop) to about 15 minutes – I’d recommend disabling this option whilst developing the app / library and only enable it when you are doing the final or release build.

The resulting documentation is really good quality – pretty much the same format as MSDN documentation.

For the effort of a few extra XML comment lines in your code this provides great value and a very comprehensive resulting document.

The easiest way I have found to integrate this into VS2005 is to set it up as an External Tool.

I create a folder under the solution folder named ‘Documentation’, I run SandcastleGUI manually the first time around, do all the required configuration and then save the settings to a file in the solution directory (don’t save it in the ‘Documentation’ folder as that is cleared out with each Sandcastle run.

I have an ‘External Tool’ configured which points to SandcastleGUI with parameters of :

/document $(ProjectDir)settings.SandcastleGUI

(I called the settings file ‘settings.SandcastleGUI’) and called the tool :

Sandcastle This Project

This allows me to simply click this tool and it will go away and create all the documentation (with my chosen parameters) for the project.

As I mentioned this is CTP at the moment – I look forward to the release version, hopefully fully integrated into Visual Studio and stylesheets that exactly mimic MSDN.

One thought on “Sandcastle Documentation Generation

  1. Hi,

    When I first started using Sandcastle I came across that VS2005 add-in that you mentioned too. I installed it, clicked around a bit, and then stared at the screen for about 10 minutes before I said to myself, "Ok, maybe I’ll write my own." 😉

    I really wanted a free, integrated solution in Visual Studio for building compiled help and I was disappointed when VS2005 didn’t have one – so I did write my own.

    Check out a@http://www.codeplex.com/DocProject@DocProject if you’re interested in building compiled help from VS2005. It’s got some good documentation and tutorials (in the form of wikis on CodePlex) and is written from the ground-up in C#. One of the best features, IMO, is a fully-functional, AJAX-enabled, ASP.NET Web Application project template (called a DocSite) that provides a web interface for the compiled help that it builds. To build the compiled help you just build the project.

Leave a Reply

Your email address will not be published. Required fields are marked *