Home > Web Front-end > JS Tutorial > JSDoc introduction and usage specifications Introduction to the use of JsDoc_javascript skills

JSDoc introduction and usage specifications Introduction to the use of JsDoc_javascript skills

WBOY
Release: 2016-05-16 18:10:59
Original
1237 people have browsed it

JsDoc Toolkit released version 2.3.2 not long ago, which mainly fixes the previous version.
If you need to use Ant, JsDoc also has 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 the parameter name and description to describe a function parameter

@returns Describe the function The return value of
@author indicates the author of the code.
@deprecated indicates that a function has been deprecated and will be completely removed in a future version of the code. To avoid using this code
@see Create an HTML link pointing to the description of the specified class
@version Specify the release version
@requires Create an HTML link pointing to the specified class required by this class
@throws @exception Describes the type of exception that the function may throw
{@link} Creates an HTML link pointing to the specified class. This is similar to @see, but {@link} can be embedded in the comment text
@fileoverview This is a special tag. If this tag is used in the first documentation block of a file, it specifies that the remainder of the documentation block will be used to provide an overview of the file
@class provides information about the class, used in the documentation of the constructor
@constructor makes it clear that a function is the constructor of a certain class
@type specifies the return type of the function
@extends indicates that one class derives from another class. JSDoc can usually detect this information by itself, but in some cases it is necessary to use the tag
@private to indicate that a class or function is private. Private classes and functions will not appear in HTML documents unless the --private command line option is provided when running JSDoc
@final indicates that a value is a constant value. Remember that JavaScript cannot truly guarantee that a value is a constant
@ignore JSDoc ignores functions with this tag

JsDoc: is a js document generation tool that extracts classes, methods, and members from the javascript program source code The annotation information forms an API help document that matches the source code.
Java open source project http://www.jsdoctoolkit.org/, which is a powerful javascript document generation tool.
Let’s finish with how to use it.
We download the tool library.
Here we are using jsdoc_toolkit-2.1.0.zip which is the current highest version.
Let’s unzip this file. You can see the README.txt file inside.
Here are detailed instructions for use. [It seems that the introduction can be done here. Of course you can also continue reading]
Here we need to create a javascript document through the command line.
java -jar jsrun.jar app/run.js -a -e=GB18030 -t=templates/jsdoc test/*.js
Of course, if you find it more troublesome to use the command line, we can create one ourselves .bat file
Copy the above content into the file and execute it.
Let me briefly explain the parameters
-a represents all methods
-e represents the encoding root of the corresponding file, which corresponds to GB18030. The default is utf-8
-t Represents the document style template of the production doc
The test/*.js here represents all the javascript files in the test directory
After execution, the document results will be output to the /out/jsdoc directory by default. Of course, this directory can also be defined
The specific parameters can be viewed using
java -jar jsrun.jar app/run.js --help
.
The result is as follows:

Copy code The code is as follows:

OPTIONS:
- a or --allfunctions
Include all functions, even undocumented ones.
-c or --conf
Load a configuration file.
-d= 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= or --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 message and exit.
-n or --nocode
Ignore all code, only document comments with @name tags.
-o= or --out=
Print log messages to a file (defaults to stdout).
-p or --private
Include symbols tagged as private, underscored and inner symbols.
-q or --quiet
Do not output any messages, not even warnings.

Let’s create the js file under test
Easy way to mark
myjs.js
Copy the code The code is as follows:

/**
* @fileOverview 간단한 메소드 주석 예
* @author llying
* @version 0.1
*/

/**
* @description 추가 연산
* @param {Num} num1 addend
* @param {Num} num2 summand
* @return {Num} 결과 결과
*/
함수 추가(num1,num2){
return num1 num2;
/**
* @description 빼기 연산
* @param {Num} num1 minuend
* @param {Num} num2 minuend
* @return {Num} 결과 결과
*/
function minus(num1,num2){
return num1 - num2
}

클래스 메소드 주석
myjs2 .js

코드 복사 코드는 다음과 같습니다.
/**
* @fileOverview 간단한 클래스 객체 주석 예
* @author llying
* @version 0.1
* /
/**
* @author llying
* @constructor Person
* @description a Person 클래스
* @see llying. * @example new Parent("张三",15);
* @since 버전 0.1
* @param {String} 사용자 이름
* @param {Num} 나이 나이
*/
기능 사람(사용자 이름, 나이)
{
/**
* @description {Sting} 이름
* @field
*/
this.username = 사용자 이름
/ **
* @description {Num} 나이
* @field
*/
this.age = 연령
/**
* @description 팝업 내용 내용
* @param {String} 내용 내용
*/
this.say = 기능(콘텐츠)
{
alert(this.username " say : " content);
}
/**
* @description json 형식의 객체를 반환합니다.
* @return {String} json 형식
* @see Person#say
*/
this.getJson = function(){
return "{name:" this.username ",age" this. age " }";
}
}


이제 java -jar jsrun.jar app/run.js -a -e=GB18030 -t=templates/jsdoc test를 실행할 수 있습니다. /* .js

이제 js 문서가 생성되었습니다. 우리는 더 이상 JavaDoc을 부러워할 필요가 없습니다.


자세한 내용은 공식 웹사이트에 로그인하여 JSDoc introduction and usage specifications Introduction to the use of JsDoc_javascript skillshttp://code.google.com/p/jsdoc-toolkit/을 참조하세요. 위키/태그 참조
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template