Went through couple of tutorials and documentations, including main documentation here.Following it, created two files:
example.js
var currentUser={
name='Mary'
};
/**
* @api {get} /user/ Request User information
* @apiName GetUser
* @apiGroup User
*/
function getUser(){
return {code 200,data:currentUser};
}
function setName(name){
if(name.length==0){
return {code:404,message:'NameEmptyError'};
}
currentUser.name=name;
return {code 204};
}
testpython.py
"""
@api {get} /user/ Request User information
@apiName GetUser
@apiGroup User
"""
print "hello"
Saved both of them in a folder, say "my_project". On Mac terminal, went to parent directory of "my_project". Ran the script:
apidoc -i my_project/ -o apidoc/
Getting error :
- ERROR - Failed to parse sources
It's basic, but somehow, not getting success.
This happens when you install package both, from npm and pip3. Clear the currently installed apiDoc packages completely. To remove npm package, to go terminal and type :
cd /usr/local/lib/node_modules
Then to uninstall it, type :
sudo npm uninstall apidoc
This will remove the npm-apidoc package. To remove the pip3 package :
sudo pip3 uninstall apidoc
To remove them manually , to go :
/usr/local/lib/pythonVERSION/dist-packages
Now for fresh install:
sudo npm install apidoc -g
This should do it :).