I don't know if it's possible but I'm wondering if there is a way to keep the code and the documentation in separate files but still work the same as it does normally with inline documentation.
1 Answers
Yes, you can keep XML documentation comments in external files and include them in your code files using the <include>
tag.
From the MSDN documentation:
The tag lets you refer to comments in another file that describe the types and members in your source code. This is an alternative to placing documentation comments directly in your source code file. By putting the documentation in a separate file, you can apply source control to the documentation separately from the source code. One person can have the source code file checked out and someone else can have the documentation file checked out.
For example, you might have a file named xml_include_tag.doc
, containing the following documentation comments:
<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>
And you would include this documentation in your code file like so:
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
static void Main()
{
}
}
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
public void Test()
{
}
}

- 239,200
- 50
- 490
- 574
-
So you have to do this for everything you want to add documentation for? Methods, classes, etc.? – Yes Man Mar 17 '12 at 18:38
-
1Well... you should do this only for large sections of documentation. Most of the time I'd recommend keeping the code and documentation in the same file. – Rene Saarsoo Mar 18 '12 at 20:29
-
1It's very useful if you have two separate groups managing the code and the documentation. Otherwise, yes, you should probably just keep them together. This is code documentation, intended for use by other developers who consume your public APIs; not quite the same as something that faces the public. – Cody Gray - on strike Mar 19 '12 at 01:36