ADB2.3使用指南
ADB2.3使用方法如下圖所示:
(1)主界面:
(2)批量選擇:
4.生成的文檔
(1)命名空間頁面:
2.類型頁面:
3.成員頁面:
5.開發(fā)自定義文檔生成器
ADB2.3支持加載用戶自定義的文檔生成器,用戶可根據(jù)自己的需求開發(fā)文檔生成器,下面以開發(fā)自定義文檔生成器MyBuilder為例,說明如何開發(fā)自定義文檔生成器:
⑴目標(biāo):
開發(fā)一個自定義文檔生成器,該文檔生成器在ADB默認(rèn)文檔生成器基礎(chǔ)上擴(kuò)展以下功能:
a.在XML文檔注釋可以用插入圖片;
b.在類型頁面和成員頁面中增加一個名稱為“自定義節(jié)”的內(nèi)容節(jié)。
⑵開發(fā)步驟
a.點(diǎn)擊菜單 工具->生成自定義文檔解決方案->擴(kuò)展XML文檔注釋,在彈出的對話框中輸入文檔生成器名稱
b.打開工程中的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為頁面原有的節(jié),將自定義節(jié)插入到頁面的最后 _memberPageSections = new PageSection[base.MemberPageSections.Length + 1]; base.MemberPageSections.CopyTo(_memberPageSections, 0); _memberPageSections[base.MemberPageSections.Length] = new PageSection("自定義節(jié)", PageSectionType.FromXML, "CustomSection"); //base.MemberPageSections為頁面原有的節(jié),將自定義節(jié)插入到頁面的最后 _typePageSections = new PageSection[base.TypePageSections.Length + 1]; base.TypePageSections.CopyTo(_typePageSections, 0); _typePageSections[base.TypePageSections.Length] = new PageSection("自定義節(jié)", PageSectionType.FromXML, "CustomSection"); } //重寫基類的MemberPageSections屬性 public override PageSection[] MemberPageSections { get { return _memberPageSections; } } //重寫基類的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 { //將圖片拷貝到生成頁面的目錄中 //(通過屬性HtmlFileDirectory獲取保存頁面的目錄) FileSystem.CopyFile( xmlFile + "\\" + src, HtmlFileDirectory + "\\" + src, true ); } finally { } //生成HTML標(biāo)志 tag.AppendFormat("<img src='{0}'/>", src); } return tag.ToString(); } default: { //其它標(biāo)志由基類處理 return base.GetTag(elem, xmlFile); } } } } }
c.點(diǎn)擊調(diào)試按鈕調(diào)試自定義文檔生成器
⑶測試
由于測試的類及其XML注釋:
namespace ClassLibrary1 { /// /// Class摘要 /// /// /// 自定義的節(jié) ///<image src="1.gif"/>/// public class Class1 { }}
用自定義文檔生成器MyBuilder生成的文檔
⑷讓ADB啟動時自動加載文檔生成器
在ADB目錄下新建目錄MyBuilder,并將MyBuilder.dll和MyBuilder.builder拷貝到該文件夾中
ADB2.3支持的注釋標(biāo)記