NDOC: How to make good use of Your XML Comments?

xiaoxiao2021-03-06  88

NDOC: How to make good use of Your XML Comments?

Writen by Allen Lee

Requirement

Use C # to develop the library. Use XML annotations in the source code. Tired of additional documentation work, I hope there is no regretful computer to pick up this boring job. With C # development conditions, at least the .NET Framework SDK 1.1 is required. Can try to suppress your sleepy insects, do not let it hinder you to read this article. other...

ENCOUNTERED Problems

The popularity of object-oriented technology has brought us great convenience. The reuse of the object reduces many unnecessary pain when we coded, clear code responsibility separation system is avoided in addition to our aversion to "Italian Powder". However, we still have to face the boring document - from the content conception to the page version. I believe that the library developers have experienced this disgusted, even if we all recognize the importance of documents. Of course, some big companies have a dedicated write document, but the most understanding of the library is the programmer! The programmer often adds a comment for the code in the library developed. If there is a tool to take advantage of these comments, you can directly export the document directly in a certain format! Smart and "lazy" programmers are always one step more than others. They don't want to put themselves in the repeated and boring box. These boring throwing a computer that has no regrets.

Feel Free To Write your class library with xml comments address

Simple text can't make you appreciate the charm of NDOC, at least I haven't had this ability. are you asleep? (Perhaps Zhou Gong's story is more interesting!) Over, please see the following demonstration code - a class representing a plural (Class).

Using

System; using

System.globalization; Namespace

Mathutils

{/ ** ////

/// Provides a plural related operational service. /// Public Sealed Class Complex {/ ** //// /// The default constructor sets the complex real part to the imaginary portion, respectively, respectively; /// public Complex () {_real = 0; _Imaginary = 0;} / ** //// /// Set the complex real part to the false portion to the specified value. /// /// /// public complex (int real, int imaginary) {_real = real _Imaginary = imaginary;} private int _real; / ** /// /// complex real part. /// public int real {get {return _real;} set {_real = value;}} private int _imaginary; / ** //// /// complex ingredient. /// public int imaginary {get {return _imaginary;} set {_imaginary = value;}} / ** //// /// converts the complex to the corresponding string form. /// /// /// Returns a string in the form of (x) (Y) i. /// public override string toString () {Return string.Format (CultureInfo.invariantculture, "{0} {1} i", _real, _imaginary);}}} generate Your XML Comments to a seperate XML File

If you have a Visual C # .NET, then you can use the steps: Right-click the item icon in the Solution Manager, select Properties | Configuration Properties | Generate, in [Output] [XML Document File] The file name of the target XML file is filled in the right, here is Complex.xml. Save Setup and turn off the dialog box, generate the project, you will find this XML file in the root of the project. No Visual C # .NET? Not called, using the C # command line compiler CSC.exe. You can generate an XML annotation file if you need to type CSC Complex.cs /Doc:Complex.xml at the command prompt of the source code. Ok, let's take a look at the first phase of labor results:

Complex

Provide multiple related operations services.

The default constructor sets the complex real part to 0;

Convert the plural to the corresponding string.

Returns a string in the form of (x) (Y) i.

Multiple real part.

Multiple ingredients.

WHERE ISUR protagonist?

It is time to come to the protagonist of this play - DOC. Next ... Download ... Installation ... Start NDOC ... (whether man can not get rid of boring odor?) Press [Add] to add your DLL or EXE, and XML annotation file associated with it. .

What kind of format do you want NDOC to generate a library document? Hey, there are a lot of types available! Let's try MSDN! Ok, all the best, only ungenerate. Now build it!

Well Done! This is our second phase of results, that is, the final result! Do you feel that itch is ready to try it?

Conclusion

Finally, the finals, one hundred people have one hundred Hamlet, I don't know how NDOC is in your mind? I don't know if you think that NDOC is eccentric, only C # that can use XML Comments is so good. However, VB.NET does not need to be sad, because you have a vbcommenter to support you silently!

转载请注明原文地址:https://www.9cbs.com/read-99392.html

New Post(0)