Work Note 7 - Simple applications such as apidoc document generation tools in java

Apidoc User Manual

Introduction

In the process of project development, the document generation tool may be used. 
This tool is a Nodejs module. Please be sure to install the nodejs environment before using it!

Tool name: apiDoc 
Git address: https://github.com/apidoc/apidoc 
Project address: http://apidocjs.com/ 
Sample project: http://apidocjs.com/example_basic/ 

Supported comment styles: 
JavaDoc-Style

/**

 * This is a comment.

 */

install apidoc

command line input 

npm installapidoc –g

 

Type apidoc –v

command to check if the installation was successful

How to use

Type in the command line

apidoc -f ".*\\.js$" -f ".*\\.java$" -i myapp/ -o apidoc/ -t mytemplate/

 

Parameter description: 
-f file filtering 
uses regular expressions, indicating which files need this conversion, if not set, the default is .cs .dart .erl .go .java .js .php .py .rb .ts suffixed files .

-i code folder

-o path to output Api documentation

-t Use the path of the template file, you can customize the output template

       

I just use the default configuration.         

       generate apidoc

       Open to your project path and enter the command line

       apidoc -o apidoc /

   The index.html in the generated file is opened with a browser and it is the document

 

 

The definition of annotation is found on the Internet

   attach some examples

 

   user.java

/**
 * @api {POST} /register registered user
 * @apiGroup Users
 * @apiVersion 0.0.1
 * @apiDescription for registered users
 * @apiParam {String} account User account name
 * @apiParam {String} password password
 * @apiParam {String} mobile phone number
 * @apiParam {int} vip = 0 Whether to register Vip identity 0 Ordinary user 1 Vip user
 * @apiParam {String} [recommend] invitation code
 * @apiParamExample {json} request example:
*                ?account=sodlinken&password=11223344&mobile=13739554137&vip=0&recommend=
 * @apiSuccess (200) {String} msg information
 * @apiSuccess (200) {int} code 0 means no error 1 means error
 * @apiSuccessExample {json} return example:
 *                {"code":"0","msg":"注册成功"}
 */







 /**
 * @api {POST} /login user login
 * @apiGroup Users
 * @apiVersion 0.0.1
 * @apiDescription for user login
 * @apiParam {String} userName username
 * @apiParam {String} password password
 * @apiParamExample {json} request example:
 * ?userName=Zhang San&password=11223344
 * @apiSuccess (200) {String} msg information
 * @apiSuccess (200) {String} code 0 means no error 1 means error
 * @apiSuccess (200) {String} user user information
 * @apiSuccess (200) {String} userId user id
 * @apiSuccessExample {json} return example:
 *                {"code":"0","msg":"登录成功","userId":"fe6386d550bd434b8cd994b58c3f8075"}
 */






 /**
 * @api {GET} /users/:id Get user information
 * @apiGroup Users
 * @apiVersion 0.0.1
 * @apiDescription get user information
 * @apiSuccess (200) {String} msg information
 * @apiSuccess (200) {int} code 0 means no error 1 means error
 * @apiSuccess (200) {String} name real name
 * @apiSuccess (200) {String} mobile phone number
 * @apiSuccess (200) {String} birthday birthday
 * @apiSuccess (200) {String} email Email address
 * @apiSuccess (200) {String} summary Introduction
 * @apiSuccess (200) {String} recommendCode my recommendation code
 * @apiSuccess (200) {String} idCardNo ID number
 * @apiSuccess (200) {String} memberState Member State 0 Ordinary User 1 VIP 2 Account Freeze
 * @apiSuccess (200) {String} address home address
 * @apiSuccess (200) {String} money account cash
 * @apiSuccessExample {json} return example:
 * {
 *   "code": 0,
 *   "msg": "",
 * "name": "real name",
 *   "mobile": 15808544477,
 *   "birthday": "1990-03-05",
 *   "email": "[email protected]",
 *   "summary": "简介",
 * "recommendCode": "My recommendation code",
 * "idCardNo": "ID Card Number",
 *   "memberState": 1,
 * "address": "Home Address",
 *   "money": "30.65"
 * }
 */







 /**
 * @api {POST} /users/:id Modify (perfect) user information
 * @apiGroup Users
 * @apiVersion 0.0.1
 * @apiDescription Modify (improve) user information
 * @apiParam (200) {String} [name] real name
 * @apiParam (200) {String} [mobile] phone number
 * @apiParam (200) {String} [birthday] birthday
 * @apiParam (200) {String} [email] Email address
 * @apiParam (200) {String} [summary] Introduction
 * @apiParam (200) {String} [idCardNo] ID number
 * @apiParam (200) {String} [address] Home address
 * @apiSuccess (200) {String} msg information
 * @apiSuccess (200) {int} code 0 means no error 1 means error
 * @apiSuccessExample {json} return example:
 *                {"code":"0","msg":"修改成功"}
 */

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326076979&siteId=291194637