Sandcastle方法產生c#.net協助類協助文檔chm

來源:互聯網
上載者:User

標籤:.text   releases   gif   inf   thread   chm   程式集   注意   ons   

Sandcastle方法產生c#.net協助類協助文檔即chm尾碼的文檔,其實是通過C#文檔注釋產生的XML檔案來產生協助文檔的。因此,第一步就是產生XML文檔,

步驟1產生XML文檔

1、開啟VS->隨意建立一個項目(這裡我用的是控制台項目),然後添加一個Student類,即學生資訊,如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp
{
/// <summary>
/// 學生資訊
/// </summary>
public class Student
{
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }

/// <summary>
/// 年齡
/// </summary>
public int Age { get; set; }

/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }

/// <summary>
/// 簡介
/// </summary>
/// <param name="name">姓名</param>
/// <param name="age">年齡</param>
/// <param name="address">地址</param>
/// <returns></returns>
public string Intrduce(string name, string age,string address) {
return "My name is" + name + ",Age:" + age + ",Address:" + address;
}
}
}

PS:注意,我這裡Student類的存取修飾詞是public,由於我這裡只用了一個類,如果不加public就會出現“No APIs found to document. See error topic in help file for details.”的錯誤。

2、右擊程式集選擇屬性,選中XML文檔檔案:

 

 3、儲存,編譯,然後在項目的bin\Debug目錄下你就會看到產生的xml檔案: 

 

 

 4、上述準備工作完成後,我們可以獲得一個TestPrductCHM.xml檔案,下面要做的就是使用 Sandcastle 產生代碼協助文檔

步驟2 Sandcastle 產生協助文檔工具

1、下載Sandcastle工具

Sandcastle是微軟官方的文檔產生工具,NDoc開發停止後,這個貌似也是唯一的一個這方面的工具。它從dll檔案及其xml注釋檔案能夠產生完整的協助文檔,支援多種產生格式(Helpe1x:chm, Helper2x:Hxs, Website,HelperView),結合新發布的Sandcastle Help File Builder視覺化檢視,整個產生過程十分簡單,而且SHFB工具看起來很強大,不僅能夠直接配置產生文檔的各個屬性,而且還支援很靈活的擴充設定,為我們提供完美的.NET類庫文檔成為一個可能。

從這裡下載工具:

Sandcastle:https://github.com/EWSoftware/SHFB/releases,點擊SHFBInstaller_v2018.7.8.0.zip。

Sandcastle Help File Builder:http://shfb.codeplex.com/

在SHFB的壓縮包裡我發現了一個VS外掛程式,因此接下來我就打算用VS來示範,如果不想裝這個外掛程式的話,

可以運行C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\SandcastleBuilderGUI.exe這個程式,結果都是一樣的

2、安裝Sandcastle工具,這裡安裝的是SHFBInstaller,點擊 SandcastleInstaller.exe

 

3、一直點擊next,當出現下面介面時,注意,要去安裝 HTML Help Workshop,否則會出現報錯

(SHFB: Error BE0037: Could not find the path the the HTML Help 1 compiler. See the error number topic in the help file for details.),

是沒有安裝Microsoft HTML Help,當然你安裝了之後可以跳過此步驟。(安裝Microsoft HTML Help  https://docs.microsoft.com/zh-cn/previous-versions/windows/desktop/htmlhelp/microsoft-html-help-downloads)

 

 

Sandcastle方法產生c#.net協助類協助文檔chm

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.