Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate documentation from code

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.

like image 598
Yes Man Avatar asked Mar 17 '12 11:03

Yes Man


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()
    {
    }
}
like image 112
Cody Gray Avatar answered Sep 28 '22 22:09

Cody Gray