With the popularity of web, JavaScript has become a new programming language. Due to the emergence of a large number of open-source JS frameworks, more and more projects are developed using JavaScript. At the same time, more and more Javascript development problems are exposed, such as performance and webpage loading speed. Among them, JavaScript document maintenance has become a challenge that developers need to solve.
Many modern programming languages have their own integrated document generation tools, such as Java with javadoc ,. net has ndoc and PHP has phpdoc. These automated document tools can automatically generate code documents based on comments in the code.
Jsdoc toolkit is such an automated document tool. It is an open-source Project released on Google Code, just like the documentation tools in other languages, it automatically extracts comments from JavaScript code to generate formatted documents.
Http://code.google.com/p/jsdoc-toolkit/downloads/list
Running Environment
Jsdoc toolkit is developed in Java and Java 1.5 + is required for running.
Usage
Before running, you need to switch the current working directory to the jsdoc toolkitdirectory, and add the directory where java.exe is located to the environment variable.
Java-jar jsrun. Jar APP/run. js-a-t = templates/jsdoc mycode. js
Mycode. JS is the JS Code of the document to be generated. If mycode. js and jsdoc are not in the same directory, add the absolute or relative path of the file. If the project contains multiple JS files, you can use the wildcard * to specify multiple JS files (*. JS ). The-e parameter specifies the document encoding, and the-t parameter specifies the document template location (you can create or modify a template file to make the output code file more special ), the generated file is in the out directory under the jsdoc directory. For ease of use, I wrote a batch processing file. You can save the code as run. BAT and put it in the jsdoc directory:
: Run. bat @ echo off: JS File Name (changed to your JS file name) set jsname = jquery. JS: JS file path (changed to your JS file path) set jspath = C:/test/ECHO start... java-jar jsrun. jar APP/run. JS-a-e = GBK-T = templates/jsdoc "% jspath % jsname %. JS ": Out/% jsname %/index.html echo finished.
Pause
Common keywords
| Author |
Identify code author |
| Class |
Identifies a function as a class constructor. |
| Constant |
Declare Constants |
| Constructor |
Same class |
| Default |
Default Value |
| Deprecated |
Declare obsolete objects |
| Description |
Object Description |
| Event |
Event Functions |
| Example |
Sample Code |
| Fileoverview |
General description of JavaScript files |
| Ignore |
Ignore the function with this flag |
| Link |
Associate with other jsdoc objects |
| Name |
Display objects declared that jsdoc cannot be detected automatically |
| Namespace |
Declare a namespace |
| Param |
Parameters |
| Private |
Declare private object |
| Property |
Explicitly declare an attribute |
| Public |
Declare Public object |
| Requires |
Declare the dependent object or file |
| Returns |
Return Value |
| See |
Declare other objects for Reference |
| Since |
The declared object takes effect from the specified version. |
| Static |
Explicitly declare a static object |
| Throws |
Declare exceptions that may be thrown during function execution |
| Type |
Declare the variable type or function return value type |
| Version |
Version Number |
For detailed syntax, see jsdoc toolkit wiki.
Organized from: http://blog.tugai.net/2010/01/08/jsdoc-toolkit-usage/
This article is the use of b3log solo from the simple design of the art of the original article: http://88250.b3log.org/articles/2010/11/26/jsdoc-toolkit-usage.html