共用方式為


<include> 檔標籤

標記 <include> 可讓您參考另一個檔案中的批註,以描述原始程式碼中的類型和成員。 此標籤是直接在原始程式碼檔案中放置檔批註的替代方案。 例如,您可以使用 <include> 來插入在整個小組或公司中使用的標準「重複使用」批註。

語法

/// <include file='filename' path='tag-path[@name="ID"' />

參數

filename
包含文件的檔案名稱。 檔案名稱可以使用路徑進行限定。 以單引號或雙引號將名稱括起來。 如果 filename 找不到 ,則編譯器會發出警告。

tag-path
有效的 XPath 運算式,可選取檔案中包含的所需節點集。

name
標記中位在註解前面的名稱規範;name 會有 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>

另請參閱

XML 檔