diff --git a/example/_apidoc.js b/example/exam1/_apidoc.js similarity index 96% rename from example/_apidoc.js rename to example/exam1/_apidoc.js index 639ed63..094883c 100644 --- a/example/_apidoc.js +++ b/example/exam1/_apidoc.js @@ -1,100 +1,100 @@ -// ------------------------------------------------------------------------------------------ -// General apiDoc documentation blocks and old history blocks. -// ------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------ -// Current Success. -// ------------------------------------------------------------------------------------------ - - -// ------------------------------------------------------------------------------------------ -// Current Errors. -// ------------------------------------------------------------------------------------------ -/** - * @apiDefine CreateUserError - * @apiVersion 0.2.0 - * - * @apiError NoAccessRight Only authenticated Admins can access the data. - * @apiError UserNameTooShort Minimum of 5 characters required. - * - * @apiErrorExample Response (example): - * HTTP/1.1 400 Bad Request - * { - * "error": "UserNameTooShort" - * } - */ - - -// ------------------------------------------------------------------------------------------ -// Current Permissions. -// ------------------------------------------------------------------------------------------ -/** - * @apiDefine admin Admin access rights needed. - * Optionally you can write here further Informations about the permission. - * - * An "apiDefinePermission"-block can have an "apiVersion", so you can attach the block to a specific version. - * - * @apiVersion 0.3.0 - */ - - -// ------------------------------------------------------------------------------------------ -// History. -// ------------------------------------------------------------------------------------------ -/** - * @apiDefine admin This title is visible in version 0.1.0 and 0.2.0 - * @apiVersion 0.1.0 - */ - -/** - * @api {get} /user/:id Read data of a User - * @apiVersion 0.2.0 - * @apiName GetUser - * @apiGroup User - * @apiPermission admin - * - * @apiDescription Here you can describe the function. - * Multilines are possible. - * - * @apiParam {String} id The Users-ID. - * - * @apiSuccess {String} id The Users-ID. - * @apiSuccess {Date} name Fullname of the User. - * - * @apiError UserNotFound The id of the User was not found. - */ - -/** - * @api {get} /user/:id Read data of a User - * @apiVersion 0.1.0 - * @apiName GetUser - * @apiGroup User - * @apiPermission admin - * - * @apiDescription Here you can describe the function. - * Multilines are possible. - * - * @apiParam {String} id The Users-ID. - * - * @apiSuccess {String} id The Users-ID. - * @apiSuccess {Date} name Fullname of the User. - * - * @apiError UserNotFound The error description text in version 0.1.0. - */ - -/** - * @api {post} /user Create a User - * @apiVersion 0.2.0 - * @apiName PostUser - * @apiGroup User - * @apiPermission none - * - * @apiDescription In this case "apiErrorStructure" is defined and used. - * Define blocks with params that will be used in several functions, so you dont have to rewrite them. - * - * @apiParam {String} name Name of the User. - * - * @apiSuccess {String} id The Users-ID. - * - * @apiUse CreateUserError +// ------------------------------------------------------------------------------------------ +// General apiDoc documentation blocks and old history blocks. +// ------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------ +// Current Success. +// ------------------------------------------------------------------------------------------ + + +// ------------------------------------------------------------------------------------------ +// Current Errors. +// ------------------------------------------------------------------------------------------ +/** + * @apiDefine CreateUserError + * @apiVersion 0.2.0 + * + * @apiError NoAccessRight Only authenticated Admins can access the data. + * @apiError UserNameTooShort Minimum of 5 characters required. + * + * @apiErrorExample Response (example): + * HTTP/1.1 400 Bad Request + * { + * "error": "UserNameTooShort" + * } + */ + + +// ------------------------------------------------------------------------------------------ +// Current Permissions. +// ------------------------------------------------------------------------------------------ +/** + * @apiDefine admin Admin access rights needed. + * Optionally you can write here further Informations about the permission. + * + * An "apiDefinePermission"-block can have an "apiVersion", so you can attach the block to a specific version. + * + * @apiVersion 0.3.0 + */ + + +// ------------------------------------------------------------------------------------------ +// History. +// ------------------------------------------------------------------------------------------ +/** + * @apiDefine admin This title is visible in version 0.1.0 and 0.2.0 + * @apiVersion 0.1.0 + */ + +/** + * @api {get} /user/:id Read data of a User + * @apiVersion 0.2.0 + * @apiName GetUser + * @apiGroup User + * @apiPermission admin + * + * @apiDescription Here you can describe the function. + * Multilines are possible. + * + * @apiParam {String} id The Users-ID. + * + * @apiSuccess {String} id The Users-ID. + * @apiSuccess {Date} name Fullname of the User. + * + * @apiError UserNotFound The id of the User was not found. + */ + +/** + * @api {get} /user/:id Read data of a User + * @apiVersion 0.1.0 + * @apiName GetUser + * @apiGroup User + * @apiPermission admin + * + * @apiDescription Here you can describe the function. + * Multilines are possible. + * + * @apiParam {String} id The Users-ID. + * + * @apiSuccess {String} id The Users-ID. + * @apiSuccess {Date} name Fullname of the User. + * + * @apiError UserNotFound The error description text in version 0.1.0. + */ + +/** + * @api {post} /user Create a User + * @apiVersion 0.2.0 + * @apiName PostUser + * @apiGroup User + * @apiPermission none + * + * @apiDescription In this case "apiErrorStructure" is defined and used. + * Define blocks with params that will be used in several functions, so you dont have to rewrite them. + * + * @apiParam {String} name Name of the User. + * + * @apiSuccess {String} id The Users-ID. + * + * @apiUse CreateUserError */ \ No newline at end of file diff --git a/example/apidoc.json b/example/exam1/apidoc.json similarity index 96% rename from example/apidoc.json rename to example/exam1/apidoc.json index cba1a09..8bed6fc 100644 --- a/example/apidoc.json +++ b/example/exam1/apidoc.json @@ -1,20 +1,20 @@ -{ - "name": "apidoc-example", - "version": "0.3.0", - "description": "apidoc example project", - "title": "Custom apiDoc browser title", - "url" : "https://api.github.com/v1", - "sampleUrl": "https://api.github.com/v1", - "header": { - "title": "My own header title", - "filename": "header.md" - }, - "footer": { - "title": "My own footer title", - "filename": "footer.md" - }, - "template": { - "withCompare": true, - "withGenerator": true - } +{ + "name": "apidoc-example", + "version": "0.3.0", + "description": "apidoc example project", + "title": "Custom apiDoc browser title", + "url" : "https://api.github.com/v1", + "sampleUrl": "https://api.github.com/v1", + "header": { + "title": "My own header title", + "filename": "header.md" + }, + "footer": { + "title": "My own footer title", + "filename": "footer.md" + }, + "template": { + "withCompare": true, + "withGenerator": true + } } \ No newline at end of file diff --git a/example/example.js b/example/exam1/example.js similarity index 97% rename from example/example.js rename to example/exam1/example.js index 6e83c09..5b41836 100644 --- a/example/example.js +++ b/example/exam1/example.js @@ -1,68 +1,68 @@ -/** - * @api {get} /user/:id Read data of a User - * @apiVersion 0.3.0 - * @apiName GetUser - * @apiGroup User - * @apiPermission admin - * - * @apiDescription Compare Verison 0.3.0 with 0.2.0 and you will see the green markers with new items in version 0.3.0 and red markers with removed items since 0.2.0. - * - * @apiParam {Number} id The Users-ID. - * - * @apiExample Example usage: - * curl -i http://localhost/user/4711 - * - * @apiSuccess {Number} id The Users-ID. - * @apiSuccess {Date} registered Registration Date. - * @apiSuccess {Date} name Fullname of the User. - * @apiSuccess {String[]} nicknames List of Users nicknames (Array of Strings). - * @apiSuccess {Object} profile Profile data (example for an Object) - * @apiSuccess {Number} profile.age Users age. - * @apiSuccess {String} profile.image Avatar-Image. - * @apiSuccess {Object[]} options List of Users options (Array of Objects). - * @apiSuccess {String} options.name Option Name. - * @apiSuccess {String} options.value Option Value. - * - * @apiError NoAccessRight Only authenticated Admins can access the data. - * @apiError UserNotFound The id of the User was not found. - * - * @apiErrorExample Response (example): - * HTTP/1.1 401 Not Authenticated - * { - * "error": "NoAccessRight" - * } - */ -function getUser() { return; } - -/** - * @api {post} /user Create a new User - * @apiVersion 0.3.0 - * @apiName PostUser - * @apiGroup User - * @apiPermission none - * - * @apiDescription In this case "apiErrorStructure" is defined and used. - * Define blocks with params that will be used in several functions, so you dont have to rewrite them. - * - * @apiParam {String} name Name of the User. - * - * @apiSuccess {Number} id The new Users-ID. - * - * @apiUse CreateUserError - */ -function postUser() { return; } - -/** - * @api {put} /user/:id Change a User - * @apiVersion 0.3.0 - * @apiName PutUser - * @apiGroup User - * @apiPermission none - * - * @apiDescription This function has same errors like POST /user, but errors not defined again, they were included with "apiErrorStructure" - * - * @apiParam {String} name Name of the User. - * - * @apiUse CreateUserError - */ +/** + * @api {get} /user/:id Read data of a User + * @apiVersion 0.3.0 + * @apiName GetUser + * @apiGroup User + * @apiPermission admin + * + * @apiDescription Compare Verison 0.3.0 with 0.2.0 and you will see the green markers with new items in version 0.3.0 and red markers with removed items since 0.2.0. + * + * @apiParam {Number} id The Users-ID. + * + * @apiExample Example usage: + * curl -i http://localhost/user/4711 + * + * @apiSuccess {Number} id The Users-ID. + * @apiSuccess {Date} registered Registration Date. + * @apiSuccess {Date} name Fullname of the User. + * @apiSuccess {String[]} nicknames List of Users nicknames (Array of Strings). + * @apiSuccess {Object} profile Profile data (example for an Object) + * @apiSuccess {Number} profile.age Users age. + * @apiSuccess {String} profile.image Avatar-Image. + * @apiSuccess {Object[]} options List of Users options (Array of Objects). + * @apiSuccess {String} options.name Option Name. + * @apiSuccess {String} options.value Option Value. + * + * @apiError NoAccessRight Only authenticated Admins can access the data. + * @apiError UserNotFound The id of the User was not found. + * + * @apiErrorExample Response (example): + * HTTP/1.1 401 Not Authenticated + * { + * "error": "NoAccessRight" + * } + */ +function getUser() { return; } + +/** + * @api {post} /user Create a new User + * @apiVersion 0.3.0 + * @apiName PostUser + * @apiGroup User + * @apiPermission none + * + * @apiDescription In this case "apiErrorStructure" is defined and used. + * Define blocks with params that will be used in several functions, so you dont have to rewrite them. + * + * @apiParam {String} name Name of the User. + * + * @apiSuccess {Number} id The new Users-ID. + * + * @apiUse CreateUserError + */ +function postUser() { return; } + +/** + * @api {put} /user/:id Change a User + * @apiVersion 0.3.0 + * @apiName PutUser + * @apiGroup User + * @apiPermission none + * + * @apiDescription This function has same errors like POST /user, but errors not defined again, they were included with "apiErrorStructure" + * + * @apiParam {String} name Name of the User. + * + * @apiUse CreateUserError + */ function putUser() { return; } \ No newline at end of file diff --git a/example/footer.md b/example/exam1/footer.md similarity index 100% rename from example/footer.md rename to example/exam1/footer.md diff --git a/example/header.md b/example/exam1/header.md similarity index 100% rename from example/header.md rename to example/exam1/header.md diff --git a/example/exam2/_apidoc.js b/example/exam2/_apidoc.js new file mode 100644 index 0000000..094883c --- /dev/null +++ b/example/exam2/_apidoc.js @@ -0,0 +1,100 @@ +// ------------------------------------------------------------------------------------------ +// General apiDoc documentation blocks and old history blocks. +// ------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------ +// Current Success. +// ------------------------------------------------------------------------------------------ + + +// ------------------------------------------------------------------------------------------ +// Current Errors. +// ------------------------------------------------------------------------------------------ +/** + * @apiDefine CreateUserError + * @apiVersion 0.2.0 + * + * @apiError NoAccessRight Only authenticated Admins can access the data. + * @apiError UserNameTooShort Minimum of 5 characters required. + * + * @apiErrorExample Response (example): + * HTTP/1.1 400 Bad Request + * { + * "error": "UserNameTooShort" + * } + */ + + +// ------------------------------------------------------------------------------------------ +// Current Permissions. +// ------------------------------------------------------------------------------------------ +/** + * @apiDefine admin Admin access rights needed. + * Optionally you can write here further Informations about the permission. + * + * An "apiDefinePermission"-block can have an "apiVersion", so you can attach the block to a specific version. + * + * @apiVersion 0.3.0 + */ + + +// ------------------------------------------------------------------------------------------ +// History. +// ------------------------------------------------------------------------------------------ +/** + * @apiDefine admin This title is visible in version 0.1.0 and 0.2.0 + * @apiVersion 0.1.0 + */ + +/** + * @api {get} /user/:id Read data of a User + * @apiVersion 0.2.0 + * @apiName GetUser + * @apiGroup User + * @apiPermission admin + * + * @apiDescription Here you can describe the function. + * Multilines are possible. + * + * @apiParam {String} id The Users-ID. + * + * @apiSuccess {String} id The Users-ID. + * @apiSuccess {Date} name Fullname of the User. + * + * @apiError UserNotFound The id of the User was not found. + */ + +/** + * @api {get} /user/:id Read data of a User + * @apiVersion 0.1.0 + * @apiName GetUser + * @apiGroup User + * @apiPermission admin + * + * @apiDescription Here you can describe the function. + * Multilines are possible. + * + * @apiParam {String} id The Users-ID. + * + * @apiSuccess {String} id The Users-ID. + * @apiSuccess {Date} name Fullname of the User. + * + * @apiError UserNotFound The error description text in version 0.1.0. + */ + +/** + * @api {post} /user Create a User + * @apiVersion 0.2.0 + * @apiName PostUser + * @apiGroup User + * @apiPermission none + * + * @apiDescription In this case "apiErrorStructure" is defined and used. + * Define blocks with params that will be used in several functions, so you dont have to rewrite them. + * + * @apiParam {String} name Name of the User. + * + * @apiSuccess {String} id The Users-ID. + * + * @apiUse CreateUserError + */ \ No newline at end of file diff --git a/example/exam2/example.js b/example/exam2/example.js new file mode 100644 index 0000000..5b41836 --- /dev/null +++ b/example/exam2/example.js @@ -0,0 +1,68 @@ +/** + * @api {get} /user/:id Read data of a User + * @apiVersion 0.3.0 + * @apiName GetUser + * @apiGroup User + * @apiPermission admin + * + * @apiDescription Compare Verison 0.3.0 with 0.2.0 and you will see the green markers with new items in version 0.3.0 and red markers with removed items since 0.2.0. + * + * @apiParam {Number} id The Users-ID. + * + * @apiExample Example usage: + * curl -i http://localhost/user/4711 + * + * @apiSuccess {Number} id The Users-ID. + * @apiSuccess {Date} registered Registration Date. + * @apiSuccess {Date} name Fullname of the User. + * @apiSuccess {String[]} nicknames List of Users nicknames (Array of Strings). + * @apiSuccess {Object} profile Profile data (example for an Object) + * @apiSuccess {Number} profile.age Users age. + * @apiSuccess {String} profile.image Avatar-Image. + * @apiSuccess {Object[]} options List of Users options (Array of Objects). + * @apiSuccess {String} options.name Option Name. + * @apiSuccess {String} options.value Option Value. + * + * @apiError NoAccessRight Only authenticated Admins can access the data. + * @apiError UserNotFound The id of the User was not found. + * + * @apiErrorExample Response (example): + * HTTP/1.1 401 Not Authenticated + * { + * "error": "NoAccessRight" + * } + */ +function getUser() { return; } + +/** + * @api {post} /user Create a new User + * @apiVersion 0.3.0 + * @apiName PostUser + * @apiGroup User + * @apiPermission none + * + * @apiDescription In this case "apiErrorStructure" is defined and used. + * Define blocks with params that will be used in several functions, so you dont have to rewrite them. + * + * @apiParam {String} name Name of the User. + * + * @apiSuccess {Number} id The new Users-ID. + * + * @apiUse CreateUserError + */ +function postUser() { return; } + +/** + * @api {put} /user/:id Change a User + * @apiVersion 0.3.0 + * @apiName PutUser + * @apiGroup User + * @apiPermission none + * + * @apiDescription This function has same errors like POST /user, but errors not defined again, they were included with "apiErrorStructure" + * + * @apiParam {String} name Name of the User. + * + * @apiUse CreateUserError + */ +function putUser() { return; } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index a122a6c..6ba07a0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,7 +2,11 @@ var gulp = require('gulp'), apidoc = require('./index.js'); gulp.task('apidoc', done => { - apidoc({ src: './example', dest: './build'}, done); + apidoc({ src: './example/exam1', dest: './build'}, done); +}); + +gulp.task('multiple', done => { + apidoc({ src: ['./example/exam1', './example/exam2'], dest: './build', debug:true }, done) }); diff --git a/package.json b/package.json index 10ed086..4f7e249 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,6 @@ "version": "0.2.8", "description": " RESTful web API Documentation Generator", "main": "index.js", - "repository": { - "type": "git", - "url": "git://github.com/c0b41/gulp-apidoc" - }, "keywords": [ "gulpplugin", "apidoc", @@ -14,15 +10,13 @@ "rest", "doc" ], - "author": "Ayhan Kuru", + "author": "c0b41", "license": "MIT", - "bugs": { - "url": "https://github.com/c0b41/gulp-apidoc/issues" - }, "homepage": "https://github.com/c0b41/gulp-apidoc", "dependencies": { "ansi-colors": "^1.1.0", "apidoc": "*", + "apidoc-core": "^0.8.3", "fancy-log": "^1.3.2", "object-assign": "^4.1.1", "plugin-error": "^1.0.1"