Comparing version 0.0.4 to 0.0.5
@@ -1,1 +0,1 @@ | ||
module.exports = require('./lib/bees'); | ||
module.exports = require('./lib/bees.js'); |
@@ -0,49 +1,55 @@ | ||
var fs = require('fs'), | ||
bees = exports; | ||
var plugins = { | ||
"return": require('./plugins/return'), | ||
"param" : require('./plugins/param') | ||
'@param': require('./plugin/param'), | ||
'@path' : require('./plugin/path'), | ||
'@descr': require('./plugin/descr') | ||
}; | ||
exports.parse = function bees(file) { | ||
var matches = file.match(/\/\*{1,2}(.|\n)+?\*\//g), | ||
json = []; | ||
matches.map(function(m) { | ||
bees.load = function(file) { | ||
return fs.readFileSync(file, 'utf-8'); | ||
}; | ||
bees.parse = function(file) { | ||
var blocks = file.match(/\/\* @api[\w\W*]+?\*\//g) || [], | ||
config = []; | ||
blocks.forEach(function(api) { | ||
var path = {}; | ||
api = api.split('\n'); | ||
api.shift(); | ||
api.pop(); | ||
api = api.map(function(x) { | ||
var match = x.match(/@([\w\W]+?;)/) || []; | ||
return match.shift() || ""; | ||
}); | ||
var sub = {}; | ||
m = m.split('\n'); | ||
m.pop(); | ||
m.shift(); | ||
m.map(function(i) { | ||
(function every(list) { | ||
var item = list.shift(); | ||
if(!item) return; | ||
i = i.replace(/\*/g, '') | ||
.trim(); | ||
if(!i.length) return; | ||
if(~i.indexOf('@')) { | ||
var cmd = i.match(/@(\w+)\s([\W\w]+)?/); | ||
cmd.shift(); | ||
if(plugins[cmd[0]]) { | ||
plugins[cmd[0]](cmd, sub); | ||
} | ||
item = item.replace(/[.*\n]/g, '').split(' '); | ||
var cmd = item.shift(); | ||
if(plugins[cmd]) { | ||
plugins[cmd](path, item); | ||
} | ||
else { | ||
i = i.split(' '); | ||
sub.method = i[0]; | ||
sub.path = i[1]; | ||
} | ||
}); | ||
every(list); | ||
})(api.join('\n').split(';')); | ||
json.push(sub); | ||
config.push(path); | ||
}); | ||
return json; | ||
return config; | ||
}; | ||
exports.use = function(name, fn) { | ||
bees.use = function(name, fn) { | ||
plugins[name] = fn; | ||
}; | ||
} |
{ | ||
"name": "bees", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "yawnt <yawn.localhost@gmail.com>", | ||
"description": "HTTP API Generator", | ||
"description": "Api documentation generator", | ||
"devDependencies": { | ||
"vows": ">= 0.0.0" | ||
"mocha": ">= 0.0.0", | ||
"should": ">= 0.0.0", | ||
"assert": ">= 0.0.0" | ||
}, | ||
"scripts": { | ||
"test": "vows --spec --isolate test/test-*.js" | ||
"test": "mocha -R spec -r should test/*-test.js" | ||
}, | ||
@@ -19,2 +21,2 @@ "bin": { | ||
} | ||
} | ||
} |
@@ -77,3 +77,2 @@ bees (in Italian ```API``` means ```bees```) | ||
); | ||
``` | ||
@@ -95,6 +94,39 @@ | ||
$ node plugin.js | ||
[ | ||
{ | ||
method: 'GET', | ||
path: '/:id', | ||
params: { id: 'id of the user' }, | ||
return: 'user infos', | ||
plugin: 'hai lol' | ||
} | ||
] | ||
``` | ||
## Reporters: | ||
Reporters are a way to return formatted objects. | ||
If we got this in eyes-reporter.js: | ||
```javascript | ||
var inspector = require('eyes').inspector({stream: null}); | ||
module.exports = function(doc) { | ||
return inspector(doc); | ||
}; | ||
``` | ||
And we call bees just like this: | ||
``` | ||
bees -R eyes-reporter <file> | ||
``` | ||
We will get: | ||
![eyes](http://i.imgur.com/F9p5M.png) | ||
Cool eh? | ||
## To Do: | ||
@@ -101,0 +133,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
5995
11
145
3
81
1