NDoc 用户指南   [回目录] NDoc 1.3

<include>

[此文档为预发布版本,在未来版本中有可能改变。]

<include> 标记指示将代码文件(*.cs)外部的某 XML 文件中的一部分、作为 XML 文档注释、包含进代码文件来。

<include file='filename' path='tagpath[@name="id"]' />

其中:

filename
包含 XML 文档注释的文件名。该文件名可包含路径。将 filename 括在单引号中 (' ')。
tagpath
filename 中指向标记名的标记路径(使用 XPath 语法)。将此路径括在单引号中 (' ')。
name
注释前边的标记中的名称说明符;名称具有一个 id
id
位于注释之前的标记的 ID。将此 ID 括在双引号中 (" ")。

应用于

所有的类型及成员。

备注

这是除了将文档注释直接置于源代码文件中之外的另一种可选方法。

<include> 标记使用 XML XPath 语法。有关自定义 <include> 使用的方法,请参见 XPath 文档。

示例

以下是一个多文件示例。第一个文件使用 <include>,如下所列:

[C#]
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
   public static void Main()
   {
   }
}

/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
   public void Test()
   {
   }
}

第二个文件 xml_include_tag.doc 包含下列文档注释:

<MyDocs>

<MyMembers name="test">
<summary>
The summary for this type.
</summary>
</MyMembers>

<MyMembers name="test2">
<summary>
The summary for this other type.
</summary>
</MyMembers>

</MyDocs>

编译器输出的 XML 文档

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>t2</name>
    </assembly>
    <members>
        <member name="T:Test">
            <summary>
The summary for this type.
</summary>
        </member>
        <member name="T:Test2">
            <summary>
The summary for this other type.
</summary>
        </member>
    </members>
</doc>

请参见

标记用法 | NDoc 支持的标记 | Microsoft 的定义