ADB2.3使用指南
ADB2.3使用方法如下圖所示:
(1)主界面:
(2)批量選擇:
4.生成的文檔
(1)命名空間頁(yè)面:
2.類(lèi)型頁(yè)面:
3.成員頁(yè)面:
5.開(kāi)發(fā)自定義文檔生成器
ADB2.3支持加載用戶自定義的文檔生成器,用戶可根據(jù)自己的需求開(kāi)發(fā)文檔生成器,下面以開(kāi)發(fā)自定義文檔生成器MyBuilder為例,說(shuō)明如何開(kāi)發(fā)自定義文檔生成器:
⑴目標(biāo):
開(kāi)發(fā)一個(gè)自定義文檔生成器,該文檔生成器在ADB默認(rèn)文檔生成器基礎(chǔ)上擴(kuò)展以下功能:
a.在XML文檔注釋可以用插入圖片;
b.在類(lèi)型頁(yè)面和成員頁(yè)面中增加一個(gè)名稱(chēng)為“自定義節(jié)”的內(nèi)容節(jié)。
⑵開(kāi)發(fā)步驟
a.點(diǎn)擊菜單 工具->生成自定義文檔解決方案->擴(kuò)展XML文檔注釋?zhuān)趶棾龅膶?duì)話框中輸入文檔生成器名稱(chēng)
b.打開(kāi)工程中的MyBuilder.cs文件,輸入以下代碼
using System; using System.Collections.Generic; using System.Text; using ADB.Factories; using Microsoft.VisualBasic.FileIO; namespace CustomBuilder { /// /// MyBuilder /// public class MyBuilder : ADB.Factories.MSDNStyleCHMDocumentBuilder { static PageSection[] _memberPageSections, _typePageSections; public MyBuilder(IGetData data, IInteract interact) : base(data, interact) { //base.MemberPageSections為頁(yè)面原有的節(jié),將自定義節(jié)插入到頁(yè)面的最后 _memberPageSections = new PageSection[base.MemberPageSections.Length + 1]; base.MemberPageSections.CopyTo(_memberPageSections, 0); _memberPageSections[base.MemberPageSections.Length] = new PageSection("自定義節(jié)", PageSectionType.FromXML, "CustomSection"); //base.MemberPageSections為頁(yè)面原有的節(jié),將自定義節(jié)插入到頁(yè)面的最后 _typePageSections = new PageSection[base.TypePageSections.Length + 1]; base.TypePageSections.CopyTo(_typePageSections, 0); _typePageSections[base.TypePageSections.Length] = new PageSection("自定義節(jié)", PageSectionType.FromXML, "CustomSection"); } //重寫(xiě)基類(lèi)的MemberPageSections屬性 public override PageSection[] MemberPageSections { get { return _memberPageSections; } } //重寫(xiě)基類(lèi)的TypePageSections屬性 public override PageSection[] TypePageSections { get { return _typePageSections; } } protected override string GetTag(System.Xml.XmlElement elem, string xmlFile) { switch (elem.Name) { case "CustomSection": { //生成"自定義節(jié)"的內(nèi)容 return GetInnerTags(elem, xmlFile); } case "image": { StringBuilder tag = new StringBuilder(); string src = elem.GetAttribute("src"); if (!string.IsNullOrEmpty(src)) { try { //將圖片拷貝到生成頁(yè)面的目錄中 //(通過(guò)屬性HtmlFileDirectory獲取保存頁(yè)面的目錄) FileSystem.CopyFile( xmlFile + "\\" + src, HtmlFileDirectory + "\\" + src, true ); } finally { } //生成HTML標(biāo)志 tag.AppendFormat("<img src='{0}'/>", src); } return tag.ToString(); } default: { //其它標(biāo)志由基類(lèi)處理 return base.GetTag(elem, xmlFile); } } } } }
c.點(diǎn)擊調(diào)試按鈕調(diào)試自定義文檔生成器
⑶測(cè)試
由于測(cè)試的類(lèi)及其XML注釋?zhuān)?/p>
namespace ClassLibrary1 { /// /// Class摘要 /// /// /// 自定義的節(jié) ///<image src="1.gif"/>/// public class Class1 { }}
用自定義文檔生成器MyBuilder生成的文檔
⑷讓ADB啟動(dòng)時(shí)自動(dòng)加載文檔生成器
在ADB目錄下新建目錄MyBuilder,并將MyBuilder.dll和MyBuilder.builder拷貝到該文件夾中
ADB2.3支持的注釋標(biāo)記