Separate documentation from code

I don’t know if this is possible, but I wonder if there is a way to save the code and documentation in separate files, but still work the same way as with the built-in documentation.

+4
source share
1 answer

Yes, you can store XML documentation comments in external files and include them in your code files using the <include> .

From the MSDN documentation :

The tag allows you to link to comments in another file that describes the types and elements of the source code. This is an alternative to posting documentation comments directly in the source file. By placing the documentation in a separate file, you can apply the source code to the documentation separately from the source code. One person may have a source code file, and someone else may check the documentation file.

For example, you might have a file called 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 this:

 /// <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() { } } 
+5
source

Source: https://habr.com/ru/post/1401975/


All Articles