<include>
文档标记
通过 <include>
标记,可在其他文件中引用描述源代码中类型和成员的注释。 此标记是对直接在源代码文件中放入文档注释的替代方法。 例如,可使用 <include>
插入整个团队或公司使用的标准“样板”注释。
语法
/// <include file='filename' path='tag-path[@name="ID"' />
参数
filename
包含文档的文件的名称。 可使用路径来限定文件名。 将名称括在单引号或双引号中。 如果编译器没有找到 filename
,它会发出警告。
tag-path
有效 XPath 表达式,它选择文件中包含的所需节点集。
name
标记中的名称说明符(位于注释之前);name
将有 ID
。
ID
标记的 ID(位于注释之前)。 将 ID 括在单引号或双引号中。
备注
<include>
标记使用 XML XPath 语法。 有关使用 <include>
进行自定义的方法,请参阅 XPath 文档。
使用 /doc
进行编译可以将文档注释处理到文件中。
示例
此示例使用多个文件。 第一个文件(使用 <include>
)包含以下文档注释:
// xml_include_tag.cpp
// compile with: /clr /doc /LD
// post-build command: xdcmake xml_include_tag.dll
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
public ref class Test {
void TestMethod() {
}
};
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
public ref class Test2 {
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 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>