NDOC use brief manual

xiaoxiao2021-03-06  39

NDOC is a .NET code document generated tool, a bit like JDOC, but this is a tool under .NET.

NDOC uses the assembly and XML documents generated during the Visual Studio.net development process to generate some compiled HTML help documents such as Visual Studio.net and .NET FRMAEWORK online help documents.

It is an OpenSource project, in http://ndoc.sourceforge.net, you can download to Sourcecode.

Use very simple, such as creating a simple item to see what NDOC does do? Create a simple item called TestNDo, only one WindowForm, with a Button, click Show Information. Package the information of the information is the ShowMSG class, only one method showMessage.

The code is as follows: showmsg.cs

Using

System;

Using

System.windows.forms;

Namespace

Testndoc

{///

/// showMSG summary description. /// Display test information class /// public class showmsg {public showmsg () {// // Todo: Add constructor logic //} /// /// test String /// private string teststr = null; #REGION Display Information Public Functions /// /// /// /// /// ///// /// Passing string parameter public void showmessage (string msg) {MessageBox.show (AddStr (MSG));} #ENDREGON / / /// Add a number of characters, private functions /// /// Passing strings /// Returns the processed string protected String addstr (String MSG) {// Returns Return Return "stradd:" msg;} /// /// TEST Addok /// /// /// protected string addok (string msg) { Return "OK:" msg;}}}

Form1.csusing

System;

Using

System.drawing;

Using

System.collections;

Using

System.componentmodel;

Using

System.windows.forms;

Using

System.data;

Namespace

Testndoc

The summary description of {///

/// Form1. /// public class testNDoc: System.Windows.Forms.Form {private System.Windows.Forms.Button btnShowMsg; private System.Windows.Forms.Button btnNoSummary; /// /// Required Designer variable. /// private system.com = null; public testndoc () {// // Windows Form Designer Support To Support // InitializationComponent (); // // Todo: in InitializationComponent call Add any constructor code //} /// /// Clean all the resources being used. /// Protected Override Void Dispose (Bool Disposing) {if (disponents! = Null) {Components.dispose ();}} Base.Dispose (DISPOSISING);} Windows Form Designer The generated code /// /// Designer supports the required method - Do not use the code editor to modify the // / this method.

/// private void InitializeComponent () {this.btnShowMsg = new System.Windows.Forms.Button (); this.btnNoSummary = new System.Windows.Forms.Button (); this.SuspendLayout (); / / // btnshowmsg /// this.btnshowmsg.location = new system.drawing.point (72, 104); this.btnshowmsg.name = "btnshowmsg"; this.btnshowmsg.size = new system.drawing.size (128, 32 ); this.btnShowMsg.TabIndex = 0; this.btnShowMsg.Text = "ShowMsg"; this.btnShowMsg.Click = new System.EventHandler (this.btnShowMsg_Click); // // btnNoSummary // this.btnNoSummary.Location = New system.drawing.point (72, 160); this.btnnosummary.name = "btnnosummary"; this.btnnosummary.size = new system.drawing.size (128, 32); this.btnnosummary.tabindex = 1; this. Btnnosummary.text = "no summary"; this.btnNoSummary.Click = new System.EventHandler (this.btnNoSummary_Click); // // testNDoc // this.AutoScaleBaseSize = new System.Drawing.Size (6, 14); this.ClientSize = new System.Drawing.Size (520, 341); this.Controls.add (this.btnnosummary); this.btnshowmsg; this.name = "testndoc"; this.text = "testnDoc"; this.ResumeLayout (false) } #Endregion ///

/// The primary entry point of the application.

/// [stathread] static void main () {Application.run (new testndoc ());} ///

/// click button display information /// // / /// private void btnshowmsg_click (object sender, system.eventargs e) {showmsg smsg = new showmsg (); smsg .ShowMessage ( "Hello?");} private void btnNoSummary_Click (object sender, System.EventArgs e) {ShowMsg sMsg = new ShowMsg (); sMsg.ShowMessage ( "No Summary Click!");}}} In order to use to generate NDoc Document, there must be a compiled assembly and an exported XML file. To generate this XML file, you must generate an XML file in the project properties.

Options Fill in the file name, as shown below: Compile with a corresponding XML file: Open the XML file to see the following (Note: This XML file is not NDOC generated, but Visual Studio.net):

XML Version = "1.0"

?>

<

DOC

>

<

askSEMBLY

>

<

Name

>

Testndoc

Name

>

askSEMBLY

>

<

MEMBERS

>

<

MEMBER

Name

= "T: testndoc.testndoc"

>

<

Summary

>

Abstract illustration of Form1.

Summary

>

MEMBER

>

<

MEMBER

Name

= "F: testndoc.testndoc.components"

>

<

Summary

>

Required designer variable.

Summary

>

MEMBER

>

<

MEMBER

Name

= "M: testNDoc.testndoc.dispose (system.boolean)"

>

<

Summary

>

Clean all the resources being used.

Summary

>

MEMBER

>

<

MEMBER

Name

= "M: testndoc.testndoc.initializecomponent"

>

<

Summary

>

Designer supports the required method - do not use the code editor to modify the contents of this method.

Summary

>

>

<

MEMBER

Name

= "M: testndoc.testndoc.main"

>

<

Summary

>

The main entry point for the application.

Summary

>

MEMBER

>

<

MEMBER

Name

= "M: testndoc.testndoc.btnshowmsg_click (system.object, system.eventargs)"

>

<

Summary

>

Click Button Display Information

Summary

>

<

PARAM

Name

= "sender"

>

PARAM

>

<

PARAM

Name

= "e"

>

PARAM

>

MEMBER

>

<

MEMBER

Name

= "T: testndoc.showmsg"

>

<

Summary

>

Summary illustration of Showmsg. Display the class of test information

Summary

>

MEMBER

>

<

MEMBER

Name

= "F: testndoc.showmsg.teststr"

>

<

Summary

>

Test string

Summary

>

MEMBER

>

<

MEMBER

Name

= "M: testndoc.showmsg.showMessage (system.string)"

>

<

Summary

>

Display information on the public function in the information box

Summary

>

<

PARAM

Name

= "msg"

>

Passing string parameters

PARAM

>

MEMBER

>

<

MEMBER

Name

= "M: testNDoc.showmsg.addstr (system.string)"

>

<

Summary

>

Add a private function of several characters

Summary

>

<

PARAM

Name

= "msg"

>

Passing string parameters

PARAM

>

<

Returns

>

Returns the handled string

Returns

>

MEMBER

>

<

MEMBER

Name

= "M: testndoc.showmsg.addok (system.string)"

>

<

Summary

>

Test Addok

Summary

>

<

PARAM

Name

= "msg"

>

PARAM

>

<

Returns

>

Returns

>

MEMBER

>

MEMBERS

>

DOC

>

Carefully compare the relationship between this XML file and source code can be found: 1. This XML file lists most methods, whether these methods are private, public or protected, even constructive; 2. part of the agion does not Included in the XML file; 3. The method without a comment is not included in the XML file, such as the constructor of ShowMSG and the BTNNOSummary_Click function portion in Form1.cs; 4. Annotation variable is also included in the XML file, such as Form1 Private system.componentmodel.container components = NULL and SHOWMSG class in the price string teststr = null; 5. The annotation of this approach has not been filed;

Summary: The following approach is included in the XML file.

///

/// Add a private function of several characters /// /// Passing strings /// return processing String

So, how is the NDOC processing?

Install the NDOC running program, select the assembly, and the corresponding XML file, then set the relevant parameters of the generated document, the document type is currently supporting 6: htmlhelp2 Note, this document needs to be installed with Visual Studio Help Integration Kit, can be in Microsoft Website download; Javadoc is similar to the documentation of the Java API, and people who are used to see the Java API more like Latex (alpha) lineArhtml (alpha) MSDNXML

Selecting different document types requires some different parameters, here choosing the HTMLHELP2 format. You can set the parameters, many of the default values, each of which can be seen below, this example selects the settings as shown below: Select Documentation-> Build on the menu to generate the needs help documentation .

At this point, a DOC directory is generated in the directory where the NDoc file is located, and all generated files are placed in this directory.

Open NDOCTEST.CHM, see the effects as follows: Here you can see the information generated is not only dependent on the XML files discussed above, and there is a lot of complete information, which should be read by the reflex mechanism. .

The comparison result can be seen: 1. The generated CHM only shows public and protected, and Private does not display, whether it is in XML, and the method of inherits will also be displayed in CHM; 3. Generate CHM Based on the assembly, the method of public and protected is displayed, while XML is mainly used as a reference, such as a total of some no comments in the project.

There is no reaction in XML, but it will also be displayed in CHM. Summary: NDOC generated CHM did not completely extract all of the comments in the project, but it is very useful as generating API documents.

Also, it is worth noting that the synchronization of NDOC seems to be some problems in use. For example, after the first generation, some modifications have made some modifications, and the modification of the comment can be updated synchronously, but some method changes are not directly reacted. For example, the public is changed to protected and does not directly react in the generated CHM. Please advise with this issue or know how to solve it. Example code can be downloaded from here

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

New Post(0)