NDoc: Make good use of your XML Comments.

  The main topic on Allen Lee in their work and learning in the face of good. NET tools, and describe the use of related experience.    Gongyushanjishi, we must first of its profits.    Well, now let us see what could benefit! 

  1. Friends like C # C # certainly had the experience of the XML document Note (XML Comments), but we may not have full use of this function, at the most, we have to regard it with other types of Notes equivalent, in the code Pages gives some indication of code or function described, at best, only new point, the formal description of the code to work or other documents with Word or anything to deal with.    Manzhao!    Have you ever thought of these two can be combined together?    I mean, in the Notes to the above source code, and then directly exported to XML, with some handling as HTML document?    To illustrate the problem, I wrote a simple code: 

  Using System; 
  Using System.Globalization; 

  Namespace MathUtils 
  ( 
  / / / <summary> 
  / / / Operators to provide services related to the complex. 
  / / / </ Summary> 
  Public sealed class Complex 
  ( 
  / / / <summary> 
  / / / Default constructor, it will be a complex and imaginary part of the other set to 0; 
  / / / </ Summary> 
  Public Complex () 
  ( 
  _Real = 0; 
  _Imaginary = 0; 
  ) 

  / / / <summary> 
  / / / Respectively multiple real and imaginary part is set to the value specified. 
  / / / </ Summary> 
  / / / <param Name="real"> </ param> 
  / / / <param Name="imaginary"> </ param> 
  Public Complex (int real, int imaginary) 
  ( 
  _Real = Real; 
  _Imaginary = Imaginary; 
  ) 

  Private int _Real; 
  / / / <summary> 
  / / / Multiple real. 
  / / / </ Summary> 
  Public int Real 
  ( 
  Get 
  ( 
  Return _Real; 
  ) 
  Set 
  ( 
  _Real = Value; 
  ) 
  ) 

  Private int _Imaginary; 
  / / / <summary> 
  / / / Imaginary part of the complex. 
  / / / </ Summary> 
  Public int Imaginary 
  ( 
  Get 
  ( 
  Return _Imaginary; 
  ) 
  Set 
  ( 
  _Imaginary = Value; 
  ) 
  ) 

  / / / <summary> 
  / / / Conversion of the plural form for the corresponding string. 
  / / / </ Summary> 
  / / / <returns> 
  / / / Return (X) + (Y) i in the form of a string. 
  / / / </ Returns> 
  Public override string ToString () 
  ( 
  Return String.Format (CultureInfo.InvariantCulture, 
  "(0) + (1) i" 
_Real,
_Imaginary);
  ) 

  ) 
  ) 

  If you have Visual C #. NET, then you can easily use to step: solutions for the management of the project in the right-click the icon, select Properties |? Configuration properties | generated in the [output] [XML text Files] fill the right target XML document file name, using Complex.xml here.    Save the settings and close the dialog box to generate the item, you will be in the project's root directory found in the XML file. 

  If you do not have Visual C #. NET, you can use a command line interface and CSC.exe only need the directory source code of the command prompt, type csc Complex.cs / doc: Complex.xml [Enter], we can Notes generate XML documents.    Below look at the generated files: 

  <? Xml version = "1.0"> 
<doc>
<assembly>
  <name> Complex </ name> 
  </ Assembly> 
<members>
  <member Name="T:MathUtils.Complex"> 
<summary>
  Complex operation to provide the relevant services. 
  </ Summary> 
  </ Member> 
  <member Name="M:MathUtils.Complex.#ctor"> 
<summary>
  The default constructor, it will be a complex and imaginary part of the other set to 0; 
  </ Summary> 
  </ Member> 
  <member Name="M:MathUtils.Complex.#ctor(System.Int32,System.Int32)"> 
<summary>
  Separate multiple real and imaginary part is set to the value specified. 
  </ Summary> 
  <param Name="real"> </ param> 
  <param Name="imaginary"> </ param> 
  </ Member> 
  <member Name="M:MathUtils.Complex.ToString"> 
<summary>
  Conversion of the plural form for the corresponding string. 
  </ Summary> 
<returns>
  Return (X) + (Y) i in the form of a string. 
  </ Returns> 
  </ Member> 
  <member Name="P:MathUtils.Complex.Real"> 
<summary>
  Multiple real. 
  </ Summary> 
  </ Member> 
  <member Name="P:MathUtils.Complex.Imaginary"> 
<summary>
  The imaginary part of the plural. 
  </ Summary> 
  </ Member> 
  </ Members> 
  </ Doc> 

  How we use this next generation of XML?    We use this very simple on the protagonist - NDoc, went http://ndoc.sourceforge.net/ download, install, and then run NDoc.    Click Add or add Exe generated Dll set procedures, as well as related XML document files.    Then select Build to generate documentation files, and generate documents can also choose to type. 

  In this way, we generate a document, here I choose MSDN document types: 

  Can ask you a question?    When you read this introduction, you have not thought about the use of this tool?    How to think?    Give me a resume?    (Completely not interested, I feel indifferent, have an opportunity to try, to immediately download a look at) Thank you! 

  Allen Lee 

  See also: 

  Reflector: Get the secret inside. NET assemblies 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags:

Releated Articles


0 Comments to “NDoc: Make good use of your XML Comments.”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.