Skip to content

Commit fffc107

Browse files
committed
Weight help items
1 parent 07ddb94 commit fffc107

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

lib/endpoint.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var colors = require('colors');
2+
var utils = require('../utils');
3+
4+
exports.swagger = false;
5+
exports.login = false;
6+
exports.category = "basic";
7+
exports.desc = "Learn how to document an endpoint";
8+
exports.weight = 3;
9+
10+
exports.run = function(config, info) {
11+
console.log("You can document each endpoint right above the code. Just use the");
12+
console.log("following syntax in a comment above the code:");
13+
console.log("");
14+
15+
console.log(utils.swaggerInlineExample(utils.guessLanguage()));
16+
17+
console.log('');
18+
console.log('Param shorthand: '.blue + 'Since params are very verbose, we have a shorthand');
19+
console.log('for describing them.');
20+
21+
console.log('');
22+
console.log(' - (in) name=default* {type:format} description'.grey);
23+
console.log('');
24+
25+
console.log("This will be expanded when the Swagger file is compiled.");
26+
27+
console.log('');
28+
console.log('For more information on this syntax, see https://github.com/readmeio/swagger-inline');
29+
30+
process.exit();
31+
};
32+

lib/help.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports.swagger = false;
66
exports.login = false;
77
exports.category = "basic";
88
exports.desc = "Learn what you can do with oai";
9+
exports.weight = 2;
910

1011
exports.run = function(config, info) {
1112
console.log("");
@@ -33,15 +34,18 @@ exports.run = function(config, info) {
3334
var info = f.desc || "";
3435

3536
if(f.category) {
36-
categories[f.category].commands.push(" $".grey + pad(" oai " + action) + " " + info.grey);
37+
categories[f.category].commands.push({
38+
text: " $".grey + pad(" oai " + action) + " " + info.grey,
39+
weight: f.weight,
40+
});
3741
}
3842
});
3943

4044
_.each(categories, function(category) {
4145
console.log("");
4246
console.log(category.desc);
43-
_.each(category.commands, function(command) {
44-
console.log(command);
47+
_.each(_.sortBy(category.commands, 'weight'), function(command) {
48+
console.log(command.text);
4549
});
4650
});
4751

lib/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports.swagger = false;
1010
exports.login = false;
1111
exports.category = "basic";
1212
exports.desc = "Create a new API specification";
13+
exports.weight = 0;
1314

1415
var types = [
1516
{ "name": "application/json", "checked": true },

0 commit comments

Comments
 (0)