JSDoc Introduction to use Specification JSDoc introduction _javascript Tips

Source: Internet
Author: User
Tags deprecated
JSDoc Toolkit recently released the 2.3.2 version, mainly to the previous version of the repair.
If you need to use Ant,jsdoc and an ant plug-in: JSDoc Toolkit ant Task
Download JSDoc Toolkit2.3.2:http://jsdoc-toolkit.googlecode.com/files/jsdoc_toolkit-2.3.2.zip
Command name Description
@param @argument Specify parameter names and descriptions to describe a function argument

@returns describe the return value of a function
@author indicates the author of the Code
@deprecated indicates that a function has been deprecated and will be completely deleted in future versions of the code. To avoid using this piece of code
@see Create an HTML link that points to the description of the specified class
@version Specify a release version
@requires Create an HTML link that points to the specified class required for this class
@throws @exception describes the types of exceptions that a function might throw
{@link} creates an HTML link that points to the specified class. This is similar to @see, but {@link} can be embedded in the comment text
@fileoverview This is a special marker. If you use this tag in the first document block of a file, specify that the remainder of the document block will be used to provide an overview of the file
@class provides information about a class, used in a constructor's document
@constructor make it clear that a function is a constructor of a class
@type The return type of the specified function
@extends indicates that a class derives another class. JSDoc usually detects this information by itself, but in some cases you must use this tag
@private indicates that a class or function is private. Private classes and functions do not appear in HTML documents unless--private command-line options are provided when running JSDoc
@final indicates that a value is a constant value. Remember that JavaScript doesn't really guarantee that a value is a constant
@ignore JSDoc ignores functions that have this tag

JSDoc: is a JS document generation tool, which extracts classes, methods, members, and other annotation information from JavaScript program source code to form an API help document supporting the source code.
Java Open Source Project http://www.jsdoctoolkit.org/, a powerful JavaScript document generation tool.
Now let's end with how to use.
We download the tool class library by downloading it.
Here we are using the Jsdoc_toolkit-2.1.0.zip and the current highest version.
We'll unpack this file. Can see inside README.txt file.
Detailed instructions are available here. "It seems to be introduced here." Of course, you can keep reading.
Here we need to create JavaScript documents from the command line.
Java-jar Jsrun.jar app/run.js-a-e=gb18030-t=templates/jsdoc test/*.js
Of course, if it feels like a hassle through the command line, we can create a. bat file on our own
Copy the contents of the above to the file and execute it.
Let me briefly explain the parameters here.
-A represents all methods
-E indicates the encoding radical for the corresponding file this corresponds to the GB18030 default is Utf-8
-T represents a document style template that produces doc
The test/*.js here represents all JavaScript files in the test directory
The document results are output by default to the/out/jsdoc directory when the execution is complete. Of course, this directory can be defined as well.
Specific parameters can be used
Java-jar Jsrun.jar app/run.js--help
For viewing.
The results are as follows:
Copy Code code as follows:

OPTIONS:
-A or--allfunctions
Include all functions, even undocumented ones.
-C or--conf
Load a configuration file.
-d=<path> or--directory=<path>
Output to this directory (defaults to "out").
-d= "Myvar:my value" or--define= "Myvar:my value"
Multiple. Define a variable, available in JSDoc as Jsdoc.opt.d.myvar.
-e=<encoding> or--encoding=<encoding>
Use this encoding to read and write files.
-e= "regex" or--exclude= "regex"
Multiple. Exclude files based on the supplied regex.
-H or--help
Show this and exit.
-N or--nocode
Ignore all code, only the document comments with @name tags.
-o=<path> or--out=<path>
Print log messages to a file (defaults to stdout).
-P or--private
Include symbols tagged as private, underscored and inner symbols.
-Q or--quiet
Don't output any messages and not even warnings.

Below we will create the JS file under test
Simple way to label
Myjs.js
Copy Code code as follows:

/**
* @fileOverview Simple Method Annotation Example
* @author <a href= "llying.javaeye.com" >llying</a>
* @version 0.1
*/

/**
* @description addition operation
* @param {Num} num1 addends
* @param {Num} num2 summand
* @return {Num} result results
*/
function Add (num1,num2) {
return NUM1 + num2;
}
/**
* @description Subtraction operation
* @param {Num} NUM1
* @param {Num} num2 Bing
* @return {Num} result results
*/
function minus (num1,num2) {
return num1-num2;
}

method annotation for a class
Myjs2.js
Copy Code code as follows:

/**
* @fileOverview Simple Class object Annotation Example
* @author <a href= "llying.javaeye.com" >llying</a>
* @version 0.1
*/
/**
* @author llying
* @constructor Person
* @description a person class
* @see the <a href= "#" >llying</a.
* @example New Parent ("John", 15);
* @since version 0.1
* @param {String} username name
* @param {Num} age
*/
function person (username,age)
{
/**
* @description {Sting} name
* @field
*/
This.username = Username;
/**
* @description {Num} age
* @field
*/
This.age = Age
/**
* @description Pop-up say content
* @param {String} content
*/
This.say = function (content)
{
Alert (this.username+ "say:" +content);
}
/**
* @description returns the object in JSON format
* @return {String} JSON format
* @see Person#say
*/
This.getjson = function () {
Return ' {name: ' +this.username+ ', age ' +this.age+ '} ';
}
}

Now we can run Java-jar Jsrun.jar app/run.js-a-e=gb18030-t=templates/jsdoc test/*.js

At this point our JS document generation completed. We don't have to envy Javadoc.

We just listed the usual tags, as far as more can log on to the official website to view
Http://code.google.com/p/jsdoc-toolkit/wiki/TagReference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.