//@desn:apidoc linux environment windows environment use
//@desn: The code word is not suitable, please indicate the source for reprinting
//@author:Zhang Huiyuan <[email protected]>
//@date:2018/5/6
text:
Windows version installation:
1. Install nodejs (nodejs environment)
32-bit installation package download address: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x86.msi
64-bit installation package download address: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x64.msi
2. Install apidoc,
npm install -g apidoc
Use the first command version to run the above command to install
Linux version of ubuntu
1. Update the ubuntu software source
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
2. Install nodejs
sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm
3. Update the npm package mirror source
sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list
4. Install n manager globally (for managing nodejs version)
sudo npm install n -g
5. Install the latest nodejs (stable version)
sudo n stable
sudo node -v (check version)
6. Install apidoc
sudo npm install apidoc -g
Use: Take the TP framework as an example
Put the template .json in the root directory of the website
content:
{
"name": "example",
"version": "0.1.0",
"description": "A basic apiDoc example"
}
Here are the comments in my code (apidoc is to convert comments into interface documents)
/**
* @api {POST} http://118.25.17.80/index/Index/add_needs Add user needs
* @apiVersion 1.0.0
* @apiGroup NEED
*
* @apiParam {String} need_name requester name - not empty
* @apiParam {String} e_mail User email - not empty email format
* @apiParam {String} phone User phone - not empty
* @apiParam {String} company_name Requirement company name - not empty
* @apiParam {String} needs_desc Requirement description - not empty
*
* @apiSuccess {Object} code Return code
* @apiSuccess {Object} reason Chinese explanation
* @apiSuccess {String[]} data Return data
*
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "code":0,
* "reason":"The request has been submitted, our staff will contact you within 2 working days!",
* "data":[]
* }
*/
Annotation reference: http://apidocjs.com (apidoc official website)
Focus on TP: The generated doapi is placed under public
Command: apidoc -i ./ -o ./public/apidoc Note: -i Application directory -o output apidoc location and another command to cd to the application root directory to run the
effect display: