Sandcastle是微軟提供的一個根據XML註釋和DLL文件生成幫助文件的工具,目前是在CodePlex上的一個開源項目,能夠去這裏下載:Sandcatle 項目
Sandcastle 自己是一個console的程序,爲了方便使用,咱們可使用他的GUI版本:Sandcastle Help File Builderhtml
咱們建立一個簡單的ClassLibrary1項目最爲示範:工具
using System; using System.Collections.Generic; using System.Text; namespace ClassLibrary1 { /// <summary> /// A sample class to show something using Sandcastle /// </summary> public class SampleClass { private string _propertyValue; /// <summary> /// Gets or sets the property value. /// </summary> /// <value>The property value.</value> public string Property { get { return _propertyValue; } set { _propertyValue = value; } } /// <summary> /// Determines whether the property is null. /// </summary> /// <returns> /// <c>true</c> if property is null; otherwise, <c>false</c>. /// </returns> public bool IsPropertyNull() { bool result = false; if (this.Property == null) { result = true; } return result; } /// <summary> /// Determines whether the property is null. /// </summary> /// <returns> /// <c>true</c> if property is empty; otherwise, <c>false</c>. /// </returns> /// <example> /// This example shows how you might use this method: /// /// <code> /// SampleClass sample = new SampleClass(); /// /// if (sample.IsPropertyEmpty()) /// { /// Console.WriteLine("The property is empty"); /// } /// else /// { /// Console.WriteLine("The property contains value " + sample.Property); /// } /// </code> /// </example> public bool IsPropertyEmpty() { bool result = this.IsPropertyNull(); if (!result) { result = (Property.Trim().Length == 0); } return result; } } }
代碼很簡單,注意其中的XML註釋。ui
打開項目的屬性,在「Build」選項中,確保「XML documentation file:」被選中了。this
打開Sandcastle Help File Builder並新建一個項目:spa
爲Sandcastle Help File Builder項目添加編譯生成的DLL文件,右鍵點擊項目右邊的「Documentation Sources",選擇「Add Documentation Source...」code
選擇剛剛生成的DLL文件。htm
在項目的屬性窗口,你能夠根據須要修改一些設置。blog
點擊Build the help file來生成文檔。文檔
這是最終生成的文檔:get
出處:http://www.cnblogs.com/DotNetNuke/archive/2009/04/23/1441899.html