码迷,mamicode.com
首页 > Windows程序 > 详细

Sandcastle方法生成c#.net帮助类帮助文档chm

时间:2018-07-30 13:27:08      阅读:477      评论:0      收藏:0      [点我收藏+]

标签:.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

标签:.text   releases   gif   inf   thread   chm   程序集   注意   ons   

原文地址:https://www.cnblogs.com/1175429393wljblog/p/9389863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!