diff --git a/.gitignore b/.gitignore index 63ea23f8..7798324f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -.settings/ -.project +doc/ node_modules/ tmp/ -doc/ -.idea/ \ No newline at end of file +npm-debug.log diff --git a/.npmignore b/.npmignore index 63ea23f8..0e85c609 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,8 @@ -.settings/ -.project +.git/ node_modules/ +test/ tmp/ -doc/ -.idea/ \ No newline at end of file +.gitignore +.npmignore +.travis.yml +npm-debug.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1bca95..2246e76b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # apiDoc Changelog + +#### 0.10.0 + +* __Split apidoc code__ + * [apidoc](https://github.com/apidoc/apidoc) is now only the CLI-Tool with UI-Template and file creation (as you know it). + You can use apidoc without change anything. + + * [apidoc-core](https://github.com/apidoc/apidoc-core) (for developers) is the parser and response the api-data. + + * [apidoc-example](https://github.com/apidoc/apidoc-example) (for developers) are the test files for the [apidoc-spec](https://github.com/apidoc/apidoc-spec). + +* CLI + * Replace optimist (not maintained anymore) with nomnom: + true / false parameters can now be used, e.g. enable markdown (default) `--markdown` or disable `--no-markdown`. + * Add parameter `--markdown`. + * Replace the custom Logger with [winston](https://github.com/flatiron/winston). + +* Parser + * Bugfix: Settings to enable / disable markdown (marked-gfm was previously used). + +* Template + * Add generator.url and generator.name to the footer generator information (for custom ui-generators). + * Move handlebars_helper.js to utils/ + +* Common + * Remove grunt dependencies (test run with `npm run test`). + * Change grunt-apidoc (0.10.0) to use always the latest version of apiDoc. + + #### 0.9.1 * Parser diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index f2f0b41a..00000000 --- a/Gruntfile.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * apidoc - * http://apidocjs.com - * - * Copyright (c) 2013-2014 inveris OHG - * Author Peter Rottmann - * Licensed under the MIT license. - */ - -"use strict"; - -module.exports = function(grunt) -{ - /* -------------------------------------------------------------------------------- - * Configuration - * -------------------------------------------------------------------------------- */ - grunt.initConfig({ - pkg: grunt.file.readJSON("package.json"), - - // Clear temporary dir - clean: { - test: ["tmp"] - }, // clean - - jshint: { - all: ["Gruntfile.js", "lib/**/*.js", "test/**/*.js", "!test/fixtures/**"], - options: { - // Enforcing Options - bitwise: true, - camelcase: true, - curly: false, - eqeqeq: true, - forin: true, - immed: true, - latedef: false, - newcap: true, - noarg: true, - noempty: true, - nonew: true, - plusplus: true, - // quotmark: "double", - regexp: false, - undef: false, - unused: false, - shadow: true, - strict: false, - trailing: true, - maxlen: 160, - // Relaxing Options - boss: true, - eqnull: true, - smarttabs: true, - sub: true, - // Environments - browser: false, - passfail: false, - node: true - } - }, // js-hint - - simplemocha: { - options: { - globals: ["should"], - timeout: 2000, - ignoreLeaks: false, - ui: "bdd", - reporter: "spec" - }, - all: { src: ["test/*_test.js"] } - } // simplemocha - }); // grunt.initConfig - - /* -------------------------------------------------------------------------------- - * Modules - * -------------------------------------------------------------------------------- */ - grunt.loadNpmTasks("grunt-contrib-clean"); - grunt.loadNpmTasks("grunt-contrib-jshint"); - grunt.loadNpmTasks("grunt-simple-mocha"); - - /* -------------------------------------------------------------------------------- - * Tasks - * -------------------------------------------------------------------------------- */ - // Task: default - grunt.registerTask("default", ["jshint"]); - - // Task: test - grunt.registerTask("test", ["clean", "jshint", "simplemocha"]); -}; \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..47a63958 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013-2014 inveris OHG +Author Peter Rottmann +Licensed under the MIT license. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index f865a565..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2013-2014 inveris OHG -Author Peter Rottmann -Licensed under the MIT license. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 4f6e32e0..8219768d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# apiDoc 0.9.x +# apiDoc 0.10.x Generates a RESTful web API Documentation. @@ -124,12 +124,3 @@ Pull requests are welcome too! A chat about apiDoc is on [Gitter](https://gitter.im/apidoc/talk). [![Gitter chat](https://badges.gitter.im/apidoc/talk.png)](https://gitter.im/apidoc/talk) - - -## License - -Copyright (c) 2013-2014 inveris OHG - -Author Peter Rottmann - -Licensed under the MIT license. diff --git a/bin/apidoc b/bin/apidoc index bfe263d5..b4b66711 100755 --- a/bin/apidoc +++ b/bin/apidoc @@ -11,77 +11,73 @@ * Licensed under the MIT license. */ -var path = require('path'); -var optimist = require('optimist'); +var path = require('path'); +var nomnom = require('nomnom'); +var apidoc = require('../lib/index'); -var argv = optimist - .usage('Usage: $0 [options]') +var argv = nomnom + .option('file-filters', { abbr: 'f', 'default': '.*\\.(coffee|cs|dart|erl|go|java|js|php?|py|rb|ts|pm)$', + help: 'RegEx-Filter to select files that should be parsed (multiple -f can be used).' }) - .option('f', { alias: 'file-filters', 'default': '.*\\.(coffee|cs|dart|erl|go|java|js|php?|py|rb|ts|pm)$', - describe: 'RegEx-Filter to select files that should be parsed (multiple -f can be used).' }) + .option('exclude-filters', { abbr: 'e', 'default': '', + help: 'RegEx-Filter to select files / dirs that should not be parsed (many -e can be used).', }) - .option('e', { alias: 'exclude-filters', 'default': '', - describe: 'RegEx-Filter to select files / dirs that should not be parsed (many -e can be used).', }) + .option('input', { abbr: 'i', 'default': './', help: 'Input / source dirname.' }) - .option('i', { alias: 'input', 'default': './', describe: 'Input / source dirname.' }) + .option('output', { abbr: 'o', 'default': './doc/', help: 'Output dirname.' }) - .option('o', { alias: 'output', 'default': './doc/', describe: 'Output dirname.' }) + .option('template', { abbr: 't', 'default': path.join(__dirname, '../template/'), + help: 'Use template for output files.' }) - .option('t', { alias: 'template', 'default': path.join(__dirname, '../template/'), - describe: 'Use template for output files.' }) + .option('verbose', { abbr: 'v', flag: true, 'default': false, help: 'Verbose debug output.' }) - .option('v', { alias: 'verbose', boolean: true, 'default': false, describe: 'Verbose debug output.' }) + .option('help', { abbr: 'h', flag: true, help: 'Show this help information.' }) - .option('h', { alias: 'help', boolean: true, describe: 'Show this help information.' }) + .option('debug', { flag: true, 'default': false, help: 'Show debug messages.' }) - .option('debug', { boolean: true, 'default': false, describe: 'Show debug messages.' }) + .option('color', { flag: true, 'default': true, help: 'Turn off log color.' }) - .option('no-color', { boolean: true, 'default': false, describe: 'Turn off log color.' }) + .option('parse', { flag: true, 'default': false, + help: 'Parse only the files and return the data, no file creation.' }) - .option('parse', { boolean: true, 'default': false, - describe: 'Parse only the files and return the data, no file creation.' }) + .option('parse-filters', { help: 'Optional user defined filters. Format name=filename' }) + .option('parse-parsers', { help: 'Optional user defined parsers. Format name=filename' }) + .option('parse-workers', { help: 'Optional user defined workers. Format name=filename' }) - .option('parse-filters', { describe: 'Optional user defined filters. Format name=filename' }) - .option('parse-parsers', { describe: 'Optional user defined parsers. Format name=filename' }) - .option('parse-workers', { describe: 'Optional user defined workers. Format name=filename' }) + .option('silent', { flag: true, 'default': false, help: 'Turn all output off.' }) - .option('silent', { boolean: true, 'default': false, describe: 'Turn all output off.' }) - - .option('simulate', { boolean: true, 'default': false, describe: 'Execute but not write any file.' }) + .option('simulate', { flag: true, 'default': false, help: 'Execute but not write any file.' }) // markdown settings + .option('markdown', { flag: true, 'default': true, help: 'Turn off markdown parser.' }) + .option('marked-config', { 'default': '', - describe: 'Enable custom markdown parser configs. It will overwite all other marked settings.' }) + help: 'Enable custom markdown parser configs. It will overwite all other marked settings.' }) - .option('marked-gfm', { boolean: true, 'default': true, - describe: 'Enable GitHub flavored markdown.' }) + .option('marked-gfm', { flag: true, 'default': true, + help: 'Enable GitHub flavored markdown.' }) - .option('marked-tables', { boolean: true, 'default': true, - describe: 'Enable GFM tables. This option requires the gfm option to be true.' }) + .option('marked-tables', { flag: true, 'default': true, + help: 'Enable GFM tables. This option requires the gfm option to be true.' }) - .option('marked-breaks', { boolean: true, 'default': false, - describe: 'Enable GFM line breaks. This option requires the gfm option to be true.' }) + .option('marked-breaks', { flag: true, 'default': false, + help: 'Enable GFM line breaks. This option requires the gfm option to be true.' }) - .option('marked-pedantic', { boolean: true, 'default': false, - describe: 'Conform to obscure parts of markdown.pl as much as possible.' }) + .option('marked-pedantic', { flag: true, 'default': false, + help: 'Conform to obscure parts of markdown.pl as much as possible.' }) - .option('marked-sanitize', { boolean: true, 'default': false, - describe: 'Sanitize the output. Ignore any HTML that has been input.' }) + .option('marked-sanitize', { flag: true, 'default': false, + help: 'Sanitize the output. Ignore any HTML that has been input.' }) - .option('marked-smartLists', { boolean: true, 'default': false, - describe: 'Use smarter list behavior than the original markdown.' }) + .option('marked-smartLists', { flag: true, 'default': false, + help: 'Use smarter list behavior than the original markdown.' }) - .option('marked-smartypants', { boolean: true, 'default': false, - describe: 'Use \'smart\' typograhic punctuation for things like quotes and dashes.' }) + .option('marked-smartypants', { flag: true, 'default': false, + help: 'Use \'smart\' typograhic punctuation for things like quotes and dashes.' }) - .argv + .parse() ; -if (argv.help) { - optimist.showHelp(); - process.exit(0); -} - /** * Transform parameters to object * @@ -117,34 +113,36 @@ function resolveMarkdownOptions(argv) { return require(path.resolve(argv['marked-config'])); } else { return { - gfm: argv['marked-gfm'], - tables: argv['marked-tables'], - breaks: argv['marked-breaks'], - pedantic: argv['marked-pedantic'], - sanitize: argv['marked-sanitize'], - smartLists: argv['marked-smartLists'], + gfm : argv['marked-gfm'], + tables : argv['marked-tables'], + breaks : argv['marked-breaks'], + pedantic : argv['marked-pedantic'], + sanitize : argv['marked-sanitize'], + smartLists : argv['marked-smartLists'], smartypants: argv['marked-smartypants'] }; } } -var defaults = { +var options = { excludeFilters: argv['exclude-filters'], includeFilters: argv['file-filters'], - src: argv['input'], - dest: argv['output'], - template: argv['template'], - verbose: argv['debug'] === true ? argv['debug'] : argv['verbose'], - debug: argv['debug'], - parse: argv['parse'], - filters: transformToObject(argv['parse-filters']), - parsers: transformToObject(argv['parse-parsers']), - workers: transformToObject(argv['parse-workers']), - silent: argv['silent'], - simulate: argv['simulate'], - marked: resolveMarkdownOptions(argv) + src : argv['input'], + dest : argv['output'], + template : argv['template'], + verbose : argv['verbose'], + debug : argv['debug'], + parse : argv['parse'], + colorize : argv['color'], + filters : transformToObject(argv['parse-filters']), + parsers : transformToObject(argv['parse-parsers']), + workers : transformToObject(argv['parse-workers']), + silent : argv['silent'], + simulate : argv['simulate'], + markdown : argv['markdown'], + marked : resolveMarkdownOptions(argv) }; -try { - require('../lib/apidoc')(defaults); -} catch (e) {} +if (apidoc.createDoc(options) === false) { + process.exit(1); +} diff --git a/lib/apidoc.js b/lib/apidoc.js deleted file mode 100644 index 7544d1c1..00000000 --- a/lib/apidoc.js +++ /dev/null @@ -1,318 +0,0 @@ -var _ = require('lodash'); -var path = require('path'); -var semver = require('semver'); -var PackageInfo = require('./package_info'); -var Parser = require('./parser'); -var Worker = require('./worker'); -var Filter = require('./filter'); -var colors = require('colors');var fs = require('fs-extra'); -var logger = require('./utils/console_logger'); -var FileError = require('./errors/file_error'); -var ParameterError = require('./errors/parameter_error'); -var ParserError = require('./errors/parser_error'); -var WorkerError = require('./errors/worker_error'); - -// const -var APIDOC_SPECIFICATION_VERSION = '0.2.0'; - -// Options -var _defaultOptions = { - excludeFilters: [], - includeFilters: [ '.*\\.(coffee|cs|dart|erl|go|java|js|php?|py|rb|ts|pm)$' ], - - src: path.join(__dirname, '../example/'), - dest: path.join(__dirname, '../doc/'), - - debug: false, - silent: false, - verbose: false, - simulate: false, - parse: false, // only parse and return the data, no file creation - - template: path.join(__dirname, '../template/'), - - filters: {}, - parsers: {}, - workers: {}, - - marked: { - gfm: true, - tables: true, - breaks: false, - pedantic: false, - sanitize: false, - smartLists: false, - smartypants: false - } -}; - -var options = {}; -_.defaults(options, _defaultOptions); - -var app = { - log: logger, - options: options, - filters: { - apierror : './filters/api_error.js', - apiheader : './filters/api_header.js', - apiparam : './filters/api_param.js', - apisuccess : './filters/api_success.js' - }, - parsers: { - api : './parsers/api.js', - apidefine : './parsers/api_define.js', - apidefineerrorstructure : './parsers/api_define_error_structure.js', - apidefineheaderstructure : './parsers/api_define_header_structure.js', - apidefinepermission : './parsers/api_define_permission.js', - apidefinestructure : './parsers/api_define_structure.js', - apidefinesuccessstructure: './parsers/api_define_success_structure.js', - apigroupdescription : './parsers/api_group_description.js', - apidescription : './parsers/api_description.js', - apierror : './parsers/api_error.js', - apierrorexample : './parsers/api_error_example.js', - apierrorstructure : './parsers/api_error_structure.js', - apierrortitle : './parsers/api_error_title.js', - apiexample : './parsers/api_example.js', - apiheader : './parsers/api_header.js', - apiheaderexample : './parsers/api_header_example.js', - apiheaderstructure : './parsers/api_header_structure.js', - apiheadertitle : './parsers/api_header_title.js', - apigroup : './parsers/api_group.js', - apiname : './parsers/api_name.js', - apiparam : './parsers/api_param.js', - apiparamexample : './parsers/api_param_example.js', - apiparamtitle : './parsers/api_param_title.js', - apipermission : './parsers/api_permission.js', - apistructure : './parsers/api_structure.js', - apisuccess : './parsers/api_success.js', - apisuccessexample : './parsers/api_success_example.js', - apisuccessstructure : './parsers/api_success_structure.js', - apisuccesstitle : './parsers/api_success_title.js', - apiuse : './parsers/api_use.js', - apiversion : './parsers/api_version.js', - apisamplerequest : './parsers/api_sample_request.js' - }, - workers: { - apierrorstructure : './workers/api_error_structure.js', - apierrortitle : './workers/api_error_title.js', - apigroup : './workers/api_group.js', - apiheaderstructure : './workers/api_header_structure.js', - apiheadertitle : './workers/api_header_title.js', - apiname : './workers/api_name.js', - apiparamtitle : './workers/api_param_title.js', - apipermission : './workers/api_permission.js', - apisamplerequest : './workers/api_sample_request.js', - apistructure : './workers/api_structure.js', - apisuccessstructure : './workers/api_success_structure.js', - apisuccesstitle : './workers/api_success_title.js', - apiuse : './workers/api_use.js', - - deprecatedApiErrorTitle : './workers/deprecated_api_error_title.js', - deprecatedApiHeaderTitle : './workers/deprecated_api_header_title.js', - deprecatedApiParamTitle : './workers/deprecated_api_param_title.js', - deprecatedApiSuccessTitle: './workers/deprecated_api_success_title.js' - } -}; // app - -// uncaughtException -process.on('uncaughtException', function(err) { - console.error((new Date()).toUTCString() + ' uncaughtException:', err.message); - console.error(err.stack); - process.exit(1); -}); - -/** - * Parser - * - * @param {Object} defaults Overwrite default options. - * @returns {Mixed} False on error | 0 = nothing todo | 1 = everything ok | List of Parsed files (if parse is set). - */ -function parse(defaults) { - // bin-parameters - if (defaults) - options = _.defaults(defaults, options); - - // Paths - options.dest = path.join(options.dest, './'); - options.template = path.join(options.template, './'); - - // extend with custom functions - app.filters = _.defaults(options.filters, app.filters); - app.parsers = _.defaults(options.parsers, app.parsers); - app.workers = _.defaults(options.workers, app.workers); - - // Options - app.options = options; - - // Log - app.log.setDebug(app.options.debug); - app.log.setSilent(app.options.silent); - app.log.setVerbose(app.options.verbose); - - var parsedFiles = []; - var parsedFilenames = []; - - try { - var packageInfo = new PackageInfo(app); - var parser = new Parser(app); - var worker = new Worker(app); - var filter = new Filter(app); - - // If input option for source is an array of folders, - // parse each folder in the order provided. - if (options.src instanceof Array) { - options.src.forEach(function(folder) { - // Keep same options for each folder, but ensure the 'src' of options - // is the folder currently being processed. - var folderOptions = options; - folderOptions.src = path.join(folder, './'); - parser.parseFiles(folderOptions, parsedFiles, parsedFilenames); - }); - } - else { - // If the input option for source is a single folder, parse as usual. - options.src = path.join(options.src, './'); - parser.parseFiles(options, parsedFiles, parsedFilenames); - } - - if (parsedFiles.length > 0) { - var packageInfos = packageInfo.get(); - - // process transformations and assignments - worker.process(parsedFiles, parsedFilenames, packageInfos); - - // cleanup - var blocks = filter.process(parsedFiles, parsedFilenames); - - // create files - var result = createOutputFiles(blocks, packageInfos); - - app.log.success('Done.'); - return result; - } else { - app.log.success('Nothing to do.'); - return 0; - } - } catch(e) { - // display error by instance - if (e instanceof FileError) { - var extra = []; - extra.push({ 'Path': e.path }); - app.log.error(e.message, extra); - } else if (e instanceof ParserError) { - var extra = e.extra; - if (e.source) - extra.unshift({ 'Source': e.source }); - if (e.element) - extra.unshift({ 'Element': '@' + e.element }); - if (e.block) - extra.unshift({ 'Block': e.block }); - if (e.file) - extra.unshift({ 'File': e.file }); - app.log.error(e.message, extra); - } - else if (e instanceof WorkerError) { - var extra = e.extra; - if (e.definition) - extra.push({ 'Definition': e.definition }); - if (e.example) - extra.push({ 'Example': e.example }); - extra.unshift({ 'Element': '@' + e.element }); - extra.unshift({ 'Block': e.block }); - extra.unshift({ 'File': e.file }); - app.log.error(e.message, extra); - } - else { - if (e.stack) - app.log.debug(e.stack); - app.log.error(e); - } - - // bubble error - throw e; - } - return; -} - -/** - * Output parsed content to files - * - * @param {Object[]} blocks - * @param {String[]} filenames - * @returns {Object} - */ -function createOutputFiles(blocks, packageInfos) { - - // TODO: sorting after filtering - // sort by group ASC, name ASC, version DESC - blocks.sort(function(a, b) { - var nameA = a.group + a.name; - var nameB = b.group + b.name; - if (nameA === nameB) { - if (a.version === b.version) - return 0; - return (semver.gte(a.version, b.version)) ? -1 : 1; - } - return (nameA < nameB) ? -1 : 1; - }); - - if (options.simulate) - app.log.warning('!!! Simulation !!! No file or dir will be copied or created.'); - - // api_data - var apiData = JSON.stringify(blocks, null, 2); - apiData = apiData.replace(/(\r\n|\n|\r)/g, '\r\n'); - - // add apiDoc specification version - packageInfos.apidoc = APIDOC_SPECIFICATION_VERSION; - - // api_project - var apiProject = JSON.stringify(packageInfos, null, 2); - apiProject = apiProject.replace(/(\r\n|\n|\r)/g, '\r\n'); - - if (options.parse === true) - return { - apiData : apiData, - apiProject: apiProject - }; - - app.log.debug('create dir: ' + options.dest); - if ( ! options.simulate) - fs.mkdirsSync(options.dest); - - app.log.debug('copy template ' + options.template + ' to: ' + options.dest); - if ( ! options.simulate) - fs.copySync(options.template, options.dest); - - // Write api_data - app.log.debug('write json file: ' + options.dest + 'api_data.json'); - if( ! options.simulate) - fs.writeFileSync(options.dest + './api_data.json', apiData); - - app.log.debug('write js file: ' + options.dest + 'api_data.js'); - if( ! options.simulate) - fs.writeFileSync(options.dest + './api_data.js', 'define({ "api": ' + apiData + ' });'); - - // Write api_project - app.log.debug('write json file: ' + options.dest + 'api_project.json'); - if( ! options.simulate) - fs.writeFileSync(options.dest + './api_project.json', apiProject); - - app.log.debug('write js file: ' + options.dest + 'api_project.js'); - if( ! options.simulate) - fs.writeFileSync(options.dest + './api_project.js', 'define(' + apiProject + ');'); - - return true; -} - -/** - * Exports - */ -module.exports = parse; - -// Direct call -if (path.dirname(process.argv[1]) === __dirname) { - try { - parse(); - } catch (e) {} -} diff --git a/lib/errors/file_error.js b/lib/errors/file_error.js deleted file mode 100644 index 2c57dd63..00000000 --- a/lib/errors/file_error.js +++ /dev/null @@ -1,27 +0,0 @@ -var util = require('util'); -var fs = require('path'); - -function FileError(message, file, path) { - // enable stack trace - Error.call(this); - Error.captureStackTrace(this, this.constructor); - this.name = this.constructor.name; - - this.message = message; - this.file = file || ''; - this.path = path || file; - - if (this.path && this.path.charAt(this.path.length - 1) !== '/') { - this.path = fs.dirname(this.path); - } -} - -/** - * Inherit from Error - */ -util.inherits(FileError, Error); - -/** - * Exports - */ -module.exports = FileError; diff --git a/lib/errors/parameter_error.js b/lib/errors/parameter_error.js deleted file mode 100644 index a1e546f2..00000000 --- a/lib/errors/parameter_error.js +++ /dev/null @@ -1,23 +0,0 @@ -var util = require('util'); - -function ParameterError(message, element, definition, example) { - // enable stack trace - Error.call(this); - Error.captureStackTrace(this, this.constructor); - this.name = this.constructor.name; - - this.message = message; - this.element = element; - this.definition = definition; - this.example = example; -} - -/** - * Inherit from Error - */ -util.inherits(ParameterError, Error); - -/** - * Exports - */ -module.exports = ParameterError; diff --git a/lib/errors/parser_error.js b/lib/errors/parser_error.js deleted file mode 100644 index 59cc9373..00000000 --- a/lib/errors/parser_error.js +++ /dev/null @@ -1,25 +0,0 @@ -var util = require('util'); - -function ParserError(message, file, block, element, source, extra) { - // enable stack trace - Error.call(this); - Error.captureStackTrace(this, this.constructor); - this.name = this.constructor.name; - - this.message = message; - this.file = file; - this.block = block; - this.element = element; - this.source = source; - this.extra = extra || []; -} - -/** - * Inherit from Error - */ -util.inherits(ParserError, Error); - -/** - * Exports - */ -module.exports = ParserError; diff --git a/lib/errors/worker_error.js b/lib/errors/worker_error.js deleted file mode 100644 index e2d83be6..00000000 --- a/lib/errors/worker_error.js +++ /dev/null @@ -1,26 +0,0 @@ -var util = require('util'); - -function WorkerError(message, file, block, element, definition, example, extra) { - // enable stack trace - Error.call(this); - Error.captureStackTrace(this, this.constructor); - this.name = this.constructor.name; - - this.message = message; - this.file = file; - this.block = block; - this.element = element; - this.definition = definition; - this.example = example; - this.extra = extra; -} - -/** - * Inherit from Error - */ -util.inherits(WorkerError, Error); - -/** - * Exports - */ -module.exports = WorkerError; diff --git a/lib/filter.js b/lib/filter.js deleted file mode 100644 index be839ce5..00000000 --- a/lib/filter.js +++ /dev/null @@ -1,68 +0,0 @@ -var util = require('util'); -var _ = require('lodash'); - -var app = {}; - -/** - * Filter - * Cleanup the data, e.g.: remove double fields, happen when overwrite a global inherited field with a local definition. - * - * @param {Object} _app - */ -function Filter(_app) { - var self = this; - - // global variables - app = _app; - - // class variables - this.filters = {}; - - // load filters - var filters = Object.keys(app.filters); - filters.forEach(function(filter) { - var filename = app.filters[filter]; - app.log.debug('load filter: ' + filter + ', ' + filename); - self.addFilter(filter, require(filename)); - }); -} - -/** - * Inherit - */ -util.inherits(Filter, Object); - -/** - * Exports - */ -module.exports = Filter; - -/** - * Add Filter - */ -Filter.prototype.addFilter = function(name, filter) { - this.filters[name] = filter; -}; - -/** - * Execute filter - */ -Filter.prototype.process = function(parsedFiles, parsedFilenames) { - // filter each @api-Parameter - _.each(this.filters, function(filter, name) { - if (filter.postFilter) { - app.log.info('filter postFilter: ' + name); - filter.postFilter(parsedFiles, parsedFilenames); - } - }); - - // reduce to local blocks where global is empty - var blocks = []; - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (Object.keys(block.global).length === 0 && Object.keys(block.local).length > 0) - blocks.push(block.local); - }); - }); - return blocks; -}; diff --git a/lib/filters/api_error.js b/lib/filters/api_error.js deleted file mode 100644 index 2408c428..00000000 --- a/lib/filters/api_error.js +++ /dev/null @@ -1,19 +0,0 @@ -// Same as @apiParam -var filterApiParam = require('./api_param.js'); - -/** - * Post Filter parsed results. - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - */ -function postFilter(parsedFiles, filenames) { - filterApiParam.postFilter(parsedFiles, filenames, 'error'); -} - -/** - * Exports - */ -module.exports = { - postFilter: postFilter -}; diff --git a/lib/filters/api_header.js b/lib/filters/api_header.js deleted file mode 100644 index d7b0aff4..00000000 --- a/lib/filters/api_header.js +++ /dev/null @@ -1,19 +0,0 @@ -// Same as @apiParam -var filterApiParam = require('./api_param.js'); - -/** - * Post Filter parsed results. - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - */ -function postFilter(parsedFiles, filenames) { - filterApiParam.postFilter(parsedFiles, filenames, 'header'); -} - -/** - * Exports - */ -module.exports = { - postFilter: postFilter -}; diff --git a/lib/filters/api_param.js b/lib/filters/api_param.js deleted file mode 100644 index 576a714a..00000000 --- a/lib/filters/api_param.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Post Filter parsed results - * Remove double fields, happen when overwrite a global inherited field with a local definition. - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {String} tagName Example: 'parameter' - * @returns {Object} - */ -function postFilter(parsedFiles, filenames, tagName) { - tagName = tagName || 'parameter'; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (block.local[tagName] && block.local[tagName].fields) { - var blockFields = block.local[tagName].fields; - Object.keys(blockFields).forEach(function(blockFieldKey) { - var fields = block.local[tagName].fields[blockFieldKey]; - var newFields = []; - var existingKeys = {}; - fields.forEach(function(field) { - var key = field.field; // .field (=id) is the key to check if it exists twice - if ( ! existingKeys[key]) { - existingKeys[key] = 1; - newFields.push(field); - } - }); - block.local[tagName].fields[blockFieldKey] = newFields; - }); - } - }); - }); -} - -/** - * Exports - */ -module.exports = { - postFilter: postFilter -}; diff --git a/lib/filters/api_success.js b/lib/filters/api_success.js deleted file mode 100644 index c9e7defc..00000000 --- a/lib/filters/api_success.js +++ /dev/null @@ -1,19 +0,0 @@ -// Same as @apiParam -var filterApiParam = require('./api_param.js'); - -/** - * Post Filter parsed results. - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - */ -function postFilter(parsedFiles, filenames) { - filterApiParam.postFilter(parsedFiles, filenames, 'success'); -} - -/** - * Exports - */ -module.exports = { - postFilter: postFilter -}; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 00000000..4ac0ec44 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,156 @@ +var _ = require('lodash'); +var fs = require('fs-extra'); +var markdown = require('marked'); +var path = require('path'); +var winston = require('winston'); + +var PackageInfo = require('./package_info'); + +var apidoc = require('../../apidoc-core/'); + +var defaults = { + dest : path.join(__dirname, '../doc/'), + template: path.join(__dirname, '../template/'), + + debug : false, + silent : false, + verbose : false, + simulate: false, + parse : false, // only parse and return the data, no file creation + colorize: true, + markdown: true, + + marked: { + gfm : true, + tables : true, + breaks : false, + pedantic : false, + sanitize : false, + smartLists : false, + smartypants: false + } +}; + +var app = { + log : {}, + markdown: false, + options : {} +}; + +// uncaughtException +process.on('uncaughtException', function(err) { + console.error((new Date()).toUTCString() + ' uncaughtException:', err.message); + console.error(err.stack); + process.exit(1); +}); + +/** + * Create the documentation + * + * @param {Object} options See defaults and apidoc-core defaults for all options / `apidoc --help` + * @returns {Mixed} true = ok, but nothing todo | false = error | Object with parsed data and project-informations. + */ +function createDoc(options) { + _.defaults(options, defaults); + + // paths + options.dest = path.join(options.dest, './'); + options.template = path.join(options.template, './'); + + // options + app.options = options; + + // logger + app.log = new (winston.Logger)({ + transports: [ + new (winston.transports.Console)({ + level : app.options.debug ? 'debug' : app.options.verbose ? 'verbose' : 'info', + silent : app.options.silent, + prettyPrint: true, + colorize : app.options.colorize, + timestamp : false + }), + ] + }); + + // markdown + if(app.options.markdown === true) { + app.markdown = markdown; + app.markdown.setOptions(app.options.marked); + } + + try { + var packageInfo = new PackageInfo(app); + var packageInfos = packageInfo.get(); + + // generator information + var apidocPath = path.join(__dirname, '../'); + var json = JSON.parse( fs.readFileSync(apidocPath + 'package.json', 'utf8') ); + var generator = { + version: json.version, + time : new Date(), + name : json.name, + url : json.homepage + }; + + var api = apidoc.parse(app.options, app.log, generator, packageInfos, app.markdown); + if (api === true) { + app.log.info('Nothing to do.'); + return true; + } + if (api === false) + return false; + + if (app.options.parse !== true) + createOutputFiles(api); + + app.log.info('Done.'); + return api; + } catch(e) { + app.log.error(e.message); + if (e.stack) + app.log.debug(e.stack); + return false; + } +} + +/** + * Save parsed data to files + * + * @param {Object[]} blocks + * @param {Object} packageInfos + */ +function createOutputFiles(api) { + if (app.options.simulate) + app.log.warn('!!! Simulation !!! No file or dir will be copied or created.'); + + app.log.verbose('create dir: ' + app.options.dest); + if ( ! app.options.simulate) + fs.mkdirsSync(app.options.dest); + + app.log.verbose('copy template ' + app.options.template + ' to: ' + app.options.dest); + if ( ! app.options.simulate) + fs.copySync(app.options.template, app.options.dest); + + // Write api_data + app.log.verbose('write json file: ' + app.options.dest + 'api_data.json'); + if( ! app.options.simulate) + fs.writeFileSync(app.options.dest + './api_data.json', api.data); + + app.log.verbose('write js file: ' + app.options.dest + 'api_data.js'); + if( ! app.options.simulate) + fs.writeFileSync(app.options.dest + './api_data.js', 'define({ "api": ' + api.data + ' });'); + + // Write api_project + app.log.verbose('write json file: ' + app.options.dest + 'api_project.json'); + if( ! app.options.simulate) + fs.writeFileSync(app.options.dest + './api_project.json', api.project); + + app.log.verbose('write js file: ' + app.options.dest + 'api_project.js'); + if( ! app.options.simulate) + fs.writeFileSync(app.options.dest + './api_project.js', 'define(' + api.project + ');'); +} + +module.exports = { + createDoc: createDoc +}; diff --git a/lib/package_info.js b/lib/package_info.js index b6874e72..4fbb94e9 100644 --- a/lib/package_info.js +++ b/lib/package_info.js @@ -1,31 +1,21 @@ -var fs = require('fs'); +var _ = require('lodash'); +var fs = require('fs'); var path = require('path'); -var util = require('util'); -var _ = require('lodash'); -var markdown = require('marked'); var app = {}; function PackageInfo(_app) { // global variables app = _app; - - // marked (markdown) Settings. - markdown.setOptions(app.options.marked); } -/** - * Inherit - */ -util.inherits(PackageInfo, Object); - /** * Exports */ module.exports = PackageInfo; /** - * Read package.json Data and optinal descriptions + * Read apidoc.json / package.json data */ PackageInfo.prototype.get = function() { var result = {}; @@ -33,16 +23,16 @@ PackageInfo.prototype.get = function() { // Read package.json var packageJson = this._readPackageData('package.json'); - if(packageJson.apidoc) + if (packageJson.apidoc) result = packageJson.apidoc; _.defaults(result, { - name : packageJson.name || '', - version : packageJson.version || '0.0.0', + name : packageJson.name || '', + version : packageJson.version || '0.0.0', description: packageJson.description || '', }); - // Read apidoc.json (and overwrite package.json information) + // read apidoc.json (and overwrite package.json information) var apidocJson = this._readPackageData('apidoc.json'); // apidoc.json has higher priority @@ -51,21 +41,11 @@ PackageInfo.prototype.get = function() { // options.packageInfo overwrites packageInfo _.extend(result, app.options.packageInfo); - // Replace header footer with file contents + // replace header footer with file contents _.extend(result, this._getHeaderFooter(result)); if (Object.keys(apidocJson).length === 0) - app.log.warning('Please create an apidoc.json.'); - - // Generator Information - try { - var apidocPath = path.join(__dirname, '../'); - var json = JSON.parse( fs.readFileSync(apidocPath + 'package.json', 'utf8') ); - result.generator = { - version: json.version, - time: new Date() - }; - } catch(e) {} + app.log.warn('Please create an apidoc.json.'); return result; }; @@ -111,16 +91,16 @@ PackageInfo.prototype._getHeaderFooter = function(json) { ['header', 'footer'].forEach(function(key) { if (json[key] && json[key].filename) { - console.log(key); var filename = path.join(app.options.src, json[key].filename); if ( ! fs.existsSync(filename)) filename = path.join('./', json[key].filename); try { app.log.debug('read header file: ' + filename); + var content = fs.readFileSync(filename, 'utf8'); result[key] = { title : json[key].title, - content: markdown( fs.readFileSync(filename, 'utf8') ) + content: app.markdown ? app.markdown(content) : content }; } catch (e) { throw new Error('Can not read: ' + filename + '.'); diff --git a/lib/parser.js b/lib/parser.js deleted file mode 100644 index 967a6a28..00000000 --- a/lib/parser.js +++ /dev/null @@ -1,457 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var util = require('util'); -var _ = require('lodash'); -var markdown = require('marked'); -var findFiles = require('./utils/find_files'); -var ParameterError = require('./errors/parameter_error'); -var ParserError = require('./errors/parser_error'); - -var app = {}; - -function Parser(_app) { - var self = this; - - // global variables - app = _app; - - // class variables - self.parsers = {}; - self.parsedFileElements = []; - self.parsedFiles = []; - self.countDeprecated = {}; - - // markdown settings - markdown.setOptions(app.options.marked); - - // load parser - var parsers = Object.keys(app.parsers); - parsers.forEach(function(parser) { - var filename = app.parsers[parser]; - app.log.debug('load parser: ' + parser + ', ' + filename); - self.addParser(parser, require(filename)); - }); -} - -/** - * Inherit - */ -util.inherits(Parser, Object); - -/** - * Exports - */ -module.exports = Parser; - -/** - * Add a Parser - */ -Parser.prototype.addParser = function(name, parser) { - this.parsers[name] = parser; -}; - -/** - * Parse files in specified folder - * - * @param {Object} options The options used to parse and filder the files. - * @param {Object[]} parsedFiles List of parsed files. - * @param {String[]} parsedFilenames List of parsed files, with full path. - */ -Parser.prototype.parseFiles = function(options, parsedFiles, parsedFilenames) { - var self = this; - - findFiles.setPath(options.src); - findFiles.setExcludeFilters(options.excludeFilters); - findFiles.setIncludeFilters(options.includeFilters); - var files = findFiles.search(); - - // Parser - for (var i = 0; i < files.length; i += 1) { - var filename = options.src + files[i]; - var parsedFile = self.parseFile(filename); - if (parsedFile) { - app.log.info('parse file: ' + filename); - parsedFiles.push(parsedFile); - parsedFilenames.push(filename); - } - } -}; - -/** - * Execute Fileparsing - */ -Parser.prototype.parseFile = function(filename) { - var self = this; - - app.log.debug('inspect file: ' + filename); - - self.filename = filename; - self.extension = path.extname(filename).toLowerCase(); - self.src = fs.readFileSync(filename, 'utf8').toString(); - app.log.debug('size: ' + self.src.length); - - // unify line-breaks - self.src = self.src.replace(/\r\n/g, '\n'); - - self.blocks = []; - self.indexApiBlocks = []; - - // determine blocks - self.blocks = self._findBlocks(); - if (self.blocks.length === 0) - return; - - app.log.debug('count blocks: ' + self.blocks.length); - - // determine elements in blocks - self.elements = self.blocks.map(function(block, i) { - var elements = self._findElements(block); - app.log.debug('count elements in block ' + i + ': ' + elements.length); - return elements; - }); - if (self.elements.length === 0) - return; - - // determine list of blocks with API elements - self.indexApiBlocks = self._findBlockWithApiGetIndex(self.elements); - if (self.indexApiBlocks.length === 0) - return; - - return self._parseBlockElements(self.indexApiBlocks, self.elements); -}; - -/** - * Parse API Elements with Plugins - * - * @param indexApiBlocks - * @param detectedElements - * @returns {Array} - */ -Parser.prototype._parseBlockElements = function(indexApiBlocks, detectedElements) { - var self = this; - var parsedBlocks = []; - - for (var i = 0; i < indexApiBlocks.length; i += 1) { - var blockIndex = indexApiBlocks[i]; - var elements = detectedElements[blockIndex]; - var blockData = { - global: {}, - local : {} - }; - var countAllowedMultiple = 0; - - for (var j = 0; j < elements.length; j += 1) { - var element = elements[j]; - var elementParser = self.parsers[element.name]; - - if ( ! elementParser) { - app.log.warning('parser plugin \'' + element.name + '\' not found.'); - break; - } - - app.log.debug('found @' + element.sourceName + ', in block: ' + i); - - // Deprecation hint - if (elementParser.deprecated) { - self.countDeprecated[element.sourceName] = self.countDeprecated[element.sourceName] ? self.countDeprecated[element.sourceName] + 1 : 1; - // show deprecated message only 1 time, if verbose is set, show it every time - if (app.options.verbose || self.countDeprecated[element.sourceName] === 1) - if (elementParser.alternative) - app.log.warning('@' + element.sourceName + ' is deprecated, please use ' + elementParser.alternative); - else - app.log.warning('@' + element.sourceName + ' is deprecated'); - } - - var values; - var preventGlobal; - var allowMultiple; - var pathTo; - var attachMethod; - try { - // parse element and retrieve values - values = elementParser.parse(element.content, element.source); - - // HINT: pathTo MUST be read after elementParser.parse, because of dynamic paths - // Add all other options after parse too, in case of a custom plugin need to modify params. - - // check if it is allowed to add to global namespace - preventGlobal = elementParser.preventGlobal === true; - - // allow multiple inserts into pathTo - allowMultiple = elementParser.allowMultiple === true; - - - // path to an array, where the values should be attached - pathTo = ''; - if (elementParser.path) { - if (typeof elementParser.path === 'string') - pathTo = elementParser.path; - else - pathTo = elementParser.path(); // for dynamic paths - } - - if ( ! pathTo) - throw new ParserError('pathTo is not defined in the parser file.', '', '', element.sourceName); - - // method how the values should be attached (insert or push) - attachMethod = elementParser.method || 'push'; - - if (attachMethod !== 'insert' && attachMethod !== 'push') - throw new ParserError('Only push or insert are allowed parser method values.', '', '', element.sourceName); - - // Markdown - // TODO: put this into converters - if ( values && - app.options.marked.gfm && - elementParser.markdownFields && - elementParser.markdownFields.length > 0 - ) { - for (var markdownIndex = 0; markdownIndex < elementParser.markdownFields.length; markdownIndex += 1) { - var markdownField = elementParser.markdownFields[markdownIndex]; - if (values[markdownField]) { - values[markdownField] = markdown(values[markdownField]); - // remove line breaks - values[markdownField] = values[markdownField].replace(/(\r\n|\n|\r)/g, ' '); - } - } - } - } catch(e) { - if (e instanceof ParameterError) { - var extra = []; - if (e.definition) - extra.push({ 'Definition': e.definition }); - if (e.example) - extra.push({ 'Example': e.example }); - throw new ParserError(e.message, - self.filename, (blockIndex + 1), element.sourceName, element.source, extra); - } - throw new ParserError('Undefined error.', - self.filename, (blockIndex + 1), element.sourceName, element.source); - } - - if ( ! values) - throw new ParserError('Empty parser result.', - self.filename, (blockIndex + 1), element.sourceName, element.source); - - if (preventGlobal) { - // Check if count global namespace entries > count allowed - // (e.g. @successTitle is global, but should co-exist with @apiErrorStructure) - if (Object.keys(blockData.global).length > countAllowedMultiple) - throw new ParserError('Only one definition or usage is allowed in the same block.', - self.filename, (blockIndex + 1), element.sourceName, element.source); - } - - // only one global allowed per block - if (pathTo === 'global' || pathTo.substr(0, 7) === 'global.') { - if (allowMultiple) { - countAllowedMultiple += 1; - } else { - if (Object.keys(blockData.global).length > 0) - throw new ParserError('Only one definition is allowed in the same block.', - self.filename, (blockIndex + 1), element.sourceName, element.source); - - if (preventGlobal === true) - throw new ParserError('Only one definition or usage is allowed in the same block.', - self.filename, (blockIndex + 1), element.sourceName, element.source); - } - } - - if ( ! blockData[pathTo]) - self._createObjectPath(blockData, pathTo, attachMethod); - - var blockDataPath = self._pathToObject(pathTo, blockData); - - // insert Fieldvalues in Path-Array - if (attachMethod === 'push') - blockDataPath.push(values); - else - _.extend(blockDataPath, values); - - // insert Fieldvalues in Mainpath - if (elementParser.extendRoot === true) - _.extend(blockData, values); - - blockData.index = blockIndex + 1; - } - parsedBlocks.push(blockData); - } - - return parsedBlocks; -}; - -/** - * Create a not existing Path in an Object - * - * @param src - * @param path - * @param {String} attachMethod Create last element as object or array: 'insert', 'push' - * @returns {Object} - */ -Parser.prototype._createObjectPath = function(src, path, attachMethod) { - if ( ! path) - return src; - var pathParts = path.split('.'); - var current = src; - for (var i = 0; i < pathParts.length; i += 1) { - var part = pathParts[i]; - if ( ! current[part]) { - if (i === (pathParts.length - 1) && attachMethod === 'push' ) - current[part] = []; - else - current[part] = {}; - } - current = current[part]; - } - return current; -}; - - -/** - * Return Path to Object - */ -Parser.prototype._pathToObject = function(path, src) { - if ( ! path) - return src; - var pathParts = path.split('.'); - var current = src; - for (var i = 0; i < pathParts.length; i += 1) { - var part = pathParts[i]; - current = current[part]; - } - return current; -}; - -/** - * Determine Blocks - */ -Parser.prototype._findBlocks = function() { - var self = this; - var blocks = []; - var src = self.src; - - // Replace Linebreak with Unicode - src = src.replace(/\n/g, '\uffff'); - - var regexs = { - '.coffee': { - // find document blocks between '###' and '###' - // docBlocksRegExp: /###\uffff?(.+?)###/g, - docBlocksRegExp: /###\uffff?(.+?)\uffff(?:\s*)?###/g, - // remove not needed tabs at the beginning - inlineRegExp: /^(\t*)?/gm - }, - '.erl': { - // Find document blocks between '%{' and '%}' - // docBlocksRegExp: /\%*\{\uffff?(.+?)\%+\}/g, - docBlocksRegExp: /\%*\{\uffff?(.+?)\uffff(?:\s*)?\%+\}/g, - // remove not needed ' % ' and tabs at the beginning - // HINT: Not sure if erlang developer use the %, but i think it should be no problem - inlineRegExp: /^(\s*)?(\%*)[ ]?/gm - }, - '.py': { - // find document blocks between """ and """ - // docBlocksRegExp: /\"\"\"\uffff?(.+?)\"\"\"/g, - docBlocksRegExp: /\"\"\"\uffff?(.+?)\uffff(?:\s*)?\"\"\"/g, - // remove not needed tabs at the beginning - inlineRegExp: /^(\t*)?/gm - }, - '.rb': { - // find document blocks between '=begin' and '=end' - // docBlocksRegExp: /\=begin\uffff?(.+?)\=end/g, - docBlocksRegExp: /\=begin\uffff?(.+?)\uffff(?:\s*)?\=end/g, - // remove not needed tabs at the beginning - inlineRegExp: /^(\t*)?/gm - }, - '.pm': { - // find document blocks between '#**' and '#*' - // or between '=pod' and '=cut' - // docBlocksRegExp: /#\*\*\uffff?(.+?)#\*|=pod\uffff?(.+?)=cut/g, - docBlocksRegExp: /#\*\*\uffff?(.+?)\uffff(?:\s*)?#\*|=pod\uffff?(.+?)\uffff(?:\s*)?=cut/g, - // remove not needed ' # ' and tabs at the beginning - inlineRegExp: /^(\s*)?(#)[ ]?/gm - }, - 'default': { - // find document blocks between '#**' and '#*' - // docBlocksRegExp: /\/\*\*\uffff?(.+?)\*\//g, - docBlocksRegExp: /\/\*\*\uffff?(.+?)\uffff(?:\s*)?\*\//g, - // remove not needed ' * ' and tabs at the beginning - inlineRegExp: /^(\s*)?(\*)[ ]?/gm - } - }; - var regexForFile = regexs[self.extension] || regexs['default']; - var matches = regexForFile.docBlocksRegExp.exec(src); - while (matches) { - var block = matches[2] || matches[1]; - - // Reverse Unicode Linebreaks - block = block.replace(/\uffff/g, '\n'); - - block = block.replace(regexForFile.inlineRegExp, ''); - blocks.push(block); - - // Find next - matches = regexForFile.docBlocksRegExp.exec(src); - } - return blocks; -}; - -/** - * Return block indexes with active API-elements - * - * An @apiIgnore ignores the block. - * Other, non @api elements, will be ignored. - */ -Parser.prototype._findBlockWithApiGetIndex = function(blocks) { - var foundIndexes = []; - for (var i = 0; i < blocks.length; i += 1) { - var found = false; - for (var j = 0; j < blocks[i].length; j += 1) { - if (blocks[i][j].name.substr(0, 9) === 'apiignore') { - app.log.debug('apiIgnore found in block: ' + i); - found = false; - break; - } - - if (blocks[i][j].name.substr(0, 3) === 'api') - found = true; - } - if (found) { - foundIndexes.push(i); - app.log.debug('api found in block: ' + i); - } - } - return foundIndexes; -}; - -/** - * Get Elements of Blocks - */ -Parser.prototype._findElements = function(block) { - var self = this; - var elements = []; - - // Replace Linebreak with Unicode - block = block.replace(/\n/g, '\uffff'); - - // Elements start with @ - var elementsRegExp = /(@(\w*)\s?(.+?)(?=\uffff[\s\*]*@|$))/gm; - var matches = elementsRegExp.exec(block); - while (matches) { - var element = { - source : matches[1], - name : matches[2].toLowerCase(), - sourceName: matches[2], - content : matches[3] - }; - - // reverse Unicode Linebreaks - element.content = element.content.replace(/\uffff/g, '\n'); - element.source = element.source.replace(/\uffff/g, '\n'); - - elements.push(element); - - // next Match - matches = elementsRegExp.exec(block); - } - return elements; -}; diff --git a/lib/parsers/api.js b/lib/parsers/api.js deleted file mode 100644 index 737f9942..00000000 --- a/lib/parsers/api.js +++ /dev/null @@ -1,27 +0,0 @@ -function parse(content) { - // trim - content = content.replace(/^\s*|\s*$/g, ''); - - // Search: type, url and title - // Example: {get} /user/:id Get User by ID. - var parseRegExp = /^(?:(?:\{(.+?)\})?\s*)?(.+?)(?:\s+(.+?))?$/g; - var matches = parseRegExp.exec(content); - - if ( ! matches) - return null; - - return { - type : matches[1], - url : matches[2], - title: matches[3] || '' - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local', - method: 'insert' -}; diff --git a/lib/parsers/api_define.js b/lib/parsers/api_define.js deleted file mode 100644 index 7846f868..00000000 --- a/lib/parsers/api_define.js +++ /dev/null @@ -1,55 +0,0 @@ -var ParameterError = require('../errors/parameter_error'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiDefine', - usage : '@apiDefine name', - example: '@apiDefine MyValidName' - } -}; - -function parse(content, source, messages) { - messages = messages || _messages; - - // trim - content = content.replace(/^\s*|\s*$/g, ''); - - var parseRegExp = /^(\w*)(.*?)(?:\s+|$)(.*)$/gm; - var matches = parseRegExp.exec(content); - - if ( ! matches) - return null; - - if (matches[0] === '') - throw new ParameterError('No arguments found.', - messages.common.element, messages.common.usage, messages.common.example); - - if (matches[2] !== '') - throw new ParameterError('Name must contain only alphanumeric characters.', - messages.common.element, messages.common.usage, messages.common.example); - - var name = matches[1]; - var title = matches[3]; - var description = ''; - - while (matches = parseRegExp.exec(content)) { - description += matches[0] + '\n'; - } - - return { - name : name, - title : title, - description: description - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.define', - method : 'insert', - markdownFields: [ 'description' ] -}; diff --git a/lib/parsers/api_define_error_structure.js b/lib/parsers/api_define_error_structure.js deleted file mode 100644 index 59ed053d..00000000 --- a/lib/parsers/api_define_error_structure.js +++ /dev/null @@ -1,27 +0,0 @@ -// Same as @apiDefine -var apiParser = require('./api_define.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiDefineErrorStructure', - usage : '@apiDefineErrorStructure name', - example: '@apiDefineErrorStructure MyValidErrorName' - } -}; - -function parse(content, source) { - return apiParser.parse(content, source, _messages); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.defineErrorStructure', - method : apiParser.method, - markdownFields: [ 'description' ], - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_define_header_structure.js b/lib/parsers/api_define_header_structure.js deleted file mode 100644 index 7a65466d..00000000 --- a/lib/parsers/api_define_header_structure.js +++ /dev/null @@ -1,27 +0,0 @@ -// Same as @apiDefine -var apiParser = require('./api_define.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiDefineHeaderStructure', - usage : '@apiDefineHeaderStructure name', - example: '@apiDefineHeaderStructure MyValidHeaderName' - } -}; - -function parse(content, source) { - return apiParser.parse(content, source, _messages); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.defineHeaderStructure', - method : apiParser.method, - markdownFields: [ 'description' ], - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_define_permission.js b/lib/parsers/api_define_permission.js deleted file mode 100644 index b1ca02af..00000000 --- a/lib/parsers/api_define_permission.js +++ /dev/null @@ -1,27 +0,0 @@ -// Same as @apiDefine -var apiParser = require('./api_define.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiDefinePermission', - usage : '@apiDefinePermission name', - example: '@apiDefinePermission MyValidPermissionName' - } -}; - -function parse(content, source) { - return apiParser.parse(content, source, _messages); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.define', - method : apiParser.method, - markdownFields: [ 'description' ], - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_define_structure.js b/lib/parsers/api_define_structure.js deleted file mode 100644 index 9dd07eee..00000000 --- a/lib/parsers/api_define_structure.js +++ /dev/null @@ -1,27 +0,0 @@ -// Same as @apiDefine -var apiParser = require('./api_define.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiDefineStructure', - usage : '@apiDefineStructure name', - example: '@apiDefineStructure MyValidName' - } -}; - -function parse(content, source) { - return apiParser.parse(content, source, _messages); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.defineStructure', - method : apiParser.method, - markdownFields: [ 'description' ], - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_define_success_structure.js b/lib/parsers/api_define_success_structure.js deleted file mode 100644 index ce8eb826..00000000 --- a/lib/parsers/api_define_success_structure.js +++ /dev/null @@ -1,27 +0,0 @@ -// Same as @apiDefine -var apiParser = require('./api_define.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiDefineSuccessStructure', - usage : '@apiDefineSuccessStructure name', - example: '@apiDefineSuccessStructure MyValidSuccessName' - } -}; - -function parse(content, source) { - return apiParser.parse(content, source, _messages); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.defineSuccessStructure', - method : apiParser.method, - markdownFields: [ 'description' ], - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_description.js b/lib/parsers/api_description.js deleted file mode 100644 index e5f91654..00000000 --- a/lib/parsers/api_description.js +++ /dev/null @@ -1,21 +0,0 @@ -function parse(content) { - // trim - var description = content.replace(/^\s*|\s*$/g, ''); - - if (description.length === 0) - return null; - - return { - description: description - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local', - method : 'insert', - markdownFields: [ 'description' ] -}; diff --git a/lib/parsers/api_error.js b/lib/parsers/api_error.js deleted file mode 100644 index cc8a7738..00000000 --- a/lib/parsers/api_error.js +++ /dev/null @@ -1,20 +0,0 @@ -// Same as @apiParam -var apiParser = require('./api_param.js'); - -function parse(content, source) { - return apiParser.parse(content, source, 'Error 4xx'); -} - -function path() { - return 'local.error.fields.' + apiParser.getGroup(); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : path, - method : apiParser.method, - markdownFields: [ 'description' ] -}; diff --git a/lib/parsers/api_error_example.js b/lib/parsers/api_error_example.js deleted file mode 100644 index 75260354..00000000 --- a/lib/parsers/api_error_example.js +++ /dev/null @@ -1,11 +0,0 @@ -// Same as @apiExample -var apiParser = require('./api_example.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.error.examples', - method: apiParser.method -}; diff --git a/lib/parsers/api_error_structure.js b/lib/parsers/api_error_structure.js deleted file mode 100644 index 99dde8a9..00000000 --- a/lib/parsers/api_error_structure.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiUse -var apiParser = require('./api_use.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.errorStructure', - method : apiParser.method, - preventGlobal: true, - deprecated : true, - alternative : '@apiUse' -}; diff --git a/lib/parsers/api_error_title.js b/lib/parsers/api_error_title.js deleted file mode 100644 index a74fda93..00000000 --- a/lib/parsers/api_error_title.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiParamTitle -var apiParser = require('./api_param_title.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'global.errorTitle', - method : apiParser.method, - allowMultiple: true, - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_example.js b/lib/parsers/api_example.js deleted file mode 100644 index 84808229..00000000 --- a/lib/parsers/api_example.js +++ /dev/null @@ -1,42 +0,0 @@ -function parse(content, source) { - // trim - source = source.replace(/^\s*|\s*$/g, ''); - - var title = ''; - var text = ''; - var type; - - // Search for @apiExample "[{type}] title and content - // /^(@\w*)?\s?(?:(?:\{(.+?)\})\s*)?(.*)$/gm; - var parseRegExpFirstLine = /(@\w*)?(?:(?:\s*\{\s*([a-zA-Z0-9\.\/\\\[\]_-]+)\s*\}\s*)?\s*(.*)?)?/; - var parseRegExpFollowing = /(^.*\s?)/gm; - - var matches; - if (matches = parseRegExpFirstLine.exec(source)) { - type = matches[2]; - title = matches[3]; - } - - parseRegExpFollowing.exec(content); // ignore line 1 - while (matches = parseRegExpFollowing.exec(source)) { - text += matches[1]; - } - - if (text.length === 0) - return null; - - return { - title : title, - content: text, - type : type || 'json' - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local.examples', - method: 'push' -}; diff --git a/lib/parsers/api_group.js b/lib/parsers/api_group.js deleted file mode 100644 index 53bbf7e2..00000000 --- a/lib/parsers/api_group.js +++ /dev/null @@ -1,20 +0,0 @@ -function parse(content) { - // trim - var group = content.replace(/^\s*|\s*$/g, ''); - - if (group.length === 0) - return null; - - return { - group: group.replace(/(\s+)/g, '_') - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local', - method: 'insert' -}; diff --git a/lib/parsers/api_group_description.js b/lib/parsers/api_group_description.js deleted file mode 100644 index c9ed6b48..00000000 --- a/lib/parsers/api_group_description.js +++ /dev/null @@ -1,23 +0,0 @@ -function parse(content) { - // trim - var description = content.replace(/^\s*|\s*$/g, ''); - - if (description.length === 0) - return null; - - return { - groupDescription: description - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local', - method : 'insert', - markdownFields: [ 'groupDescription' ], - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_header.js b/lib/parsers/api_header.js deleted file mode 100644 index 52661117..00000000 --- a/lib/parsers/api_header.js +++ /dev/null @@ -1,20 +0,0 @@ -// Same as @apiParam -var apiParser = require('./api_param.js'); - -function parse(content, source) { - return apiParser.parse(content, source, 'Header'); -} - -function path() { - return 'local.header.fields.' + apiParser.getGroup(); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : path, - method : apiParser.method, - markdownFields: [ 'description' ] -}; diff --git a/lib/parsers/api_header_example.js b/lib/parsers/api_header_example.js deleted file mode 100644 index 912ae4d2..00000000 --- a/lib/parsers/api_header_example.js +++ /dev/null @@ -1,11 +0,0 @@ -// Same as @apiExample -var apiParser = require('./api_example.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.header.examples', - method: apiParser.method -}; diff --git a/lib/parsers/api_header_structure.js b/lib/parsers/api_header_structure.js deleted file mode 100644 index 27c79391..00000000 --- a/lib/parsers/api_header_structure.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiUse -var apiParser = require('./api_use.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.headerStructure', - method : apiParser.method, - preventGlobal: true, - deprecated : true, - alternative : '@apiUse' -}; diff --git a/lib/parsers/api_header_title.js b/lib/parsers/api_header_title.js deleted file mode 100644 index c0184092..00000000 --- a/lib/parsers/api_header_title.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiParamTitle -var apiParser = require('./api_param_title.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'global.headerTitle', - method : apiParser.method, - allowMultiple: true, - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_name.js b/lib/parsers/api_name.js deleted file mode 100644 index cde3b46e..00000000 --- a/lib/parsers/api_name.js +++ /dev/null @@ -1,20 +0,0 @@ -function parse(content) { - // trim - var name = content.replace(/^\s*|\s*$/g, ''); - - if(name.length === 0) - return null; - - return { - name: name.replace(/(\s+)/g, '_') - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local', - method: 'insert' -}; diff --git a/lib/parsers/api_param.js b/lib/parsers/api_param.js deleted file mode 100644 index 5853c8da..00000000 --- a/lib/parsers/api_param.js +++ /dev/null @@ -1,134 +0,0 @@ -var group = ''; - -// Search: group, type, optional, fieldname, defaultValue, size, description -// Example: {String{1..4}} [user.name='John Doe'] Users fullname. -// -// Naming convention: -// b -> begin -// e -> end -// name -> the field value -// oName -> wrapper for optional field -// wName -> wrapper for field -var regExp = { - b: '^', // start - oGroup: { // optional group: (404) - b: '\\s*(?:\\(\\s*', // starting with '(', optional surrounding spaces - group: '(.+?)', // 1 - e: '\\s*\\)\\s*)?' // ending with ')', optional surrounding spaces - }, - oType: { // optional type: {string} - b: '\\s*(?:\\{\\s*', // starting with '{', optional surrounding spaces - type: '([a-zA-Z0-9\\.\\/\\\\\\[\\]_-]+)', // 2 - oSize: { // optional size within type: {string{1..4}} - b: '\\s*(?:\\{\\s*', // starting with '{', optional surrounding spaces - size: '(.+?)', // 3 - e: '\\s*\\}\\s*)?' // ending with '}', optional surrounding spaces - }, - oAllowedValues: { // optional allowed values within type: {string='abc','def'} - b: '\\s*(?:=\\s*', // starting with '=', optional surrounding spaces - possibleValues: '(.+?)', // 4 - e: '(?=\\s*\\}\\s*))?' // ending with '}', optional surrounding spaces - }, - e: '\\s*\\}\\s*)?' // ending with '}', optional surrounding spaces - }, - wName: { - b: '(\\[?\\s*', // 5 optional optional-marker - name: '([a-zA-Z0-9\\.\\/\\\\_-]+)', // 6 - oDefaultValue: { // optional defaultValue - b: '(?:\\s*=\\s*(?:', // starting with '=', optional surrounding spaces - withDoubleQuote: '"([^"]*)"', // 7 - withQuote: '|\'([^\']*)\'', // 8 - withoutQuote: '|(.*?)(?:\\s|\\]|$)', // 9 - e: '))?' - }, - e: '\\s*\\]?\\s*)' - }, - description: '(.*)?', // 10 - e: '$|@' -}; - -function _objectValuesToString(obj) { - var str = ''; - for (var el in obj) { - if (typeof obj[el] === 'string') - str += obj[el]; - else - str += _objectValuesToString(obj[el]); - } - return str; -} - -var parseRegExp = new RegExp(_objectValuesToString(regExp)); - -var allowedValuesWithDoubleQuoteRegExp = new RegExp(/\"[^\"]*[^\"]\"/g); -var allowedValuesWithQuoteRegExp = new RegExp(/\'[^\']*[^\']\'/g); -var allowedValuesRegExp = new RegExp(/[^,\s]+/g); - -function parse(content, source, defaultGroup) { - // trim - content = content.replace(/^\s*|\s*$/g, ''); - - // replace Linebreak with Unicode - content = content.replace(/\n/g, '\uffff'); - - var matches = parseRegExp.exec(content); - - if ( ! matches) - return null; - - var allowedValues = matches[4]; - if (allowedValues) { - var regExp; - if (allowedValues.charAt(0) === '"') - regExp = allowedValuesWithDoubleQuoteRegExp; - else if (allowedValues.charAt(0) === '\'') - regExp = allowedValuesWithQuoteRegExp; - else - regExp = allowedValuesRegExp; - - var allowedValuesMatch; - var list = []; - - while (allowedValuesMatch = regExp.exec(allowedValues)) { - list.push(allowedValuesMatch[0]); - } - allowedValues = list; - } - - // Replace Unicode Linebreaks in description - if (matches[10]) - matches[10] = matches[10].replace(/\uffff/g, '\n'); - - // Set global group variable - group = matches[1] || defaultGroup || 'Parameter'; - - return { - group : group, - type : matches[2], - size : matches[3], - allowedValues: allowedValues, - optional : (matches[5] && matches[5][0] === '[') ? true : false, - field : matches[6], - defaultValue : matches[7] || matches[8] || matches[9], - description : matches[10] || '' - }; -} - -function path() { - return 'local.parameter.fields.' + getGroup(); -} - -function getGroup() { - return group; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : path, - method : 'push', - getGroup : getGroup, - markdownFields: [ 'description' ] -}; diff --git a/lib/parsers/api_param_example.js b/lib/parsers/api_param_example.js deleted file mode 100644 index 5773e59f..00000000 --- a/lib/parsers/api_param_example.js +++ /dev/null @@ -1,11 +0,0 @@ -// Same as @apiExample -var apiParser = require('./api_example.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.parameter.examples', - method: apiParser.method -}; diff --git a/lib/parsers/api_param_title.js b/lib/parsers/api_param_title.js deleted file mode 100644 index 8f9b355b..00000000 --- a/lib/parsers/api_param_title.js +++ /dev/null @@ -1,31 +0,0 @@ -function parse(content, source) { - // trim - content = content.replace(/^\s*|\s*$/g, ''); - - // replace Linebreak with Unicode - content = content.replace(/\n/g, '\uffff'); - - // search: group, title - var parseRegExp = /^(?:\((.+?)\))\s*(.*)(^@|$)/g; - var matches = parseRegExp.exec(content); - - if ( ! matches) - return null; - - return { - group: matches[1], - title: matches[2] - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'global.paramTitle', - method : 'push', - allowMultiple: true, - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_permission.js b/lib/parsers/api_permission.js deleted file mode 100644 index 3b1ffc62..00000000 --- a/lib/parsers/api_permission.js +++ /dev/null @@ -1,12 +0,0 @@ -// Same as @apiUse -var apiParser = require('./api_use.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.permission', - method : apiParser.method, - preventGlobal: true -}; diff --git a/lib/parsers/api_sample_request.js b/lib/parsers/api_sample_request.js deleted file mode 100644 index 626148ba..00000000 --- a/lib/parsers/api_sample_request.js +++ /dev/null @@ -1,20 +0,0 @@ -function parse(content, source) { - // trim - var url = content.replace(/^\s*|\s*$/g, ''); - - if(url.length === 0) - return null; - - return { - url: url - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local.sampleRequest', - method: 'push' -}; diff --git a/lib/parsers/api_structure.js b/lib/parsers/api_structure.js deleted file mode 100644 index b68b4854..00000000 --- a/lib/parsers/api_structure.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiUse -var apiParser = require('./api_use.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.structure', - method : apiParser.method, - preventGlobal: true, - deprecated : true, - alternative : '@apiUse' -}; diff --git a/lib/parsers/api_success.js b/lib/parsers/api_success.js deleted file mode 100644 index c0daf31d..00000000 --- a/lib/parsers/api_success.js +++ /dev/null @@ -1,20 +0,0 @@ -// Same as @apiParam -var apiParser = require('./api_param.js'); - -function parse(content, source) { - return apiParser.parse(content, source, 'Success 200'); -} - -function path() { - return 'local.success.fields.' + apiParser.getGroup(); -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : path, - method : apiParser.method, - markdownFields: [ 'description' ] -}; diff --git a/lib/parsers/api_success_example.js b/lib/parsers/api_success_example.js deleted file mode 100644 index 2904840b..00000000 --- a/lib/parsers/api_success_example.js +++ /dev/null @@ -1,11 +0,0 @@ -// Same as @apiExample -var apiParser = require('./api_example.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.success.examples', - method: apiParser.method -}; diff --git a/lib/parsers/api_success_structure.js b/lib/parsers/api_success_structure.js deleted file mode 100644 index 8341c996..00000000 --- a/lib/parsers/api_success_structure.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiUse -var apiParser = require('./api_use.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'local.successStructure', - method : apiParser.method, - preventGlobal: true, - deprecated : true, - alternative : '@apiUse' -}; diff --git a/lib/parsers/api_success_title.js b/lib/parsers/api_success_title.js deleted file mode 100644 index 690caee6..00000000 --- a/lib/parsers/api_success_title.js +++ /dev/null @@ -1,14 +0,0 @@ -// Same as @apiParamTitle -var apiParser = require('./api_param_title.js'); - -/** - * Exports - */ -module.exports = { - parse : apiParser.parse, - path : 'global.successTitle', - method : apiParser.method, - allowMultiple: true, - deprecated : true, - alternative : '@apiDefine' -}; diff --git a/lib/parsers/api_use.js b/lib/parsers/api_use.js deleted file mode 100644 index ed4d47fc..00000000 --- a/lib/parsers/api_use.js +++ /dev/null @@ -1,21 +0,0 @@ -function parse(content) { - // trim - var name = content.replace(/^\s*|\s*$/g, ''); - - if (name.length === 0) - return null; - - return { - name: name - }; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local.use', - method : 'push', - preventGlobal: true -}; diff --git a/lib/parsers/api_version.js b/lib/parsers/api_version.js deleted file mode 100644 index a19170e2..00000000 --- a/lib/parsers/api_version.js +++ /dev/null @@ -1,32 +0,0 @@ -var semver = require('semver'); -var ParameterError = require('../errors/parameter_error'); - -function parse(content) { - // trim - content = content.replace(/^\s*|\s*$/g, ''); - - if (content.length === 0) - return null; - - if ( ! semver.valid(content)) - throw new ParameterError('Version format not valid.', - 'apiVersion', '@apiVersion major.minor.patch', '@apiDefine 1.2.3'); - - return { - version: content - }; -} - -function pushTo() { - return 'local'; -} - -/** - * Exports - */ -module.exports = { - parse : parse, - path : 'local', - method : 'insert', - extendRoot: true -}; diff --git a/lib/utils/console_logger.js b/lib/utils/console_logger.js deleted file mode 100644 index 6ae295e1..00000000 --- a/lib/utils/console_logger.js +++ /dev/null @@ -1,151 +0,0 @@ -var colors = require('colors'); - -/** - * Console logger - */ -function Logger() { - this.isDebug = false; - this.isSilent = false; - this.isVerbose = true; -} - -/** - * Exports - */ -module.exports = new Logger(); - -/** - * Turn on/off debug log - * - * @param {Boolean} isSilent - */ -Logger.prototype.setDebug = function(isDebug) { - this.isDebug = (isDebug === true) ? true : false; -}; - -/** - * Turn on/off log - * - * @param {Boolean} isSilent - */ -Logger.prototype.setSilent = function(isSilent) { - this.isSilent = (isSilent === true) ? true : false; -}; - -/** - * Turn on/off verbose log - * - * @param {Boolean} isVerbose - */ -Logger.prototype.setVerbose = function(isVerbose) { - this.isVerbose = (isVerbose === true) ? true : false; -}; - -/** - * Output debug message - * - * @param {String} message - */ -Logger.prototype.debug = function(message, extra) { - if ( ! this.isSilent && this.isDebug) { - console.log(colors.cyan('debug: ') + message); - if (extra) - console.log(colors.white(this._getExtra(extra))); - } -}; - -/** - * Output error message - * - * @param {String} message - */ -Logger.prototype.error = function(message, extra) { - if ( ! this.isSilent) { - console.error(colors.red('error: ') + message); - if (extra) - console.error(colors.white(this._getExtra(extra))); - } -}; - -/** - * Output non important info message - * - * @param {String} message - */ -Logger.prototype.info = function(message, extra) { - if (this.isVerbose && ! this.isSilent) { - console.info('info: ' + message); - if (extra) - console.info(colors.white(this._getExtra(extra))); - } -}; - -/** - * Output success message - * - * @param {String} message - */ -Logger.prototype.success = function(message, extra) { - if ( ! this.isSilent) { - console.log(colors.green('success: ') + message); - if (extra) - console.log(colors.white(this._getExtra(extra))); - } -}; - -/** - * Output warning message - * - * @param {String} message - */ -Logger.prototype.warning = function(message, extra) { - if ( ! this.isSilent) { - console.warn(colors.yellow('warning: ') + message); - if (extra) - console.warn(colors.white(this._getExtra(extra))); - } -}; - -/** - * Output warning message - * - * @param {Object[]} extra - */ -Logger.prototype._getExtra = function(extra) { - var result = ''; - - // get longest name for indention - var longestName = extra.map(function(entry) { - return Object.keys(entry)[0]; // get name - }).reduce(function(last, now) { - return (last.length > now.length) ? last : now; - }); - - extra.forEach(function(entry) { - var keys = Object.keys(entry); - var key = keys[0]; - var value = '' + entry[key]; // cast all to string (can be change to display objects / arrays) - var padRight = new Array(longestName.length - key.length + 1).join(' '); - - if (value.indexOf('\n') === -1) - result += indent(key + ': ' + padRight + value) + '\n'; - else - result += indent(key + ':' + '\n' + indent(value, longestName.length + 2)) + '\n'; // + 2 for (": ") - }); - return result; -}; - -/** - * Indent string - * - * @param {String} text - * @param {Integer} length - * @param {Char} char - * @returns {String} - */ -function indent(text, length, char) { - length = length ? length : 9; - char = char ? char : ' '; - var pad = new Array((length + 1)).join(char); - return text.replace(/^(.*)$/gm, pad + '$1'); -} diff --git a/lib/utils/find_files.js b/lib/utils/find_files.js deleted file mode 100644 index aaafeca8..00000000 --- a/lib/utils/find_files.js +++ /dev/null @@ -1,124 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var wrench = require('wrench'); -var os = require('os'); -var FileError = require('../errors/file_error'); - -/** - * Search files recursivly and filter with include / exlude filters - */ -function FindFiles() { - this.path = './'; - this.excludeFilters = []; - this.includeFilters = []; -} - -/** - * Exports - */ -module.exports = new FindFiles(); - -/** - * Set path to source-files - * - * @param {String} path - */ -FindFiles.prototype.setPath = function(path) { - if (path) - this.path = path; -}; - -/** - * Set exclude filters - * - * @param {string[]} excludeFilters - */ -FindFiles.prototype.setExcludeFilters = function(excludeFilters) { - if (excludeFilters) - this.excludeFilters = excludeFilters; -}; - -/** - * Set include filters - * - * @param {string[]} isSilent - */ -FindFiles.prototype.setIncludeFilters = function(includeFilters) { - if (includeFilters) - this.includeFilters = includeFilters; -}; - -/** - * Search files recursivly and filter by include / exlude filters - * - * @returns {String[]} - */ -FindFiles.prototype.search = function() { - var self = this; - var files = []; - try { - // find Files - files = wrench.readdirSyncRecursive(self.path); - - // create RegExp Include Filter List - var regExpIncludeFilters = []; - filters = self.includeFilters; - if (typeof(filters) === 'string') - filters = [ filters ]; - - filters.forEach(function(filter) { - if (filter.length > 0) - regExpIncludeFilters.push( new RegExp(filter) ); - }); - - // RegExp Include Filter - var length = regExpIncludeFilters.length; - files = files.filter(function(filename) { - // Not include Directories like 'dirname.js' - var fullFilename = path.join(self.path, filename); - if (fs.statSync(fullFilename).isDirectory()) - return 0; - - if (os.platform() === 'win32') - filename = filename.replace(/\\/g, '/'); - - // apply every filter - for (var i = 0; i < length; i += 1) { - if(regExpIncludeFilters[i].test(filename)) - return 1; - } - return 0; - }); - - // create RegExp Exclude Filter List - var regExpExcludeFilters = []; - filters = self.excludeFilters; - if (typeof(filters) === 'string') - filters = [ filters ]; - - filters.forEach(function(filter) { - if (filter.length > 0) - regExpExcludeFilters.push( new RegExp(filter) ); - }); // forEach - - // RegExp Exclude Filter - length = regExpExcludeFilters.length; - files = files.filter(function(filename) { - if (os.platform() === 'win32') - filename = filename.replace(/\\/g, '/'); - - // apply every filter - for(var i = 0; i < length; i += 1) { - if(regExpExcludeFilters[i].test(filename)) - return 0; - } - return 1; - }); - } catch (e) { - throw e; - } finally { - if ( ! files || files.length === 0) - throw new FileError('No files found.', self.path); - } - return files; -}; diff --git a/lib/worker.js b/lib/worker.js deleted file mode 100644 index 0d98dfe4..00000000 --- a/lib/worker.js +++ /dev/null @@ -1,98 +0,0 @@ -var util = require('util'); -var _ = require('lodash'); - -var app = {}; - -/** - * Worker - * - * Attaches defined data to parameter which inherit the data. - * It uses 2 functions, preProcess and postProcess (with the result of preProcess). - * - * preProcess Generates a list with [defineName][name][version] = value - * postProcess Attach the preProcess data with the nearest version to the tree. - * - * @param {Object} _app - */ -function Worker(_app) { - var self = this; - - // global variables - app = _app; - - // class variables - this.workers = {}; - - // load worker - var workers = Object.keys(app.workers); - workers.forEach(function(worker) { - var filename = app.workers[worker]; - app.log.debug('load worker: ' + worker + ', ' + filename); - self.addWorker(worker, require(filename)); - }); -} - -/** - * Inherit - */ -util.inherits(Worker, Object); - -/** - * Exports - */ -module.exports = Worker; - -/** - * Add Worker - */ -Worker.prototype.addWorker = function(name, worker) { - this.workers[name] = worker; -}; - -/** - * Execute worker - * - * @todo Add priority system (if needed), if a plugin need an other operation to be done before. - */ -Worker.prototype.process = function(parsedFiles, parsedFilenames, packageInfos) { - // some smaller operation that are not outsourced to extra workers - // TODO: add priority system first and outsource them then - parsedFiles.forEach(function(parsedFile, fileIndex) { - parsedFile.forEach(function(block) { - if (Object.keys(block.global).length === 0 && Object.keys(block.local).length > 0) { - if ( ! block.local.type) - block.local.type = ''; - - if ( ! block.local.url) - block.local.url = ''; - - if ( ! block.local.version) - block.local.version = '0.0.0'; - - if ( ! block.local.filename) - block.local.filename = parsedFilenames[fileIndex]; - - // convert dir delimeter \\ to / - block.local.filename = block.local.filename.replace(/\\/g, '/'); - } - - }); - }); - - // process transformations and assignments for each @api-Parameter - var preProcessResults = {}; - - _.each(this.workers, function(worker, name) { - if (worker.preProcess) { - app.log.info('worker preProcess: ' + name); - var result = worker.preProcess(parsedFiles, parsedFilenames, packageInfos); - _.extend(preProcessResults, result); - } - }); - _.each(this.workers, function(worker, name) { - if (worker.postProcess) { - app.log.info('worker postProcess: ' + name); - worker.postProcess(parsedFiles, parsedFilenames, preProcessResults, packageInfos); - } - }); -}; diff --git a/lib/workers/api_error_structure.js b/lib/workers/api_error_structure.js deleted file mode 100644 index f9170256..00000000 --- a/lib/workers/api_error_structure.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiUse -var apiWorker = require('./api_use.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiErrorStructure', - usage : '@apiErrorStructure group', - example: '@apiDefine MyValidErrorStructureGroup Some title\n@apiErrorStructure MyValidErrorStructureGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineErrorStructure'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineErrorStructure', 'errorStructure', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_error_title.js b/lib/workers/api_error_title.js deleted file mode 100644 index eec1d14a..00000000 --- a/lib/workers/api_error_title.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiParamTitle -var apiWorker = require('./api_param_title.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiError', - usage : '@apiError (group) varname', - example: '@apiDefine MyValidErrorGroup Some title or 40X Error\n@apiError (MyValidErrorGroup) username' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineErrorTitle'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineErrorTitle', 'error', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_group.js b/lib/workers/api_group.js deleted file mode 100644 index 5d059d01..00000000 --- a/lib/workers/api_group.js +++ /dev/null @@ -1,177 +0,0 @@ -var path = require('path'); -var semver = require('semver'); -var WorkerError = require('../errors/worker_error'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiGroup', - usage : '@apiGroup group', - example: '@apiDefine MyValidGroup Some title\n@apiGroup MyValidGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @param {String} target Target path in preProcess-Object (returned result), where the data should be set. - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos, target) { - target = target || 'defineGroup'; - var source = 'define'; // relative path to the tree (global.), from where the data should be fetched. - - var result = {}; - result[target] = {}; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (block.global[source]) { - var name = block.global[source].name; - var version = block.version || '0.0.0'; - - if ( ! result[target][name]) - result[target][name] = {}; - - // fetch from global - result[target][name][version] = block.global[source]; - } - }); - }); - - // remove empty target - if (result[target].length === 0) - delete result[target]; - - return result; -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - * @param {String} source Source path in preProcess-Object - * @param {String} target Relative path to the tree (local.), where the data should be modified. - * @param {String} messages - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, target, messages) { - source = source || 'defineGroup'; - target = target || 'group'; - messages = messages || _messages; - - // set group name if empty - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - // Ignore global groups, or non existing global group names (that will be generated with this func) - // could overwrite local names on a later starting worker process from e.g. @apiUse - if (Object.keys(block.global).length === 0) { - var group = block.local[target]; - if ( ! group) { - // TODO: Add a warning - - // if no group is set, the filename will be the group-name - group = path.resolve(filenames[parsedFileIndex]); - } - - // replace special chars - group = group.replace(/[^\w]/g, '_'); - - block.local[target] = group; - } - }); - }); - - // add group description and title - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - if ( ! block.local[target]) - return; - - var name = block.local[target]; - var version = block.version || '0.0.0'; - var matchedData = {}; - - if ( ! preProcess[source] || ! preProcess[source][name]) { -// TODO: Enable in the next version -// At the moment the (groupname) is optional and must not be defined. -/* - var extra = [ - { 'Groupname': name } - ]; - throw new WorkerError('Referenced groupname does not exist / it is not defined with @apiDefine.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); -*/ -// TODO: Remove in the next version -matchedData.title = block.local[target]; -matchedData.description = undefined; - - } - -// TODO: Remove in the next version -else { - - if (preProcess[source][name][version]) { - // found the version - matchedData = preProcess[source][name][version]; - } else { - // find nearest matching version - var foundIndex = -1; - var lastVersion = '0.0.0'; - - var versionKeys = Object.keys(preProcess[source][name]); - versionKeys.forEach(function(currentVersion, versionIndex) { - if (semver.gte(version, currentVersion) && semver.gte(currentVersion, lastVersion)) { - lastVersion = currentVersion; - foundIndex = versionIndex; - } - }); - - if (foundIndex === -1) { - var extra = [ - { 'Groupname': name }, - { 'Version': version }, - { 'Defined versions': versionKeys }, - ]; - throw new WorkerError('Referenced definition has no matching or a higher version. ' + - 'Check version number in referenced define block.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); - } - - var versionName = versionKeys[foundIndex]; - matchedData = preProcess[source][name][versionName]; - } - -// TODO: Remove in the next version -} - - block.local['groupTitle'] = matchedData.title; - - if (matchedData.description) - block.local['groupDescription'] = matchedData.description; // keep original block.local - }); - }); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_header_structure.js b/lib/workers/api_header_structure.js deleted file mode 100644 index 1b280b7f..00000000 --- a/lib/workers/api_header_structure.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiUse -var apiWorker = require('./api_use.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiHeaderStructure', - usage : '@apiHeaderStructure group', - example: '@apiDefine MyValidHeaderStructureGroup Some title\n@apiHeaderStructure MyValidHeaderStructureGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineHeaderStructure'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineHeaderStructure', 'headerStructure', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_header_title.js b/lib/workers/api_header_title.js deleted file mode 100644 index 5bb02020..00000000 --- a/lib/workers/api_header_title.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiParamTitle -var apiWorker = require('./api_param_title.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiHeader', - usage : '@apiHeader (group) varname', - example: '@apiDefine MyValidHeaderGroup Some title\n@apiHeader (MyValidHeaderGroup) Content-Type' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineHeaderTitle'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineHeaderTitle', 'header', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_name.js b/lib/workers/api_name.js deleted file mode 100644 index 682ca481..00000000 --- a/lib/workers/api_name.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * PostProcess - * - * Priority: process after use and api - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - var target = 'name'; - - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - // Ignore global name, or non existing global names (that will be generated with this func) - // could overwrite local names on a later starting worker process from e.g. @apiUse - if (Object.keys(block.global).length === 0) { - var name = block.local[target]; - if ( ! name) { - // TODO: Add a warning - - // HINT: document that name SHOULD always be used - // if no name is set, the name will be generated from type and url. - var type = block.local.type; - var url = block.local.url; - name = type.charAt(0).toUpperCase() + type.slice(1).toLowerCase(); - - var matches = url.match(/[\w]+/g); - if (matches) { - for (var i = 0; i < matches.length; i+= 1) { - var part = matches[i]; - name += part.charAt(0).toUpperCase() + part.slice(1).toLowerCase(); - } - } - } - - // replace special chars - name = name.replace(/[^\w]/g, '_'); - - block.local[target] = name; - } - }); - }); -} - -/** - * Exports - */ -module.exports = { - postProcess: postProcess -}; diff --git a/lib/workers/api_param_title.js b/lib/workers/api_param_title.js deleted file mode 100644 index 668644ba..00000000 --- a/lib/workers/api_param_title.js +++ /dev/null @@ -1,165 +0,0 @@ -var semver = require('semver'); -var WorkerError = require('../errors/worker_error'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiParam', - usage : '@apiParam (group) varname', - example: '@apiDefine MyValidParamGroup Some title\n@apiParam (MyValidParamGroup) username' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @param {String} target Target path in preProcess-Object (returned result), where the data should be set. - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos, target) { - target = target || 'defineParamTitle'; - var source = 'define'; // relative path to the tree (global.), from where the data should be fetched. - - var result = {}; - result[target] = {}; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (block.global[source]) { - var name = block.global[source].name; - var version = block.version || '0.0.0'; - - if ( ! result[target][name]) - result[target][name] = {}; - - // fetch from global - result[target][name][version] = block.global[source]; - } - }); - }); - - // remove empty target - if (result[target].length === 0) - delete result[target]; - - return result; -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - * @param {String} source Source path in preProcess-Object - * @param {String} target Relative path to the tree (local.), where the data should be modified. - * @param {String} messages - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, target, messages) { - source = source || 'defineParamTitle'; - target = target || 'parameter'; - messages = messages || _messages; - - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - if ( ! block.local[target] || ! block.local[target].fields) - return; - - var newFields = {}; - var fields = block.local[target].fields; - Object.keys(fields).forEach(function(fieldGroup) { - var params = block.local[target].fields[fieldGroup]; - - params.forEach(function(definition) { - var name = definition.group; - var version = block.version || '0.0.0'; - var matchedData = {}; - - if ( ! preProcess[source] || ! preProcess[source][name]) { -// TODO: Enable in the next version -// At the moment the (groupname) is optional and must not be defined. -/* - var extra = [ - { 'Groupname': name } - ]; - throw new WorkerError('Referenced groupname does not exist / it is not defined with @apiDefine.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); -*/ -// TODO: Remove in the next version -matchedData.name = name; -matchedData.title = name; - - } - -// TODO: Remove in the next version -else { - - if (preProcess[source][name][version]) { - // found the version - matchedData = preProcess[source][name][version]; - } else { - // find nearest matching version - var foundIndex = -1; - var lastVersion = '0.0.0'; - - var versionKeys = Object.keys(preProcess[source][name]); - versionKeys.forEach(function(currentVersion, versionIndex) { - if (semver.gte(version, currentVersion) && semver.gte(currentVersion, lastVersion)) { - lastVersion = currentVersion; - foundIndex = versionIndex; - } - }); - - if (foundIndex === -1) { - var extra = [ - { 'Groupname': name }, - { 'Version': version }, - { 'Defined versions': versionKeys }, - ]; - throw new WorkerError('Referenced definition has no matching or a higher version. ' + - 'Check version number in referenced define block.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); - } - - var versionName = versionKeys[foundIndex]; - matchedData = preProcess[source][name][versionName]; - } - -// TODO: Remove in the next version -} - - if ( ! newFields[matchedData.title]) - newFields[matchedData.title] = []; - - newFields[matchedData.title].push(definition); - }); - }); - - // replace fields with new field header - // TODO: reduce complexity and remove group - block.local[target].fields = newFields; - }); - }); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_permission.js b/lib/workers/api_permission.js deleted file mode 100644 index edcd5937..00000000 --- a/lib/workers/api_permission.js +++ /dev/null @@ -1,157 +0,0 @@ -var semver = require('semver'); -var WorkerError = require('../errors/worker_error'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiPermission', - usage : '@apiPermission group', - example: '@apiDefine MyValidPermissionGroup Some title\n@apiPermission MyValidPermissionGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @param {String} target Target path in preProcess-Object (returned result), where the data should be set. - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos, target) { - target = target || 'definePermission'; - var source = 'define'; // relative path to the tree (global.), from where the data should be fetched. - - var result = {}; - result[target] = {}; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (block.global[source]) { - var name = block.global[source].name; - var version = block.version || '0.0.0'; - - if ( ! result[target][name]) - result[target][name] = {}; - - // fetch from local - result[target][name][version] = block.global[source]; - } - }); - }); - - if (result[target].length === 0) - delete result[target]; - - return result; -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - * @param {String} source Source path in preProcess-Object - * @param {String} target Relative path to the tree (local.), where the data should be modified. - * @param {String} messages - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, target, messages) { - source = source || 'definePermission'; - target = target || 'permission'; - messages = messages || _messages; - - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - if ( ! block.local[target]) - return; - - var newPermissions = []; - block.local[target].forEach(function(definition) { - var name = definition.name; - var version = block.version || '0.0.0'; - var matchedData = {}; - - if ( ! preProcess[source] || ! preProcess[source][name]) { -// TODO: Enable in the next version -// At the moment the (groupname) is optional and must not be defined. -/* - var extra = [ - { 'Groupname': name } - ]; - throw new WorkerError('Referenced groupname does not exist / it is not defined with @apiDefine.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); -*/ -// TODO: Remove in the next version -matchedData.name = name; -matchedData.title = definition.title; -matchedData.description = definition.description; - - } - -// TODO: Remove in the next version -else { - - if (preProcess[source][name][version]) { - // found the version - matchedData = preProcess[source][name][version]; - } else { - // find nearest matching version - var foundIndex = -1; - var lastVersion = '0.0.0'; - - var versionKeys = Object.keys(preProcess[source][name]); - versionKeys.forEach(function(currentVersion, versionIndex) { - if (semver.gte(version, currentVersion) && semver.gte(currentVersion, lastVersion)) { - lastVersion = currentVersion; - foundIndex = versionIndex; - } - }); - - if (foundIndex === -1) { - var extra = [ - { 'Groupname': name }, - { 'Version': version }, - { 'Defined versions': versionKeys }, - ]; - throw new WorkerError('Referenced definition has no matching or a higher version. ' + - 'Check version number in referenced define block.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); - } - - var versionName = versionKeys[foundIndex]; - matchedData = preProcess[source][name][versionName]; - } - -// TODO: Remove in the next version -} - - newPermissions.push(matchedData); - }); - - // replace permissions with new permissions - // TODO: reduce complexity and remove group - block.local[target] = newPermissions; - }); - }); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_sample_request.js b/lib/workers/api_sample_request.js deleted file mode 100644 index faa802c4..00000000 --- a/lib/workers/api_sample_request.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - var targetName = 'sampleRequest'; - - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - if (block.local[targetName]) { - var newBlock = []; - block.local[targetName].forEach(function(entry) { - if (entry.url !== 'off') { - // Check if is an internal url - if (packageInfos.sampleUrl && entry.url.length >= 4 && entry.url.substr(0, 4).toLowerCase() !== 'http') { - // Prepend sampleUrl - entry.url = packageInfos.sampleUrl + entry.url; - } - newBlock.push(entry); - } - }); // forEach - - if (newBlock.length === 0) - delete block.local[targetName]; - else - block.local[targetName] = newBlock; - } else { - if (packageInfos.sampleUrl && block.local && block.local['url']) { - block.local[targetName] = [{ - 'url': packageInfos.sampleUrl + block.local['url'] - }]; - } - } - }); - }); -} - -/** - * Exports - */ -module.exports = { - postProcess: postProcess -}; diff --git a/lib/workers/api_structure.js b/lib/workers/api_structure.js deleted file mode 100644 index e758effd..00000000 --- a/lib/workers/api_structure.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiUse -var apiWorker = require('./api_use.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiStructure', - usage : '@apiStructure group', - example: '@apiDefine MyValidStructureGroup Some title\n@apiStructure MyValidStructureGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineStructure'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineStructure', 'structure', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_success_structure.js b/lib/workers/api_success_structure.js deleted file mode 100644 index 360ee507..00000000 --- a/lib/workers/api_success_structure.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiUse -var apiWorker = require('./api_use.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiSuccessStructure', - usage : '@apiSuccessStructure group', - example: '@apiDefine MyValidSuccessStructureGroup Some title\n@apiSuccessStructure MyValidSuccessStructureGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineSuccessStructure'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineSuccessStructure', 'successStructure', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_success_title.js b/lib/workers/api_success_title.js deleted file mode 100644 index edf9c5c5..00000000 --- a/lib/workers/api_success_title.js +++ /dev/null @@ -1,43 +0,0 @@ -// Same as @apiParamTitle -var apiWorker = require('./api_param_title.js'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiSuccess', - usage : '@apiSuccess (group) varname', - example: '@apiDefine MyValidSuccessGroup Some title or 200 OK\n@apiSuccess (MyValidSuccessGroup) username' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'defineSuccessTitle'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'defineSuccessTitle', 'success', _messages); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/api_use.js b/lib/workers/api_use.js deleted file mode 100644 index b76cf3af..00000000 --- a/lib/workers/api_use.js +++ /dev/null @@ -1,161 +0,0 @@ -var _ = require('lodash'); -var semver = require('semver'); -var WorkerError = require('../errors/worker_error'); - -// Additional information for error log -var _messages = { - common: { - element: 'apiUse', - usage : '@apiUse group', - example: '@apiDefine MyValidGroup Some title\n@apiUse MyValidGroup' - } -}; - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @param {String} target Target path in preProcess-Object (returned result), where the data should be set. - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos, target) { - target = target || 'define'; - var source = target; // relative path to the tree (global.), from where the data should be fetched. - - var result = {}; - result[target] = {}; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (block.global[source]) { - var name = block.global[source].name; - var version = block.version || '0.0.0'; - - if ( ! result[target][name]) - result[target][name] = {}; - - // fetch from local - result[target][name][version] = block.local; - } - }); - }); - - if (result[target].length === 0) - delete result[target]; - - return result; -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - * @param {String} source Source path in preProcess-Object - * @param {String} target Target path in preProcess-Object (returned result), where the data should be set. - * @param {String} messages - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, target, messages) { - source = source || 'define'; - target = target || 'use'; - messages = messages || _messages; - - parsedFiles.forEach(function(parsedFile, parsedFileIndex) { - parsedFile.forEach(function(block) { - if ( ! block.local[target]) - return; - - block.local[target].forEach(function(definition) { - var name = definition.name; - var version = block.version || '0.0.0'; - - if ( ! preProcess[source] || ! preProcess[source][name]) { - var extra = [ - { 'Groupname': name } - ]; - throw new WorkerError('Referenced groupname does not exist / it is not defined with @apiDefine.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); - } - - var matchedData = {}; - var matchedVersion = version; - if (preProcess[source][name][version]) { - // found the version - matchedData = preProcess[source][name][version]; - } else { - // find nearest matching version - var foundIndex = -1; - var lastVersion = '0.0.0'; - - var versionKeys = Object.keys(preProcess[source][name]); - versionKeys.forEach(function(currentVersion, versionIndex) { - if (semver.gte(version, currentVersion) && semver.gte(currentVersion, lastVersion)) { - lastVersion = currentVersion; - foundIndex = versionIndex; - } - }); - - if (foundIndex === -1) { - var extra = [ - { 'Groupname': name }, - { 'Version': version }, - { 'Defined versions': versionKeys }, - ]; - throw new WorkerError('Referenced definition has no matching or a higher version. ' + - 'Check version number in referenced define block.', - filenames[parsedFileIndex], - block.index, - messages.common.element, - messages.common.usage, - messages.common.example, - extra); - } - - var versionName = versionKeys[foundIndex]; - matchedData = preProcess[source][name][versionName]; - } - - // remove target, not needed anymore - // TODO: create a cleanup filter - delete block.local[target]; - - // copy matched elements into parsed block - _recursiveMerge(block.local, matchedData); - }); - }); - }); -} - -/** - * Recursive Merge of Objects with Arrays. - * - * @param block - * @param matchedData - * @todo Bad Hack - watch for something better - */ -function _recursiveMerge(block, matchedData) { - _.merge(block, matchedData, function(a, b) { - if(a instanceof Array) - return a.concat(b); - if(_.isObject(a)) - _recursiveMerge(a, b); - return a; - }); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/deprecated_api_error_title.js b/lib/workers/deprecated_api_error_title.js deleted file mode 100644 index 5eff64a3..00000000 --- a/lib/workers/deprecated_api_error_title.js +++ /dev/null @@ -1,34 +0,0 @@ -// Same as @apiParamTitle -var apiWorker = require('./deprecated_api_param_title.js'); - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'errorTitle'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'errorTitle', 'error'); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/deprecated_api_header_title.js b/lib/workers/deprecated_api_header_title.js deleted file mode 100644 index 4eba632d..00000000 --- a/lib/workers/deprecated_api_header_title.js +++ /dev/null @@ -1,34 +0,0 @@ -// Same as @apiParamTitle -var apiWorker = require('./deprecated_api_param_title.js'); - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'headerTitle'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'headerTitle', 'header'); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/deprecated_api_param_title.js b/lib/workers/deprecated_api_param_title.js deleted file mode 100644 index 1e2c6aa9..00000000 --- a/lib/workers/deprecated_api_param_title.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @param {String} target Target path in preProcess-Object (returned result), where the data should be set. - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos, target) { - target = target || 'paramTitle'; - var source = target; // relative path to the tree (global.), from where the data should be fetched. - - var result = {}; - result[target] = []; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if (block.global[source]) { - var entries = block.global[source]; - - // Simple append, same Codes too - entries.forEach(function(entry) { - result[target].push(entry); - }); - - // Delete should be placed in a cleanup filter (here we not know if an other worker need the data) - delete block.global[source]; - } - }); - }); - - if (result[target].length === 0) - delete result[target]; - - return result; -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - * @param {String} source Source path in preProcess-Object - * @param {String} target Relative path to the tree (local.), where the data should be modified. - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, target) { - source = source || 'paramTitle'; - target = target || 'parameter'; - - parsedFiles.forEach(function(parsedFile) { - parsedFile.forEach(function(block) { - if ( ! block.local[target] || ! block.local[target].fields) - return; - - var fields = block.local[target].fields; - var newBlock = {}; // preserve sorting - Object.keys(fields).forEach(function(blockKey) { - var blockEntries = block.local[target].fields[blockKey]; - var found = false; - - if (preProcess[source]) { - preProcess[source].forEach(function(preEntry) { - if (preEntry.group === blockKey) { - found = true; - newBlock[preEntry.title] = blockEntries; - } - }); - } - - if ( ! found) - newBlock[blockKey] = blockEntries; - }); - block.local[target].fields = newBlock; - }); - }); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/lib/workers/deprecated_api_success_title.js b/lib/workers/deprecated_api_success_title.js deleted file mode 100644 index 272801b9..00000000 --- a/lib/workers/deprecated_api_success_title.js +++ /dev/null @@ -1,34 +0,0 @@ -// Same as @apiParamTitle -var apiWorker = require('./deprecated_api_param_title.js'); - -/** - * PreProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object} packageInfos - * @returns {Object} - */ -function preProcess(parsedFiles, filenames, packageInfos) { - return apiWorker.preProcess(parsedFiles, filenames, packageInfos, 'successTitle'); -} - -/** - * PostProcess - * - * @param {Object[]} parsedFiles - * @param {String[]} filenames - * @param {Object[]} preProcess - * @param {Object} packageInfos - */ -function postProcess(parsedFiles, filenames, preProcess, packageInfos) { - apiWorker.postProcess(parsedFiles, filenames, preProcess, packageInfos, 'successTitle', 'success'); -} - -/** - * Exports - */ -module.exports = { - preProcess : preProcess, - postProcess: postProcess -}; diff --git a/package.json b/package.json index db572aa7..d9ebbb3b 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,26 @@ { "name": "apidoc", - "version": "0.9.1", + "version": "0.10.0", "description": "RESTful web API Documentation Generator", "author": "Peter Rottmann ", + "license": { + "type": "MIT", + "url": "https://github.com/apidoc/apidoc/blob/master/LICENSE" + }, "preferGlobal": true, + "bin": "bin/apidoc", + "main": "./lib/index.js", "homepage": "http://apidocjs.com", "repository": { "type": "git", "url": "https://github.com/apidoc/apidoc.git" }, - "license": { - "type": "MIT", - "url": "https://github.com/apidoc/apidoc/blob/master/LICENSE.md" - }, "bugs": { "url": "https://github.com/apidoc/apidoc/issues" }, - "main": "./lib/apidoc", - "bin": "bin/apidoc", "scripts": { - "test": "grunt test" + "test": "npm run jshint && mocha test/", + "jshint": "jshint lib/ test/ --exclude test/fixtures/" }, "keywords": [ "api", @@ -33,19 +34,37 @@ "node": ">= 0.10.0" }, "dependencies": { - "colors": "~1.0.3", + "apidoc-core": "~0.2.1", "fs-extra": "~0.13.0", "lodash": "~2.4.1", "marked": "~0.3.2", - "optimist": "~0.6.1", - "semver": "~4.1.0", - "wrench": "~1.5.8" + "nomnom": "~1.8.1", + "winston": "~0.8.3" }, "devDependencies": { - "grunt": "~0.4.5", - "grunt-contrib-clean": "~0.6.0", - "grunt-contrib-jshint": "~0.10.0", - "grunt-simple-mocha": "~0.4.0", + "apidoc-example": "*", + "jshint": "^2.5.10", + "mocha": "~2.0.1", + "semver": "^4.1.0", "should": "~4.2.1" + }, + "jshintConfig": { + "camelcase": true, + "curly": false, + "eqeqeq": true, + "forin": true, + "latedef": false, + "newcap": true, + "undef": true, + "unused": true, + "trailing": true, + "node": true, + "browser": true, + "predef": [ + "it", + "describe", + "before", + "after" + ] } } diff --git a/template/index.html b/template/index.html index 2ca285af..8a2b95da 100644 --- a/template/index.html +++ b/template/index.html @@ -75,7 +75,7 @@

{{name}}

{{#if template.withGenerator}} {{#if generator}}
- {{__ "Generated with"}} apiDoc {{{generator.version}}} - {{{generator.time}}} + {{__ "Generated with"}} {{{generator.name}}} {{{generator.version}}} - {{{generator.time}}}
{{/if}} {{/if}} diff --git a/template/locales/locale.js b/template/locales/locale.js index 31ac07ef..2787534a 100644 --- a/template/locales/locale.js +++ b/template/locales/locale.js @@ -2,30 +2,29 @@ define([ './locales/de.js' ], function() { var locales = {}; - for(index in arguments) - { - for(property in arguments[index]) - { + for(index in arguments) { + for(property in arguments[index]) { locales[property] = arguments[index][property]; - } // for - } // for + } + } var language = ((navigator.language) ? navigator.language : navigator.userLanguage).substr(0, 2).toLowerCase(); - if( ! locales['en']) locales['en'] = {}; - if( ! locales[language]) language = 'en'; + if( ! locales['en']) + locales['en'] = {}; + if( ! locales[language]) + language = 'en'; var locale = locales[language]; - var __ = function(text) - { + var __ = function(text) { var index = locale[text]; if(index === undefined) return text; return index; - }; // __ + }; return { - __: __, + __ : __, locales: locales, - locale: locale + locale : locale }; }); diff --git a/template/main.js b/template/main.js index 7594146c..119c91c8 100644 --- a/template/main.js +++ b/template/main.js @@ -3,7 +3,7 @@ require.config({ bootstrap: './vendor/bootstrap.min', diffMatchPatch: './vendor/diff_match_patch.min', handlebars: './vendor/handlebars.min', - handlebarsExtended: './handlebars_helper', + handlebarsExtended: './utils/handlebars_helper', jquery: './vendor/jquery.min', locales: './locales/locale', lodash: './vendor/lodash.min', diff --git a/template/handlebars_helper.js b/template/utils/handlebars_helper.js similarity index 100% rename from template/handlebars_helper.js rename to template/utils/handlebars_helper.js diff --git a/test/apidoc_test.js b/test/apidoc_test.js index 12949371..660d7046 100644 --- a/test/apidoc_test.js +++ b/test/apidoc_test.js @@ -1,18 +1,27 @@ +/*jshint unused:false, expr:true */ + /** - * Test: apidoc.js + * Test: apiDoc full parse */ -// Node Module +// node modules +var apidoc = require('apidoc-core'); +var exec = require('child_process').exec; +var fs = require('fs-extra'); +var path = require('path'); +var semver = require('semver'); var should = require('should'); -var fs = require('fs'); -var sys = require('sys'); -var exec = require('child_process').exec; -/* -------------------------------------------------------------------------------- - * Tests - * -------------------------------------------------------------------------------- */ +var versions = require('apidoc-example').versions; + describe('apiDoc full example', function() { + // get latest example for the used apidoc-spec + var latestExampleVersion = semver.maxSatisfying(versions, '~' + apidoc.SPECIFICATION_VERSION); // ~0.2.0 = >=0.2.0 <0.3.0 + + var exampleBasePath = 'node_modules/apidoc-example/' + latestExampleVersion; + var fixturePath = exampleBasePath + '/fixtures'; + var fixtureFiles = [ 'api_data.js', 'api_data.json', @@ -22,6 +31,8 @@ describe('apiDoc full example', function() { ]; before(function(done) { + fs.removeSync('./tmp/'); + done(); }); @@ -29,9 +40,16 @@ describe('apiDoc full example', function() { done(); }); + // version found + it('should find latest example version', function(done) { + should(latestExampleVersion).be.ok; + done(); + }); + // create - it('case 1: should create example in tmp/', function(done) { - exec('node ./bin/apidoc -i test/fixtures/example/ -o tmp/ -t test/template/ --silent', function(err, stdout, stderr) { + it('should create example in tmp/', function(done) { + var cmd = 'node ./bin/apidoc -i ' + exampleBasePath + '/src/ -o tmp/ -t test/template/ --silent'; + exec(cmd, function(err, stdout, stderr) { if (err) throw err; @@ -43,19 +61,21 @@ describe('apiDoc full example', function() { }); // check - it('case 1: should find created files', function(done) { + it('should find created files', function(done) { fixtureFiles.forEach(function(name) { - fs.existsSync('./tmp/' + name).should.eql(true); + fs.existsSync(fixturePath + '/' + name).should.eql(true); }); done(); }); // compare - it('case 1: created files should equal to fixtures', function(done) { + it('created files should equal to fixtures', function(done) { var timeRegExp = /\"time\"\:\s\"(.*)\"/g; var versionRegExp = /\"version\"\:\s\"(.*)\"/g; + var filenameRegExp = new RegExp('(?!"filename":\\s")(' + exampleBasePath + '/)', 'g'); + fixtureFiles.forEach(function(name) { - var fixtureContent = fs.readFileSync('test/fixtures/' + name, 'utf8'); + var fixtureContent = fs.readFileSync(fixturePath + '/' + name, 'utf8'); var createdContent = fs.readFileSync('./tmp/' + name, 'utf8'); // creation time remove (never equal) @@ -66,15 +86,21 @@ describe('apiDoc full example', function() { fixtureContent = fixtureContent.replace(versionRegExp, ''); createdContent = createdContent.replace(versionRegExp, ''); + // remove the base path + createdContent = createdContent.replace(filenameRegExp, ''); + var fixtureLines = fixtureContent.split(/\r\n/); var createdLines = createdContent.split(/\r\n/); if (fixtureLines.length !== createdLines.length) - throw new Error('File ./tmp/' + name + ' not equals to test/fixtures/' + name); + throw new Error('File ./tmp/' + name + ' not equals to ' + fixturePath + '/' + name); for (var lineNumber = 0; lineNumber < fixtureLines.length; lineNumber += 1) { if (fixtureLines[lineNumber] !== createdLines[lineNumber]) - throw new Error('File ./tmp/' + name + ' not equals to test/fixtures/' + name + ' in line ' + (lineNumber + 1)); + throw new Error('File ./tmp/' + name + ' not equals to ' + fixturePath + '/' + name + ' in line ' + (lineNumber + 1) + + '\nfixture: ' + fixtureLines[lineNumber] + + '\ncreated: ' + createdLines[lineNumber] + ); } }); done(); diff --git a/test/fixtures/api_data.js b/test/fixtures/api_data.js deleted file mode 100644 index b56a0be6..00000000 --- a/test/fixtures/api_data.js +++ /dev/null @@ -1,1750 +0,0 @@ -define({ "api": [ - { - "type": "get", - "url": "/define", - "title": "Define", - "name": "GetDefine", - "group": "Define", - "version": "0.8.0", - "description": "

Example of @apiDefine and @apiUse

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "optional": false, - "field": "field3", - "description": "

This is Field 3 (local).

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field1", - "description": "

This is Field 1.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field2", - "description": "

This is Field 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/define.js", - "groupTitle": "Define", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/define" - } - ] - }, - { - "type": "post", - "url": "/test/error", - "title": "Multiple Error Structures", - "name": "PostError", - "group": "Error", - "version": "0.1.0", - "description": "

Use of multiple ErrorStructures.

", - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "optional": false, - "field": "error3Error", - "description": "

This is Error 3 (local).

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "error1Error", - "description": "

This is Error 1.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "error2Error", - "description": "

This is Error 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/error_structure.js", - "groupTitle": "Error", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/error" - } - ] - }, - { - "type": "post", - "url": "/test/title_and_error", - "title": "Title and Structure", - "name": "PostTitleAndError", - "group": "Error", - "version": "0.1.0", - "description": "

Use of Title and Structures in the same block.

", - "success": { - "fields": { - "204 No Content. Added to global namespace.": [ - { - "group": "204", - "optional": false, - "field": "message", - "description": "

Successfully deleted.

" - } - ] - } - }, - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "optional": false, - "field": "error3Error", - "description": "

This is Error 3 (local).

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "error1Error", - "description": "

This is Error 1.

" - } - ] - } - }, - "groupTitle": "Error", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/title_and_error" - } - ] - }, - { - "type": "get", - "url": "/test/escape", - "title": "Escape Example", - "name": "GetEscape", - "group": "Escape", - "version": "0.6.0", - "description": "

Escape Example data.

", - "examples": [ - { - "title": "Example usage:", - "content": " curl -i http://localhost/escape/text\n curl -i http://localhost/escape/html\n curl -i http://localhost/escape/xml", - "type": "json" - } - ], - "success": { - "examples": [ - { - "title": "Example Response", - "content": "HTTP/1.1 200 OK {\n field_text: 'text-value',\n field_html: 'html-value',\n field_xml: 'xml-value'\n}", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/escape.js", - "groupTitle": "Escape", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/escape" - } - ] - }, - { - "type": "get", - "url": "/test/escape", - "title": "Escape Example", - "name": "GetEscape", - "group": "Escape", - "version": "0.5.0", - "description": "

Escape Example data - with comparison.

", - "examples": [ - { - "title": "Example usage:", - "content": " curl -i http://localhost/escape/text-old\n curl -i http://localhost/escape/html-old\n curl -i http://localhost/escape/xml-old", - "type": "json" - } - ], - "success": { - "examples": [ - { - "title": "Example Response", - "content": "HTTP/1.1 200 OK {\n field_text: 'text-value old',\n field_html: 'html-value old',\n field_xml: 'xml-value old'\n}", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/escape.js", - "groupTitle": "Escape", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/escape" - } - ] - }, - { - "type": "get", - "url": "/example/", - "title": "Example", - "name": "GetExample", - "group": "Example", - "version": "0.7.1", - "description": "

Extended usage of @apiExample with different example types.

", - "examples": [ - { - "title": "PHP Example (new)", - "content": "echo 'This is the content. (new)';", - "type": "PHP" - }, - { - "title": "JS Example", - "content": "console.log('This is the content.');", - "type": "JS" - } - ], - "success": { - "examples": [ - { - "title": "PHP Success Example (new)", - "content": "echo 'This is the success content. (new)';", - "type": "PHP" - }, - { - "title": "JS Success Example", - "content": "console.log('This is the success content.');", - "type": "JS" - } - ] - }, - "error": { - "examples": [ - { - "title": "PHP Error Example", - "content": "echo 'This is the error content.';", - "type": "PHP" - }, - { - "title": "JS Error Example", - "content": "console.log('This is the error content.');", - "type": "JS" - } - ] - }, - "filename": "test/fixtures/example/example.js", - "groupTitle": "Example", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/example/" - } - ] - }, - { - "type": "get", - "url": "/example/", - "title": "Example", - "name": "GetExample", - "group": "Example", - "version": "0.7.0", - "description": "

Extended usage of @apiExample with different example types.

", - "examples": [ - { - "title": "PHP Example", - "content": "echo 'This is the content.';", - "type": "PHP" - }, - { - "title": "JS Example (removed)", - "content": "console.log('This is the content. (removed)');", - "type": "JS" - } - ], - "success": { - "examples": [ - { - "title": "PHP Success Example", - "content": "echo 'This is the success content.';", - "type": "PHP" - }, - { - "title": "JS Success Example", - "content": "console.log('This is the success content.');", - "type": "JS" - } - ] - }, - "error": { - "examples": [ - { - "title": "PHP Error Example (removed)", - "content": "echo 'This is the error content. (removed)';", - "type": "PHP" - }, - { - "title": "JS Error Example", - "content": "console.log('This is the error content.');", - "type": "JS" - } - ] - }, - "filename": "test/fixtures/example/example.js", - "groupTitle": "Example", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/example/" - } - ] - }, - { - "type": "get", - "url": "/group/:id", - "title": "Group and Description", - "name": "GetGroup", - "group": "Group", - "groupDescription": "

This is a Group Description. Markdown capable.

", - "version": "0.5.0", - "filename": "test/fixtures/example/group.js", - "groupTitle": "Group", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/group/:id" - } - ] - }, - { - "type": "get", - "url": "/test/:id", - "title": "Grouping", - "name": "GetGrouping", - "group": "Grouping", - "version": "0.1.0", - "description": "

Title and Grouping of param, success and error

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param1", - "description": "

No Group, automatically set Group to "Parameter"

" - } - ], - "Replace \"login\" with this text": [ - { - "group": "login", - "type": "String", - "optional": false, - "field": "param2", - "description": "

Group "login"

" - }, - { - "group": "login", - "type": "String", - "optional": false, - "field": "param3", - "defaultValue": "Default Value", - "description": "

Group "login" with default Value

" - } - ] - } - }, - "success": { - "fields": { - "201 - Everything ok, replace \"201\" with this text.": [ - { - "group": "201", - "type": "String", - "optional": false, - "field": "success2", - "description": "

Group "201"

" - }, - { - "group": "201", - "type": "String", - "optional": false, - "field": "success3", - "defaultValue": "Default Value", - "description": "

Group "201" with default Value

" - } - ], - "Success 200": [ - { - "group": "Success 200", - "type": "String", - "optional": false, - "field": "success1", - "description": "

No Group, automatically set "Success 200"

" - } - ] - } - }, - "error": { - "fields": { - "400": [ - { - "group": "400", - "type": "String", - "optional": false, - "field": "error2", - "description": "

Group "400"

" - } - ], - "401 - Oh oh, replace \"401\" with this text": [ - { - "group": "401", - "type": "String", - "optional": false, - "field": "error3", - "description": "

Group "401"

" - } - ], - "Error 4xx": [ - { - "group": "Error 4xx", - "type": "String", - "optional": false, - "field": "error1", - "description": "

No Group automatically set "Error 4xx"

" - } - ] - } - }, - "groupTitle": "Grouping", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/:id" - } - ] - }, - { - "type": "get", - "url": "/header/:id", - "title": "Parameters", - "name": "GetHeader", - "group": "Header", - "version": "0.5.0", - "description": "

Test for @apiHeader (same as @apiParam)

", - "header": { - "fields": { - "Header": [ - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header1", - "description": "

Parameter with type and description.

" - }, - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header2", - "description": "" - }, - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header3", - "defaultValue": "Default Value", - "description": "

Parameter with type, description and default value.

" - }, - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header4", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Header", - "optional": false, - "field": "header5", - "description": "

Basic Parameter with description.

" - }, - { - "group": "Header", - "optional": false, - "field": "header6", - "description": "" - }, - { - "group": "Header", - "optional": false, - "field": "header7", - "defaultValue": "Default Value", - "description": "

Basic Parameter with description and default value.

" - }, - { - "group": "Header", - "optional": false, - "field": "header8", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Header", - "optional": true, - "field": "header9", - "description": "

Optional basic Parameter with description.

" - }, - { - "group": "Header", - "optional": true, - "field": "header10", - "description": "" - }, - { - "group": "Header", - "optional": true, - "field": "header11", - "defaultValue": "Default Value", - "description": "

Optional basic Parameter with description and default value.

" - }, - { - "group": "Header", - "optional": true, - "field": "header12", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header13", - "description": "

Optional Parameter with type and description.

" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header14", - "description": "" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header15", - "defaultValue": "Default Value", - "description": "

Optional Parameter with type, description and default value.

" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header16", - "defaultValue": "Default Value", - "description": "" - } - ] - } - }, - "filename": "test/fixtures/example/header.js", - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/header/:id" - } - ] - }, - { - "type": "get", - "url": "/header/example/", - "title": "Header Example", - "name": "GetHeaderExample", - "group": "Header", - "version": "0.5.0", - "description": "

Usage of @headerExample.

", - "header": { - "examples": [ - { - "title": "An example:", - "content": " curl -i http://localhost/header/example/", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/header_example.js", - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/header/example/" - } - ] - }, - { - "type": "get", - "url": "/header/title/", - "title": "Header Title", - "name": "GetHeaderTitle", - "group": "Header", - "version": "0.5.0", - "description": "

Usage of @apiHeaderTitle.

", - "header": { - "fields": { - "This are the Parameters for MyGroup:": [ - { - "group": "MyHeaderGroup", - "optional": false, - "field": "authorization", - "description": "

The authorization code.

" - }, - { - "group": "MyHeaderGroup", - "type": "string", - "optional": false, - "field": "text", - "description": "

Some text.

" - } - ] - } - }, - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/header/title/" - } - ] - }, - { - "type": "post", - "url": "/test/header", - "title": "Header Structure", - "name": "PostHeader", - "group": "Header", - "version": "0.5.0", - "description": "

Use of multiple HeaderStructures.

", - "header": { - "fields": { - "Header": [ - { - "group": "Header", - "optional": false, - "field": "Header3", - "description": "

This is Header 3 (local).

" - }, - { - "group": "Header", - "optional": false, - "field": "Header1", - "description": "

This is Header 1.

" - }, - { - "group": "Header", - "optional": false, - "field": "header2", - "description": "

This is Header 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/header_structure.js", - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/header" - } - ] - }, - { - "type": "get", - "url": "/language/coffeescript", - "title": "CoffeeScript", - "name": "GetLanguageCoffeeScript", - "group": "Language", - "version": "0.4.0", - "description": "

Test for CoffeeScript Comment-Syntax.

", - "filename": "test/fixtures/example/language.coffee", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/coffeescript" - } - ] - }, - { - "type": "get", - "url": "/language/coffeescript/indented1", - "title": "CoffeeScript indented 1", - "name": "GetLanguageCoffeeScriptIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.coffee", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/coffeescript/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/coffeescript/indented2", - "title": "CoffeeScript indented 2", - "name": "GetLanguageCoffeeScriptIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.coffee", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/coffeescript/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/erlang", - "title": "Erlang", - "name": "GetLanguageErlang", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Erlang Comment-Syntax.

", - "filename": "test/fixtures/example/language.erl", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/erlang" - } - ] - }, - { - "type": "get", - "url": "/language/erlang/indented1", - "title": "Erlang indented 1", - "name": "GetLanguageErlangIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "\tThis is example line 2.\n\tThis is example line 3.\n\t\t Line 4 indented (with tab at beginning).\n\t Line 5 indented.\n\tThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.erl", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/erlang/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/erlang/indented2", - "title": "Erlang indented 2", - "name": "GetLanguageErlangIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.erl", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/erlang/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/javascript", - "title": "JavaScript", - "name": "GetLanguageJavaScript", - "group": "Language", - "version": "0.4.0", - "description": "

Test for JavaScript Comment-Syntax.

", - "filename": "test/fixtures/example/language.js", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/javascript" - } - ] - }, - { - "type": "get", - "url": "/language/javascript/indented1", - "title": "JavaScript indented 1", - "name": "GetLanguageJavaScriptIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.js", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/javascript/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/javascript/indented2", - "title": "JavaScript indented 2", - "name": "GetLanguageJavaScriptIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.js", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/javascript/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/perl", - "title": "Perl", - "name": "GetLanguagePerl", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Perl Comment-Syntax.

", - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl" - } - ] - }, - { - "type": "get", - "url": "/language/perl/indented1", - "title": "Perl indented 1", - "name": "GetLanguagePerlIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t\tLine 4 indented (with tab at beginning).\n\tLine 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/perl/indented2", - "title": "Perl indented 2", - "name": "GetLanguagePerlIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/perl/podcut", - "title": "Perl comment with pod and cut", - "name": "GetLanguagePerlPodCut", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl/podcut" - } - ] - }, - { - "type": "get", - "url": "/language/python", - "title": "Python", - "name": "GetLanguagePython", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Python Comment-Syntax.

", - "filename": "test/fixtures/example/language.py", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/python" - } - ] - }, - { - "type": "get", - "url": "/language/python/indented1", - "title": "Python indented 1", - "name": "GetLanguagePythonIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.py", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/python/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/python/indented2", - "title": "Python indented 2", - "name": "GetLanguagePythonIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.py", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/python/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/ruby", - "title": "Ruby", - "name": "GetLanguageRuby", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Ruby Comment-Syntax.

", - "filename": "test/fixtures/example/language.rb", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/ruby" - } - ] - }, - { - "type": "get", - "url": "/language/ruby/indented1", - "title": "Ruby indented 1", - "name": "GetLanguageRubyIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.rb", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/ruby/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/ruby/indented2", - "title": "Ruby indented 2", - "name": "GetLanguageRubyIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.rb", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/ruby/indented2" - } - ] - }, - { - "type": "get", - "url": "/markdown/:id", - "title": "Markdown", - "name": "GetMarkdown", - "group": "Markdown", - "version": "0.6.0", - "description": "

Enable markdown for all description fields.

This text is in a separate p.

  • List 1
  • List 2

Multiline markdown text, output in one line.

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param1", - "description": "

This is a markdown apiParam

Separate line.

" - } - ] - } - }, - "filename": "test/fixtures/example/markdown.js", - "groupTitle": "Markdown", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/markdown/:id" - } - ] - }, - { - "type": "get", - "url": "/param/:id", - "title": "Parameters", - "name": "GetParam", - "group": "Param", - "version": "0.1.1", - "description": "

Parameters and different Versions: 0.1.1

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "optional": false, - "field": "param1", - "description": "

Parameter and description.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param2", - "description": "" - }, - { - "group": "Parameter", - "optional": false, - "field": "param3", - "defaultValue": "Default Value", - "description": "

Parameter, default value and description.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param4", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param5", - "description": "

Optional parameter and description.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param6", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param7", - "defaultValue": "Default Value", - "description": "

Optional parameter, default value and description.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param8", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param9", - "description": "

Type, parameter and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param10", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param11", - "defaultValue": "Default Value", - "description": "

Type, parameter and default value.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param12", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param13", - "description": "

Type, optional parameter and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param14", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param15", - "defaultValue": "Default Value", - "description": "

Type, optional parameter, default value and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param26", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "size": "4,8", - "optional": false, - "field": "param17", - "description": "

Type, size, parameter and description.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-3", - "optional": false, - "field": "param18", - "description": "

Type, size, parameter and description.

" - }, - { - "group": "Parameter", - "type": "String", - "size": "4,8", - "optional": false, - "field": "param19", - "defaultValue": "Default Value", - "description": "

Type, size, parameter, default value and description.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-3", - "optional": false, - "field": "param20", - "defaultValue": "1", - "description": "

Type, size, parameter, default value and description.

" - }, - { - "group": "Parameter", - "type": "String", - "allowedValues": [ - "\"value 1\"" - ], - "optional": false, - "field": "param21", - "description": "

Type, parameter and allowed string value.

" - }, - { - "group": "Parameter", - "type": "String", - "allowedValues": [ - "\"value 1\"", - "\"value 2\"" - ], - "optional": false, - "field": "param22", - "description": "

Type, parameter and allowed list of string values.

" - }, - { - "group": "Parameter", - "type": "Number", - "allowedValues": [ - "4711" - ], - "optional": false, - "field": "param23", - "description": "

Type, parameter and allowed value.

" - }, - { - "group": "Parameter", - "type": "Number", - "allowedValues": [ - "4711", - "4712" - ], - "optional": false, - "field": "param24", - "description": "

Type, parameter and allowed list of values.

" - }, - { - "group": "Parameter", - "type": "String", - "size": "1,10", - "allowedValues": [ - "\"value 1\"" - ], - "optional": false, - "field": "param25", - "description": "

Type, size, parameter and allowed string value.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-9999", - "allowedValues": [ - "4711" - ], - "optional": false, - "field": "param27", - "description": "

Type, size, parameter and allowed value.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-9999", - "allowedValues": [ - "4711", - "4712" - ], - "optional": false, - "field": "param28", - "description": "

Type, size, parameter and allowed list of values.

" - } - ] - } - }, - "filename": "test/fixtures/example/param.js", - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/:id" - } - ] - }, - { - "type": "get", - "url": "/param/:id", - "title": "Parameters", - "name": "GetParam", - "group": "Param", - "version": "0.1.0", - "description": "

Parameters and different Versions: 0.1.0

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param0", - "description": "

This param is removed in 0.1.1.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param1", - "description": "

This is an old text.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param2", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param3", - "defaultValue": "Default Value", - "description": "

Parameter with type, description and default value.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param4", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "optional": false, - "field": "param5", - "description": "

Basic Parameter with description.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param6", - "description": "" - }, - { - "group": "Parameter", - "optional": false, - "field": "param7", - "defaultValue": "Default Value", - "description": "

Basic Parameter with description and default value.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param8", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param9", - "description": "

Optional basic Parameter with description.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param10", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param11", - "defaultValue": "Default Value", - "description": "

Optional basic Parameter with description and default value.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param12", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param13", - "description": "

Optional Parameter with type and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param14", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param15", - "defaultValue": "Default Value", - "description": "

Optional Parameter with type, description and default value.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param16", - "defaultValue": "Default Value", - "description": "" - } - ] - } - }, - "filename": "test/fixtures/example/param.js", - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/:id" - } - ] - }, - { - "type": "get", - "url": "/param/example/", - "title": "Param Example", - "name": "GetParamExample", - "group": "Param", - "version": "0.8.0", - "description": "

Usage of @apiParamExample.

", - "examples": [ - { - "title": "A common example:", - "content": " curl -i http://localhost/param/example/", - "type": "json" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "name", - "description": "

Fullname.

" - } - ] - }, - "examples": [ - { - "title": "A JSON example:", - "content": " {\n \"name\": \"John Doe\"\n }", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/param_example.js", - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/example/" - } - ] - }, - { - "type": "get", - "url": "/param/title/", - "title": "Param Title", - "name": "GetParamTitle", - "group": "Param", - "version": "0.8.0", - "description": "

Usage of @apiParamTitle.

", - "parameter": { - "fields": { - "Parameters only for admin users:": [ - { - "group": "ParamTitleGroupname", - "type": "String", - "optional": false, - "field": "newPassword", - "description": "

New password.

" - }, - { - "group": "ParamTitleGroupname", - "type": "String", - "optional": false, - "field": "userId", - "description": "

Change password of that user.

" - } - ] - } - }, - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/title/" - } - ] - }, - { - "type": "get", - "url": "/permission/", - "title": "Permission", - "name": "GetPermission", - "group": "Permission", - "version": "0.8.0", - "description": "

@apiPermission test.

", - "permission": [ - { - "name": "permission_admin", - "title": "Admin access.", - "description": "" - } - ], - "filename": "test/fixtures/example/permission.js", - "groupTitle": "Permission", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/permission/" - } - ] - }, - { - "type": "get", - "url": "/permission/", - "title": "Permission", - "name": "GetPermission", - "group": "Permission", - "version": "0.8.0", - "description": "

@apiPermission test.

", - "permission": [ - { - "name": "permission_admin", - "title": "Admin access.", - "description": "" - }, - { - "name": "permission_user", - "title": "User access.", - "description": "" - } - ], - "filename": "test/fixtures/example/permission.js", - "groupTitle": "Permission", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/permission/" - } - ] - }, - { - "type": "get", - "url": "/sample/request/", - "title": "Sampe Request", - "name": "GetSampleRequest", - "group": "Sample", - "version": "0.8.0", - "description": "

Usage of many @apiHeaderTitle with different parameters.

", - "header": { - "fields": { - "This are the Header for Group 1:": [ - { - "group": "HeaderGroup1", - "type": "string", - "optional": false, - "field": "authorization", - "description": "

The authorization code.

" - }, - { - "group": "HeaderGroup1", - "type": "string", - "optional": false, - "field": "secrect", - "description": "

Additional secret.

" - } - ], - "This are the Header for Group 2:": [ - { - "group": "HeaderGroup2", - "type": "string", - "optional": false, - "field": "authorization", - "description": "

The authorization code.

" - }, - { - "group": "HeaderGroup2", - "type": "string", - "optional": false, - "field": "secrect", - "description": "

Additional secret.

" - }, - { - "group": "HeaderGroup2", - "type": "string", - "optional": false, - "field": "type", - "description": "

Content-Type.

" - } - ] - } - }, - "parameter": { - "fields": { - "This are Parameter for Group 1:": [ - { - "group": "ParameterGroup1", - "type": "String", - "optional": false, - "field": "name", - "description": "

Your name.

" - } - ], - "This are Parameter for Group 2:": [ - { - "group": "ParameterGroup2", - "type": "string", - "optional": false, - "field": "firstname", - "description": "

Your firstname.

" - }, - { - "group": "ParameterGroup2", - "type": "string", - "optional": false, - "field": "lastname", - "description": "

Some lastname.

" - } - ] - } - }, - "groupTitle": "Sample", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/sample/request/" - } - ] - }, - { - "type": "post", - "url": "/test/structure", - "title": "Multiple Structures", - "name": "PostStructure", - "group": "Structure", - "version": "0.1.0", - "description": "

Use of multiple Structures.

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "optional": false, - "field": "field3", - "description": "

This is Field 3 (local).

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field1", - "description": "

This is Field 1.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field2", - "description": "

This is Field 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/structure.js", - "groupTitle": "Structure", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/structure" - } - ] - }, - { - "type": "post", - "url": "/test/success", - "title": "Multiple Success Structures", - "name": "PostSuccess", - "group": "Success", - "version": "0.1.0", - "description": "

Use of multiple SuccessStructures.

", - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "optional": false, - "field": "success3", - "description": "

This is Success 3 (local).

" - }, - { - "group": "Success 200", - "optional": false, - "field": "success1", - "description": "

This is Success 1.

" - }, - { - "group": "Success 200", - "optional": false, - "field": "success2", - "description": "

This is Success 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/success_structure.js", - "groupTitle": "Success", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/success" - } - ] - } -] }); \ No newline at end of file diff --git a/test/fixtures/api_data.json b/test/fixtures/api_data.json deleted file mode 100644 index 97a13c90..00000000 --- a/test/fixtures/api_data.json +++ /dev/null @@ -1,1750 +0,0 @@ -[ - { - "type": "get", - "url": "/define", - "title": "Define", - "name": "GetDefine", - "group": "Define", - "version": "0.8.0", - "description": "

Example of @apiDefine and @apiUse

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "optional": false, - "field": "field3", - "description": "

This is Field 3 (local).

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field1", - "description": "

This is Field 1.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field2", - "description": "

This is Field 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/define.js", - "groupTitle": "Define", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/define" - } - ] - }, - { - "type": "post", - "url": "/test/error", - "title": "Multiple Error Structures", - "name": "PostError", - "group": "Error", - "version": "0.1.0", - "description": "

Use of multiple ErrorStructures.

", - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "optional": false, - "field": "error3Error", - "description": "

This is Error 3 (local).

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "error1Error", - "description": "

This is Error 1.

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "error2Error", - "description": "

This is Error 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/error_structure.js", - "groupTitle": "Error", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/error" - } - ] - }, - { - "type": "post", - "url": "/test/title_and_error", - "title": "Title and Structure", - "name": "PostTitleAndError", - "group": "Error", - "version": "0.1.0", - "description": "

Use of Title and Structures in the same block.

", - "success": { - "fields": { - "204 No Content. Added to global namespace.": [ - { - "group": "204", - "optional": false, - "field": "message", - "description": "

Successfully deleted.

" - } - ] - } - }, - "error": { - "fields": { - "Error 4xx": [ - { - "group": "Error 4xx", - "optional": false, - "field": "error3Error", - "description": "

This is Error 3 (local).

" - }, - { - "group": "Error 4xx", - "optional": false, - "field": "error1Error", - "description": "

This is Error 1.

" - } - ] - } - }, - "groupTitle": "Error", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/title_and_error" - } - ] - }, - { - "type": "get", - "url": "/test/escape", - "title": "Escape Example", - "name": "GetEscape", - "group": "Escape", - "version": "0.6.0", - "description": "

Escape Example data.

", - "examples": [ - { - "title": "Example usage:", - "content": " curl -i http://localhost/escape/text\n curl -i http://localhost/escape/html\n curl -i http://localhost/escape/xml", - "type": "json" - } - ], - "success": { - "examples": [ - { - "title": "Example Response", - "content": "HTTP/1.1 200 OK {\n field_text: 'text-value',\n field_html: 'html-value',\n field_xml: 'xml-value'\n}", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/escape.js", - "groupTitle": "Escape", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/escape" - } - ] - }, - { - "type": "get", - "url": "/test/escape", - "title": "Escape Example", - "name": "GetEscape", - "group": "Escape", - "version": "0.5.0", - "description": "

Escape Example data - with comparison.

", - "examples": [ - { - "title": "Example usage:", - "content": " curl -i http://localhost/escape/text-old\n curl -i http://localhost/escape/html-old\n curl -i http://localhost/escape/xml-old", - "type": "json" - } - ], - "success": { - "examples": [ - { - "title": "Example Response", - "content": "HTTP/1.1 200 OK {\n field_text: 'text-value old',\n field_html: 'html-value old',\n field_xml: 'xml-value old'\n}", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/escape.js", - "groupTitle": "Escape", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/escape" - } - ] - }, - { - "type": "get", - "url": "/example/", - "title": "Example", - "name": "GetExample", - "group": "Example", - "version": "0.7.1", - "description": "

Extended usage of @apiExample with different example types.

", - "examples": [ - { - "title": "PHP Example (new)", - "content": "echo 'This is the content. (new)';", - "type": "PHP" - }, - { - "title": "JS Example", - "content": "console.log('This is the content.');", - "type": "JS" - } - ], - "success": { - "examples": [ - { - "title": "PHP Success Example (new)", - "content": "echo 'This is the success content. (new)';", - "type": "PHP" - }, - { - "title": "JS Success Example", - "content": "console.log('This is the success content.');", - "type": "JS" - } - ] - }, - "error": { - "examples": [ - { - "title": "PHP Error Example", - "content": "echo 'This is the error content.';", - "type": "PHP" - }, - { - "title": "JS Error Example", - "content": "console.log('This is the error content.');", - "type": "JS" - } - ] - }, - "filename": "test/fixtures/example/example.js", - "groupTitle": "Example", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/example/" - } - ] - }, - { - "type": "get", - "url": "/example/", - "title": "Example", - "name": "GetExample", - "group": "Example", - "version": "0.7.0", - "description": "

Extended usage of @apiExample with different example types.

", - "examples": [ - { - "title": "PHP Example", - "content": "echo 'This is the content.';", - "type": "PHP" - }, - { - "title": "JS Example (removed)", - "content": "console.log('This is the content. (removed)');", - "type": "JS" - } - ], - "success": { - "examples": [ - { - "title": "PHP Success Example", - "content": "echo 'This is the success content.';", - "type": "PHP" - }, - { - "title": "JS Success Example", - "content": "console.log('This is the success content.');", - "type": "JS" - } - ] - }, - "error": { - "examples": [ - { - "title": "PHP Error Example (removed)", - "content": "echo 'This is the error content. (removed)';", - "type": "PHP" - }, - { - "title": "JS Error Example", - "content": "console.log('This is the error content.');", - "type": "JS" - } - ] - }, - "filename": "test/fixtures/example/example.js", - "groupTitle": "Example", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/example/" - } - ] - }, - { - "type": "get", - "url": "/group/:id", - "title": "Group and Description", - "name": "GetGroup", - "group": "Group", - "groupDescription": "

This is a Group Description. Markdown capable.

", - "version": "0.5.0", - "filename": "test/fixtures/example/group.js", - "groupTitle": "Group", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/group/:id" - } - ] - }, - { - "type": "get", - "url": "/test/:id", - "title": "Grouping", - "name": "GetGrouping", - "group": "Grouping", - "version": "0.1.0", - "description": "

Title and Grouping of param, success and error

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param1", - "description": "

No Group, automatically set Group to "Parameter"

" - } - ], - "Replace \"login\" with this text": [ - { - "group": "login", - "type": "String", - "optional": false, - "field": "param2", - "description": "

Group "login"

" - }, - { - "group": "login", - "type": "String", - "optional": false, - "field": "param3", - "defaultValue": "Default Value", - "description": "

Group "login" with default Value

" - } - ] - } - }, - "success": { - "fields": { - "201 - Everything ok, replace \"201\" with this text.": [ - { - "group": "201", - "type": "String", - "optional": false, - "field": "success2", - "description": "

Group "201"

" - }, - { - "group": "201", - "type": "String", - "optional": false, - "field": "success3", - "defaultValue": "Default Value", - "description": "

Group "201" with default Value

" - } - ], - "Success 200": [ - { - "group": "Success 200", - "type": "String", - "optional": false, - "field": "success1", - "description": "

No Group, automatically set "Success 200"

" - } - ] - } - }, - "error": { - "fields": { - "400": [ - { - "group": "400", - "type": "String", - "optional": false, - "field": "error2", - "description": "

Group "400"

" - } - ], - "401 - Oh oh, replace \"401\" with this text": [ - { - "group": "401", - "type": "String", - "optional": false, - "field": "error3", - "description": "

Group "401"

" - } - ], - "Error 4xx": [ - { - "group": "Error 4xx", - "type": "String", - "optional": false, - "field": "error1", - "description": "

No Group automatically set "Error 4xx"

" - } - ] - } - }, - "groupTitle": "Grouping", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/:id" - } - ] - }, - { - "type": "get", - "url": "/header/:id", - "title": "Parameters", - "name": "GetHeader", - "group": "Header", - "version": "0.5.0", - "description": "

Test for @apiHeader (same as @apiParam)

", - "header": { - "fields": { - "Header": [ - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header1", - "description": "

Parameter with type and description.

" - }, - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header2", - "description": "" - }, - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header3", - "defaultValue": "Default Value", - "description": "

Parameter with type, description and default value.

" - }, - { - "group": "Header", - "type": "String", - "optional": false, - "field": "header4", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Header", - "optional": false, - "field": "header5", - "description": "

Basic Parameter with description.

" - }, - { - "group": "Header", - "optional": false, - "field": "header6", - "description": "" - }, - { - "group": "Header", - "optional": false, - "field": "header7", - "defaultValue": "Default Value", - "description": "

Basic Parameter with description and default value.

" - }, - { - "group": "Header", - "optional": false, - "field": "header8", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Header", - "optional": true, - "field": "header9", - "description": "

Optional basic Parameter with description.

" - }, - { - "group": "Header", - "optional": true, - "field": "header10", - "description": "" - }, - { - "group": "Header", - "optional": true, - "field": "header11", - "defaultValue": "Default Value", - "description": "

Optional basic Parameter with description and default value.

" - }, - { - "group": "Header", - "optional": true, - "field": "header12", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header13", - "description": "

Optional Parameter with type and description.

" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header14", - "description": "" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header15", - "defaultValue": "Default Value", - "description": "

Optional Parameter with type, description and default value.

" - }, - { - "group": "Header", - "type": "String", - "optional": true, - "field": "header16", - "defaultValue": "Default Value", - "description": "" - } - ] - } - }, - "filename": "test/fixtures/example/header.js", - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/header/:id" - } - ] - }, - { - "type": "get", - "url": "/header/example/", - "title": "Header Example", - "name": "GetHeaderExample", - "group": "Header", - "version": "0.5.0", - "description": "

Usage of @headerExample.

", - "header": { - "examples": [ - { - "title": "An example:", - "content": " curl -i http://localhost/header/example/", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/header_example.js", - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/header/example/" - } - ] - }, - { - "type": "get", - "url": "/header/title/", - "title": "Header Title", - "name": "GetHeaderTitle", - "group": "Header", - "version": "0.5.0", - "description": "

Usage of @apiHeaderTitle.

", - "header": { - "fields": { - "This are the Parameters for MyGroup:": [ - { - "group": "MyHeaderGroup", - "optional": false, - "field": "authorization", - "description": "

The authorization code.

" - }, - { - "group": "MyHeaderGroup", - "type": "string", - "optional": false, - "field": "text", - "description": "

Some text.

" - } - ] - } - }, - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/header/title/" - } - ] - }, - { - "type": "post", - "url": "/test/header", - "title": "Header Structure", - "name": "PostHeader", - "group": "Header", - "version": "0.5.0", - "description": "

Use of multiple HeaderStructures.

", - "header": { - "fields": { - "Header": [ - { - "group": "Header", - "optional": false, - "field": "Header3", - "description": "

This is Header 3 (local).

" - }, - { - "group": "Header", - "optional": false, - "field": "Header1", - "description": "

This is Header 1.

" - }, - { - "group": "Header", - "optional": false, - "field": "header2", - "description": "

This is Header 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/header_structure.js", - "groupTitle": "Header", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/header" - } - ] - }, - { - "type": "get", - "url": "/language/coffeescript", - "title": "CoffeeScript", - "name": "GetLanguageCoffeeScript", - "group": "Language", - "version": "0.4.0", - "description": "

Test for CoffeeScript Comment-Syntax.

", - "filename": "test/fixtures/example/language.coffee", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/coffeescript" - } - ] - }, - { - "type": "get", - "url": "/language/coffeescript/indented1", - "title": "CoffeeScript indented 1", - "name": "GetLanguageCoffeeScriptIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.coffee", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/coffeescript/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/coffeescript/indented2", - "title": "CoffeeScript indented 2", - "name": "GetLanguageCoffeeScriptIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.coffee", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/coffeescript/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/erlang", - "title": "Erlang", - "name": "GetLanguageErlang", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Erlang Comment-Syntax.

", - "filename": "test/fixtures/example/language.erl", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/erlang" - } - ] - }, - { - "type": "get", - "url": "/language/erlang/indented1", - "title": "Erlang indented 1", - "name": "GetLanguageErlangIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "\tThis is example line 2.\n\tThis is example line 3.\n\t\t Line 4 indented (with tab at beginning).\n\t Line 5 indented.\n\tThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.erl", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/erlang/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/erlang/indented2", - "title": "Erlang indented 2", - "name": "GetLanguageErlangIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.erl", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/erlang/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/javascript", - "title": "JavaScript", - "name": "GetLanguageJavaScript", - "group": "Language", - "version": "0.4.0", - "description": "

Test for JavaScript Comment-Syntax.

", - "filename": "test/fixtures/example/language.js", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/javascript" - } - ] - }, - { - "type": "get", - "url": "/language/javascript/indented1", - "title": "JavaScript indented 1", - "name": "GetLanguageJavaScriptIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.js", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/javascript/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/javascript/indented2", - "title": "JavaScript indented 2", - "name": "GetLanguageJavaScriptIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.js", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/javascript/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/perl", - "title": "Perl", - "name": "GetLanguagePerl", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Perl Comment-Syntax.

", - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl" - } - ] - }, - { - "type": "get", - "url": "/language/perl/indented1", - "title": "Perl indented 1", - "name": "GetLanguagePerlIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t\tLine 4 indented (with tab at beginning).\n\tLine 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/perl/indented2", - "title": "Perl indented 2", - "name": "GetLanguagePerlIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n\t Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/perl/podcut", - "title": "Perl comment with pod and cut", - "name": "GetLanguagePerlPodCut", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.pm", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/perl/podcut" - } - ] - }, - { - "type": "get", - "url": "/language/python", - "title": "Python", - "name": "GetLanguagePython", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Python Comment-Syntax.

", - "filename": "test/fixtures/example/language.py", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/python" - } - ] - }, - { - "type": "get", - "url": "/language/python/indented1", - "title": "Python indented 1", - "name": "GetLanguagePythonIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.py", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/python/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/python/indented2", - "title": "Python indented 2", - "name": "GetLanguagePythonIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.py", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/python/indented2" - } - ] - }, - { - "type": "get", - "url": "/language/ruby", - "title": "Ruby", - "name": "GetLanguageRuby", - "group": "Language", - "version": "0.4.0", - "description": "

Test for Ruby Comment-Syntax.

", - "filename": "test/fixtures/example/language.rb", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/ruby" - } - ] - }, - { - "type": "get", - "url": "/language/ruby/indented1", - "title": "Ruby indented 1", - "name": "GetLanguageRubyIndented1", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.rb", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/ruby/indented1" - } - ] - }, - { - "type": "get", - "url": "/language/ruby/indented2", - "title": "Ruby indented 2", - "name": "GetLanguageRubyIndented2", - "group": "Language", - "version": "0.4.0", - "examples": [ - { - "title": "Test for indented comment.", - "content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.", - "type": "json" - } - ], - "filename": "test/fixtures/example/language.rb", - "groupTitle": "Language", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/language/ruby/indented2" - } - ] - }, - { - "type": "get", - "url": "/markdown/:id", - "title": "Markdown", - "name": "GetMarkdown", - "group": "Markdown", - "version": "0.6.0", - "description": "

Enable markdown for all description fields.

This text is in a separate p.

  • List 1
  • List 2

Multiline markdown text, output in one line.

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param1", - "description": "

This is a markdown apiParam

Separate line.

" - } - ] - } - }, - "filename": "test/fixtures/example/markdown.js", - "groupTitle": "Markdown", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/markdown/:id" - } - ] - }, - { - "type": "get", - "url": "/param/:id", - "title": "Parameters", - "name": "GetParam", - "group": "Param", - "version": "0.1.1", - "description": "

Parameters and different Versions: 0.1.1

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "optional": false, - "field": "param1", - "description": "

Parameter and description.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param2", - "description": "" - }, - { - "group": "Parameter", - "optional": false, - "field": "param3", - "defaultValue": "Default Value", - "description": "

Parameter, default value and description.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param4", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param5", - "description": "

Optional parameter and description.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param6", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param7", - "defaultValue": "Default Value", - "description": "

Optional parameter, default value and description.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param8", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param9", - "description": "

Type, parameter and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param10", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param11", - "defaultValue": "Default Value", - "description": "

Type, parameter and default value.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param12", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param13", - "description": "

Type, optional parameter and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param14", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param15", - "defaultValue": "Default Value", - "description": "

Type, optional parameter, default value and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param26", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "size": "4,8", - "optional": false, - "field": "param17", - "description": "

Type, size, parameter and description.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-3", - "optional": false, - "field": "param18", - "description": "

Type, size, parameter and description.

" - }, - { - "group": "Parameter", - "type": "String", - "size": "4,8", - "optional": false, - "field": "param19", - "defaultValue": "Default Value", - "description": "

Type, size, parameter, default value and description.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-3", - "optional": false, - "field": "param20", - "defaultValue": "1", - "description": "

Type, size, parameter, default value and description.

" - }, - { - "group": "Parameter", - "type": "String", - "allowedValues": [ - "\"value 1\"" - ], - "optional": false, - "field": "param21", - "description": "

Type, parameter and allowed string value.

" - }, - { - "group": "Parameter", - "type": "String", - "allowedValues": [ - "\"value 1\"", - "\"value 2\"" - ], - "optional": false, - "field": "param22", - "description": "

Type, parameter and allowed list of string values.

" - }, - { - "group": "Parameter", - "type": "Number", - "allowedValues": [ - "4711" - ], - "optional": false, - "field": "param23", - "description": "

Type, parameter and allowed value.

" - }, - { - "group": "Parameter", - "type": "Number", - "allowedValues": [ - "4711", - "4712" - ], - "optional": false, - "field": "param24", - "description": "

Type, parameter and allowed list of values.

" - }, - { - "group": "Parameter", - "type": "String", - "size": "1,10", - "allowedValues": [ - "\"value 1\"" - ], - "optional": false, - "field": "param25", - "description": "

Type, size, parameter and allowed string value.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-9999", - "allowedValues": [ - "4711" - ], - "optional": false, - "field": "param27", - "description": "

Type, size, parameter and allowed value.

" - }, - { - "group": "Parameter", - "type": "Number", - "size": "1-9999", - "allowedValues": [ - "4711", - "4712" - ], - "optional": false, - "field": "param28", - "description": "

Type, size, parameter and allowed list of values.

" - } - ] - } - }, - "filename": "test/fixtures/example/param.js", - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/:id" - } - ] - }, - { - "type": "get", - "url": "/param/:id", - "title": "Parameters", - "name": "GetParam", - "group": "Param", - "version": "0.1.0", - "description": "

Parameters and different Versions: 0.1.0

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param0", - "description": "

This param is removed in 0.1.1.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param1", - "description": "

This is an old text.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param2", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param3", - "defaultValue": "Default Value", - "description": "

Parameter with type, description and default value.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "param4", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "optional": false, - "field": "param5", - "description": "

Basic Parameter with description.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param6", - "description": "" - }, - { - "group": "Parameter", - "optional": false, - "field": "param7", - "defaultValue": "Default Value", - "description": "

Basic Parameter with description and default value.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "param8", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param9", - "description": "

Optional basic Parameter with description.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param10", - "description": "" - }, - { - "group": "Parameter", - "optional": true, - "field": "param11", - "defaultValue": "Default Value", - "description": "

Optional basic Parameter with description and default value.

" - }, - { - "group": "Parameter", - "optional": true, - "field": "param12", - "defaultValue": "Default Value", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param13", - "description": "

Optional Parameter with type and description.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param14", - "description": "" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param15", - "defaultValue": "Default Value", - "description": "

Optional Parameter with type, description and default value.

" - }, - { - "group": "Parameter", - "type": "String", - "optional": true, - "field": "param16", - "defaultValue": "Default Value", - "description": "" - } - ] - } - }, - "filename": "test/fixtures/example/param.js", - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/:id" - } - ] - }, - { - "type": "get", - "url": "/param/example/", - "title": "Param Example", - "name": "GetParamExample", - "group": "Param", - "version": "0.8.0", - "description": "

Usage of @apiParamExample.

", - "examples": [ - { - "title": "A common example:", - "content": " curl -i http://localhost/param/example/", - "type": "json" - } - ], - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "type": "String", - "optional": false, - "field": "name", - "description": "

Fullname.

" - } - ] - }, - "examples": [ - { - "title": "A JSON example:", - "content": " {\n \"name\": \"John Doe\"\n }", - "type": "json" - } - ] - }, - "filename": "test/fixtures/example/param_example.js", - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/example/" - } - ] - }, - { - "type": "get", - "url": "/param/title/", - "title": "Param Title", - "name": "GetParamTitle", - "group": "Param", - "version": "0.8.0", - "description": "

Usage of @apiParamTitle.

", - "parameter": { - "fields": { - "Parameters only for admin users:": [ - { - "group": "ParamTitleGroupname", - "type": "String", - "optional": false, - "field": "newPassword", - "description": "

New password.

" - }, - { - "group": "ParamTitleGroupname", - "type": "String", - "optional": false, - "field": "userId", - "description": "

Change password of that user.

" - } - ] - } - }, - "groupTitle": "Param", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/param/title/" - } - ] - }, - { - "type": "get", - "url": "/permission/", - "title": "Permission", - "name": "GetPermission", - "group": "Permission", - "version": "0.8.0", - "description": "

@apiPermission test.

", - "permission": [ - { - "name": "permission_admin", - "title": "Admin access.", - "description": "" - } - ], - "filename": "test/fixtures/example/permission.js", - "groupTitle": "Permission", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/permission/" - } - ] - }, - { - "type": "get", - "url": "/permission/", - "title": "Permission", - "name": "GetPermission", - "group": "Permission", - "version": "0.8.0", - "description": "

@apiPermission test.

", - "permission": [ - { - "name": "permission_admin", - "title": "Admin access.", - "description": "" - }, - { - "name": "permission_user", - "title": "User access.", - "description": "" - } - ], - "filename": "test/fixtures/example/permission.js", - "groupTitle": "Permission", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/permission/" - } - ] - }, - { - "type": "get", - "url": "/sample/request/", - "title": "Sampe Request", - "name": "GetSampleRequest", - "group": "Sample", - "version": "0.8.0", - "description": "

Usage of many @apiHeaderTitle with different parameters.

", - "header": { - "fields": { - "This are the Header for Group 1:": [ - { - "group": "HeaderGroup1", - "type": "string", - "optional": false, - "field": "authorization", - "description": "

The authorization code.

" - }, - { - "group": "HeaderGroup1", - "type": "string", - "optional": false, - "field": "secrect", - "description": "

Additional secret.

" - } - ], - "This are the Header for Group 2:": [ - { - "group": "HeaderGroup2", - "type": "string", - "optional": false, - "field": "authorization", - "description": "

The authorization code.

" - }, - { - "group": "HeaderGroup2", - "type": "string", - "optional": false, - "field": "secrect", - "description": "

Additional secret.

" - }, - { - "group": "HeaderGroup2", - "type": "string", - "optional": false, - "field": "type", - "description": "

Content-Type.

" - } - ] - } - }, - "parameter": { - "fields": { - "This are Parameter for Group 1:": [ - { - "group": "ParameterGroup1", - "type": "String", - "optional": false, - "field": "name", - "description": "

Your name.

" - } - ], - "This are Parameter for Group 2:": [ - { - "group": "ParameterGroup2", - "type": "string", - "optional": false, - "field": "firstname", - "description": "

Your firstname.

" - }, - { - "group": "ParameterGroup2", - "type": "string", - "optional": false, - "field": "lastname", - "description": "

Some lastname.

" - } - ] - } - }, - "groupTitle": "Sample", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/sample/request/" - } - ] - }, - { - "type": "post", - "url": "/test/structure", - "title": "Multiple Structures", - "name": "PostStructure", - "group": "Structure", - "version": "0.1.0", - "description": "

Use of multiple Structures.

", - "parameter": { - "fields": { - "Parameter": [ - { - "group": "Parameter", - "optional": false, - "field": "field3", - "description": "

This is Field 3 (local).

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field1", - "description": "

This is Field 1.

" - }, - { - "group": "Parameter", - "optional": false, - "field": "field2", - "description": "

This is Field 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/structure.js", - "groupTitle": "Structure", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/structure" - } - ] - }, - { - "type": "post", - "url": "/test/success", - "title": "Multiple Success Structures", - "name": "PostSuccess", - "group": "Success", - "version": "0.1.0", - "description": "

Use of multiple SuccessStructures.

", - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "optional": false, - "field": "success3", - "description": "

This is Success 3 (local).

" - }, - { - "group": "Success 200", - "optional": false, - "field": "success1", - "description": "

This is Success 1.

" - }, - { - "group": "Success 200", - "optional": false, - "field": "success2", - "description": "

This is Success 2.

" - } - ] - } - }, - "filename": "test/fixtures/example/success_structure.js", - "groupTitle": "Success", - "sampleRequest": [ - { - "url": "https://api.github.com/v1/test/success" - } - ] - } -] \ No newline at end of file diff --git a/test/fixtures/api_project.js b/test/fixtures/api_project.js deleted file mode 100644 index 81abeae7..00000000 --- a/test/fixtures/api_project.js +++ /dev/null @@ -1,27 +0,0 @@ -define({ - "name": "test", - "version": "0.5.0", - "description": "RESTful web API Documentation Generator", - "url": "https://api.github.com/v1", - "sampleUrl": "https://api.github.com/v1", - "header": { - "title": "My own header title", - "content": "

Header .md File

\n

Content of header.md file.

\n" - }, - "footer": { - "title": "My own footer title", - "content": "

Footer .md File

\n

Content of footer.md file.

\n" - }, - "order": [ - "Error", - "Define", - "PostTitleAndError", - "NotExistingEntry", - "PostError" - ], - "generator": { - "version": "0.8.2", - "time": "2014-11-28T14:02:36.750Z" - }, - "apidoc": "0.2.0" -}); \ No newline at end of file diff --git a/test/fixtures/api_project.json b/test/fixtures/api_project.json deleted file mode 100644 index 941637df..00000000 --- a/test/fixtures/api_project.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "test", - "version": "0.5.0", - "description": "RESTful web API Documentation Generator", - "url": "https://api.github.com/v1", - "sampleUrl": "https://api.github.com/v1", - "header": { - "title": "My own header title", - "content": "

Header .md File

\n

Content of header.md file.

\n" - }, - "footer": { - "title": "My own footer title", - "content": "

Footer .md File

\n

Content of footer.md file.

\n" - }, - "order": [ - "Error", - "Define", - "PostTitleAndError", - "NotExistingEntry", - "PostError" - ], - "generator": { - "version": "0.8.2", - "time": "2014-11-28T14:02:36.750Z" - }, - "apidoc": "0.2.0" -} \ No newline at end of file diff --git a/test/fixtures/example/_grouping.js b/test/fixtures/example/_grouping.js deleted file mode 100644 index b9a9f4f3..00000000 --- a/test/fixtures/example/_grouping.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @api {get} /test/:id Grouping - * @apiName GetGrouping - * @apiGroup Grouping - * @apiVersion 0.1.0 - * @apiDescription Title and Grouping of param, success and error - * - * - * @apiParam {String} param1 No Group, automatically set Group to "Parameter" - * - * @apiParamTitle (login) Replace "login" with this text - * @apiParam (login) {String} param2 Group "login" - * @apiParam (login) {String} param3="Default Value" Group "login" with default Value - * - * - * @apiSuccess {String} success1 No Group, automatically set "Success 200" - * - * @apiSuccessTitle (201) 201 - Everything ok, replace "201" with this text. - * @apiSuccess (201) {String} success2 Group "201" - * @apiSuccess (201) {String} success3="Default Value" Group "201" with default Value - * - * - * @apiError {String} error1 No Group automatically set "Error 4xx" - * - * @apiError (400) {String} error2 Group "400" - * - * @apiErrorTitle (401) 401 - Oh oh, replace "401" with this text - * @apiError (401) {String} error3 Group "401" - */ diff --git a/test/fixtures/example/_syntax.js b/test/fixtures/example/_syntax.js deleted file mode 100644 index faaec2fd..00000000 --- a/test/fixtures/example/_syntax.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @test Ignore this block. No apiDoc. - */ - - /** - * @apiIgnore Ignore this block, apiIgnore is set. - * @api {get} /ignore/me - * Test whitespaces befor block. - */ diff --git a/test/fixtures/example/apidoc.json b/test/fixtures/example/apidoc.json deleted file mode 100644 index 2cb44e7f..00000000 --- a/test/fixtures/example/apidoc.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "test", - "version": "0.5.0", - "description": "RESTful web API Documentation Generator", - "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" - }, - "order": [ - "Error", - "Define", - "PostTitleAndError", - "NotExistingEntry", - "PostError" - ] -} diff --git a/test/fixtures/example/define.js b/test/fixtures/example/define.js deleted file mode 100644 index f3f032d4..00000000 --- a/test/fixtures/example/define.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @apiDefine Structure1 title - * Some description. - * - * @apiParam field1 This is Field 1. - */ - -/** - * @apiDefine Structure2 title - * Some description. - * - * @apiParam field2 This is Field 2. - */ - -/** - * @api {get} /define Define - * @apiName GetDefine - * @apiGroup Define - * @apiVersion 0.8.0 - * @apiDescription Example of @apiDefine and @apiUse - * - * @apiUse Structure1 - * @apiUse Structure2 - * - * @apiParam field3 This is Field 3 (local). - */ diff --git a/test/fixtures/example/error_structure.js b/test/fixtures/example/error_structure.js deleted file mode 100644 index 2cc88415..00000000 --- a/test/fixtures/example/error_structure.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Use of multiple ErrorStructures. - */ - -/** - * @apiDefineErrorStructure Error1 - * - * @apiError error1Error This is Error 1. - */ - -/** - * @apiDefineErrorStructure Error2 - * - * @apiError error2Error This is Error 2. - */ - -/** - * @api {post} /test/error Multiple Error Structures - * @apiName PostError - * @apiGroup Error - * @apiVersion 0.1.0 - * @apiDescription Use of multiple ErrorStructures. - * - * @apiErrorStructure Error1 - * @apiErrorStructure Error2 - * - * @apiError error3Error This is Error 3 (local). - */ diff --git a/test/fixtures/example/escape.js b/test/fixtures/example/escape.js deleted file mode 100644 index d9a4d64a..00000000 --- a/test/fixtures/example/escape.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @api {get} /test/escape Escape Example - * @apiName GetEscape - * @apiGroup Escape - * @apiVersion 0.6.0 - * @apiDescription Escape Example data. - * - * @apiExample Example usage: - * curl -i http://localhost/escape/text - * curl -i http://localhost/escape/html - * curl -i http://localhost/escape/xml - * - * @apiSuccessExample Example Response - * HTTP/1.1 200 OK { - * field_text: 'text-value', - * field_html: 'html-value', - * field_xml: 'xml-value' - * } - */ - -/** - * @api {get} /test/escape Escape Example - * @apiName GetEscape - * @apiGroup Escape - * @apiVersion 0.5.0 - * @apiDescription Escape Example data - with comparison. - * - * @apiExample Example usage: - * curl -i http://localhost/escape/text-old - * curl -i http://localhost/escape/html-old - * curl -i http://localhost/escape/xml-old - * - * @apiSuccessExample Example Response - * HTTP/1.1 200 OK { - * field_text: 'text-value old', - * field_html: 'html-value old', - * field_xml: 'xml-value old' - * } - */ diff --git a/test/fixtures/example/example.js b/test/fixtures/example/example.js deleted file mode 100644 index a009e849..00000000 --- a/test/fixtures/example/example.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @api {get} /example/ Example - * @apiName GetExample - * @apiGroup Example - * @apiVersion 0.7.1 - * @apiDescription Extended usage of @apiExample with different example types. - * - * @apiExample {PHP} PHP Example (new) - * echo 'This is the content. (new)'; - * @apiExample {JS} JS Example - * console.log('This is the content.'); - * - * @apiSuccessExample {PHP} PHP Success Example (new) - * echo 'This is the success content. (new)'; - * @apiSuccessExample {JS} JS Success Example - * console.log('This is the success content.'); - * - * @apiErrorExample {PHP} PHP Error Example - * echo 'This is the error content.'; - * @apiErrorExample {JS} JS Error Example - * console.log('This is the error content.'); - */ - -/** - * @api {get} /example/ Example - * @apiName GetExample - * @apiGroup Example - * @apiVersion 0.7.0 - * @apiDescription Extended usage of @apiExample with different example types. - * - * @apiExample {PHP} PHP Example - * echo 'This is the content.'; - * @apiExample {JS} JS Example (removed) - * console.log('This is the content. (removed)'); - * - * @apiSuccessExample {PHP} PHP Success Example - * echo 'This is the success content.'; - * @apiSuccessExample {JS} JS Success Example - * console.log('This is the success content.'); - * - * @apiErrorExample {PHP} PHP Error Example (removed) - * echo 'This is the error content. (removed)'; - * @apiErrorExample {JS} JS Error Example - * console.log('This is the error content.'); - */ diff --git a/test/fixtures/example/footer.md b/test/fixtures/example/footer.md deleted file mode 100644 index ff9e0d65..00000000 --- a/test/fixtures/example/footer.md +++ /dev/null @@ -1,3 +0,0 @@ -# Footer .md File - -Content of footer.md file. diff --git a/test/fixtures/example/group.js b/test/fixtures/example/group.js deleted file mode 100644 index 84bf2b03..00000000 --- a/test/fixtures/example/group.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @api {get} /group/:id Group and Description - * @apiName GetGroup - * @apiGroup Group - * @apiGroupDescription This is a Group Description. - * Markdown capable. - * @apiVersion 0.5.0 - */ diff --git a/test/fixtures/example/header.js b/test/fixtures/example/header.js deleted file mode 100644 index f1b391ae..00000000 --- a/test/fixtures/example/header.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @api {get} /header/:id Parameters - * @apiName GetHeader - * @apiGroup Header - * @apiVersion 0.5.0 - * @apiDescription Test for @apiHeader (same as @apiParam) - * - * @apiHeader {String} header1 Parameter with type and description. - * @apiHeader {String} header2 - * @apiHeader {String} header3="Default Value" Parameter with type, description and default value. - * @apiHeader {String} header4="Default Value" - * - * @apiHeader header5 Basic Parameter with description. - * @apiHeader header6 - * @apiHeader header7="Default Value" Basic Parameter with description and default value. - * @apiHeader header8="Default Value" - * - * @apiHeader [header9] Optional basic Parameter with description. - * @apiHeader [header10] - * @apiHeader [header11="Default Value"] Optional basic Parameter with description and default value. - * @apiHeader [header12="Default Value"] - * - * @apiHeader {String} [header13] Optional Parameter with type and description. - * @apiHeader {String} [header14] - * @apiHeader {String} [header15="Default Value"] Optional Parameter with type, description and default value. - * @apiHeader {String} [header16="Default Value"] - */ diff --git a/test/fixtures/example/header.md b/test/fixtures/example/header.md deleted file mode 100644 index b68a6964..00000000 --- a/test/fixtures/example/header.md +++ /dev/null @@ -1,3 +0,0 @@ -# Header .md File - -Content of header.md file. diff --git a/test/fixtures/example/header_example.js b/test/fixtures/example/header_example.js deleted file mode 100644 index 7a971cb3..00000000 --- a/test/fixtures/example/header_example.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @api {get} /header/example/ Header Example - * @apiName GetHeaderExample - * @apiGroup Header - * @apiVersion 0.5.0 - * @apiDescription Usage of @headerExample. - * - * @apiHeaderExample An example: - * curl -i http://localhost/header/example/ - */ diff --git a/test/fixtures/example/header_structure.js b/test/fixtures/example/header_structure.js deleted file mode 100644 index d851a522..00000000 --- a/test/fixtures/example/header_structure.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Use of multiple HeaderStructures. - */ - -/** - * @apiDefineHeaderStructure Header1 - * - * @apiHeader Header1 This is Header 1. - */ - -/** - * @apiDefineHeaderStructure Header2 - * - * @apiHeader header2 This is Header 2. - */ - -/** - * @api {post} /test/header Header Structure - * @apiName PostHeader - * @apiGroup Header - * @apiVersion 0.5.0 - * @apiDescription Use of multiple HeaderStructures. - * - * @apiHeaderStructure Header1 - * @apiHeaderStructure Header2 - * - * @apiHeader Header3 This is Header 3 (local). - */ diff --git a/test/fixtures/example/header_title.js b/test/fixtures/example/header_title.js deleted file mode 100644 index e6dece31..00000000 --- a/test/fixtures/example/header_title.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @api {get} /header/title/ Header Title - * @apiName GetHeaderTitle - * @apiGroup Header - * @apiVersion 0.5.0 - * @apiDescription Usage of @apiHeaderTitle. - * - * @apiHeaderTitle (MyHeaderGroup) This are the Parameters for MyGroup: - * @apiHeader (MyHeaderGroup) authorization The authorization code. - * @apiHeader (MyHeaderGroup) {string} text Some text. - */ diff --git a/test/fixtures/example/language.coffee b/test/fixtures/example/language.coffee deleted file mode 100644 index 9f6646d8..00000000 --- a/test/fixtures/example/language.coffee +++ /dev/null @@ -1,35 +0,0 @@ -# Test for programming language: CoffeeScript - -### -@api {get} /language/coffeescript CoffeeScript -@apiName GetLanguageCoffeeScript -@apiGroup Language -@apiVersion 0.4.0 -@apiDescription Test for CoffeeScript Comment-Syntax. -### - -### - @api {get} /language/coffeescript/indented1 CoffeeScript indented 1 - @apiName GetLanguageCoffeeScriptIndented1 - @apiGroup Language - @apiVersion 0.4.0 - @apiExample Test for indented comment. - This is example line 2. - This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. - This is example line 6. -### - -### -@api {get} /language/coffeescript/indented2 CoffeeScript indented 2 -@apiName GetLanguageCoffeeScriptIndented2 -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -### diff --git a/test/fixtures/example/language.erl b/test/fixtures/example/language.erl deleted file mode 100644 index fea418e9..00000000 --- a/test/fixtures/example/language.erl +++ /dev/null @@ -1,35 +0,0 @@ -% Test for programming language: Erlang - -%{ -@api {get} /language/erlang Erlang -@apiName GetLanguageErlang -@apiGroup Language -@apiVersion 0.4.0 -@apiDescription Test for Erlang Comment-Syntax. -%} - -%{ -% @api {get} /language/erlang/indented1 Erlang indented 1 -% @apiName GetLanguageErlangIndented1 -% @apiGroup Language -% @apiVersion 0.4.0 -% @apiExample Test for indented comment. -% This is example line 2. -% This is example line 3. -% Line 4 indented (with tab at beginning). -% Line 5 indented. -% This is example line 6. -%} - -%{ -@api {get} /language/erlang/indented2 Erlang indented 2 -@apiName GetLanguageErlangIndented2 -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -%} diff --git a/test/fixtures/example/language.js b/test/fixtures/example/language.js deleted file mode 100644 index 5408f581..00000000 --- a/test/fixtures/example/language.js +++ /dev/null @@ -1,35 +0,0 @@ -// Test for programming language: JavaScript - -/** - * @api {get} /language/javascript JavaScript - * @apiName GetLanguageJavaScript - * @apiGroup Language - * @apiVersion 0.4.0 - * @apiDescription Test for JavaScript Comment-Syntax. - */ - -/** - * @api {get} /language/javascript/indented1 JavaScript indented 1 - * @apiName GetLanguageJavaScriptIndented1 - * @apiGroup Language - * @apiVersion 0.4.0 - * @apiExample Test for indented comment. - * This is example line 2. - * This is example line 3. - * Line 4 indented (with tab at beginning). - * Line 5 indented. - * This is example line 6. - */ - -/** -@api {get} /language/javascript/indented2 JavaScript indented 2 -@apiName GetLanguageJavaScriptIndented2 -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -*/ diff --git a/test/fixtures/example/language.pm b/test/fixtures/example/language.pm deleted file mode 100644 index 98f5c59c..00000000 --- a/test/fixtures/example/language.pm +++ /dev/null @@ -1,48 +0,0 @@ -# Test for programming language: Perl - -#** -# @api {get} /language/perl Perl -# @apiName GetLanguagePerl -# @apiGroup Language -# @apiVersion 0.4.0 -# @apiDescription Test for Perl Comment-Syntax. -#* - -#** -# @api {get} /language/perl/indented1 Perl indented 1 -# @apiName GetLanguagePerlIndented1 -# @apiGroup Language -# @apiVersion 0.4.0 -# @apiExample Test for indented comment. -# This is example line 2. -# This is example line 3. -# Line 4 indented (with tab at beginning). -# Line 5 indented. -# This is example line 6. -#* - -#** -@api {get} /language/perl/indented2 Perl indented 2 -@apiName GetLanguagePerlIndented2 -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -#* - -=pod -@api {get} /language/perl/podcut Perl comment with pod and cut -@apiName GetLanguagePerlPodCut -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -=cut diff --git a/test/fixtures/example/language.py b/test/fixtures/example/language.py deleted file mode 100644 index 3fcdcdac..00000000 --- a/test/fixtures/example/language.py +++ /dev/null @@ -1,35 +0,0 @@ -# Test for programming language: Python - -""" -@api {get} /language/python Python -@apiName GetLanguagePython -@apiGroup Language -@apiVersion 0.4.0 -@apiDescription Test for Python Comment-Syntax. -""" - -""" - @api {get} /language/python/indented1 Python indented 1 - @apiName GetLanguagePythonIndented1 - @apiGroup Language - @apiVersion 0.4.0 - @apiExample Test for indented comment. - This is example line 2. - This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. - This is example line 6. -""" - -""" -@api {get} /language/python/indented2 Python indented 2 -@apiName GetLanguagePythonIndented2 -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -""" diff --git a/test/fixtures/example/language.rb b/test/fixtures/example/language.rb deleted file mode 100644 index 99680c69..00000000 --- a/test/fixtures/example/language.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Test for programming language: Ruby - -=begin -@api {get} /language/ruby Ruby -@apiName GetLanguageRuby -@apiGroup Language -@apiVersion 0.4.0 -@apiDescription Test for Ruby Comment-Syntax. -=end - -=begin - @api {get} /language/ruby/indented1 Ruby indented 1 - @apiName GetLanguageRubyIndented1 - @apiGroup Language - @apiVersion 0.4.0 - @apiExample Test for indented comment. - This is example line 2. - This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. - This is example line 6. -=end - -=begin -@api {get} /language/ruby/indented2 Ruby indented 2 -@apiName GetLanguageRubyIndented2 -@apiGroup Language -@apiVersion 0.4.0 -@apiExample Test for indented comment. -This is example line 2. -This is example line 3. - Line 4 indented (with tab at beginning). - Line 5 indented. -This is example line 6. -=end diff --git a/test/fixtures/example/markdown.js b/test/fixtures/example/markdown.js deleted file mode 100644 index b0ca6a72..00000000 --- a/test/fixtures/example/markdown.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @api {get} /markdown/:id Markdown - * @apiName GetMarkdown - * @apiGroup Markdown - * @apiVersion 0.6.0 - * @apiDescription Enable markdown for all description fields. - * - * This **text** is in a __separate__ p. - * - * * List 1 - * * List 2 - * - * Multiline markdown text, - * output in one line. - * - * @apiParam {String} param1 This is a markdown **apiParam** - * - * Separate line. - */ diff --git a/test/fixtures/example/param.js b/test/fixtures/example/param.js deleted file mode 100644 index 9be2530d..00000000 --- a/test/fixtures/example/param.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @api {get} /param/:id Parameters - * @apiName GetParam - * @apiGroup Param - * @apiVersion 0.1.1 - * @apiDescription Parameters and different Versions: 0.1.1 - * - * @apiParam param1 Parameter and description. - * @apiParam param2 - * @apiParam param3="Default Value" Parameter, default value and description. - * @apiParam param4="Default Value" - * - * @apiParam [param5] Optional parameter and description. - * @apiParam [param6] - * @apiParam [param7="Default Value"] Optional parameter, default value and description. - * @apiParam [param8="Default Value"] - * - * @apiParam {String} param9 Type, parameter and description. - * @apiParam {String} param10 - * @apiParam {String} param11="Default Value" Type, parameter and default value. - * @apiParam {String} param12="Default Value" - * - * @apiParam {String} [param13] Type, optional parameter and description. - * @apiParam {String} [param14] - * @apiParam {String} [param15="Default Value"] Type, optional parameter, default value and description. - * @apiParam {String} [param26="Default Value"] - * - * @apiParam {String{4,8}} param17 Type, size, parameter and description. - * @apiParam {Number{1-3}} param18 Type, size, parameter and description. - * @apiParam {String{4,8}} param19="Default Value" Type, size, parameter, default value and description. - * @apiParam {Number{1-3}} param20=1 Type, size, parameter, default value and description. - * - * @apiParam {String="value 1"} param21 Type, parameter and allowed string value. - * @apiParam {String="value 1", "value 2"} param22 Type, parameter and allowed list of string values. - * @apiParam {Number=4711} param23 Type, parameter and allowed value. - * @apiParam {Number=4711,4712} param24 Type, parameter and allowed list of values. - * - * @apiParam {String{1,10}="value 1"} param25 Type, size, parameter and allowed string value. - * @apiParam {String{1,10}="value 1", "value 2"} param26 Type, size, parameter and allowed list of string values. - * @apiParam {Number{1-9999}=4711} param27 Type, size, parameter and allowed value. - * @apiParam {Number{1-9999}=4711,4712} param28 Type, size, parameter and allowed list of values. - */ - -/** - * @api {get} /param/:id Parameters - * @apiName GetParam - * @apiGroup Param - * @apiVersion 0.1.0 - * @apiDescription Parameters and different Versions: 0.1.0 - * - * @apiParam {String} param0 This param is removed in 0.1.1. - * @apiParam {String} param1 This is an old text. - * @apiParam {String} param2 - * @apiParam {String} param3="Default Value" Parameter with type, description and default value. - * @apiParam {String} param4="Default Value" - * - * @apiParam param5 Basic Parameter with description. - * @apiParam param6 - * @apiParam param7="Default Value" Basic Parameter with description and default value. - * @apiParam param8="Default Value" - * - * @apiParam [param9] Optional basic Parameter with description. - * @apiParam [param10] - * @apiParam [param11="Default Value"] Optional basic Parameter with description and default value. - * @apiParam [param12="Default Value"] - * - * @apiParam {String} [param13] Optional Parameter with type and description. - * @apiParam {String} [param14] - * @apiParam {String} [param15="Default Value"] Optional Parameter with type, description and default value. - * @apiParam {String} [param16="Default Value"] - */ diff --git a/test/fixtures/example/param_example.js b/test/fixtures/example/param_example.js deleted file mode 100644 index 9c2e6f9c..00000000 --- a/test/fixtures/example/param_example.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @api {get} /param/example/ Param Example - * @apiName GetParamExample - * @apiGroup Param - * @apiVersion 0.8.0 - * @apiDescription Usage of @apiParamExample. - * - * @apiExample A common example: - * curl -i http://localhost/param/example/ - * - * @apiParam {String} name Fullname. - * @apiParamExample {json} A JSON example: - * { - * "name": "John Doe" - * } - */ diff --git a/test/fixtures/example/param_title.js b/test/fixtures/example/param_title.js deleted file mode 100644 index 3cb2ced1..00000000 --- a/test/fixtures/example/param_title.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @api {get} /param/title/ Param Title - * @apiName GetParamTitle - * @apiGroup Param - * @apiVersion 0.8.0 - * @apiDescription Usage of @apiParamTitle. - * - * @apiParamTitle (ParamTitleGroupname) Parameters only for admin users: - * @apiParam (ParamTitleGroupname) {String} newPassword New password. - * @apiParam (ParamTitleGroupname) {String} userId Change password of that user. - */ diff --git a/test/fixtures/example/permission.js b/test/fixtures/example/permission.js deleted file mode 100644 index c154ebea..00000000 --- a/test/fixtures/example/permission.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @apiDefinePermission permission_admin Admin access. - */ - -/** - * @apiDefinePermission permission_user User access. - */ - -/** - * @api {get} /permission/ Permission - * @apiName GetPermission - * @apiGroup Permission - * @apiVersion 0.8.0 - * @apiDescription @apiPermission test. - * @apiPermission permission_admin - */ - -/** - * @api {get} /permission/ Permission - * @apiName GetPermission - * @apiGroup Permission - * @apiVersion 0.8.0 - * @apiDescription @apiPermission test. - * @apiPermission permission_admin - * @apiPermission permission_user - */ diff --git a/test/fixtures/example/sample_request.js b/test/fixtures/example/sample_request.js deleted file mode 100644 index 504775b6..00000000 --- a/test/fixtures/example/sample_request.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @api {get} /sample/request/ Sampe Request - * @apiName GetSampleRequest - * @apiGroup Sample - * @apiVersion 0.8.0 - * @apiDescription Usage of many @apiHeaderTitle with different parameters. - * - * @apiHeaderTitle (HeaderGroup1) This are the Header for Group 1: - * @apiHeader (HeaderGroup1) {string} authorization The authorization code. - * @apiHeader (HeaderGroup1) {string} secrect Additional secret. - * - * @apiHeaderTitle (HeaderGroup2) This are the Header for Group 2: - * @apiHeader (HeaderGroup2) {string} authorization The authorization code. - * @apiHeader (HeaderGroup2) {string} secrect Additional secret. - * @apiHeader (HeaderGroup2) {string} type Content-Type. - * - * @apiParamTitle (ParameterGroup1) This are Parameter for Group 1: - * @apiParam (ParameterGroup1) {String} name Your name. - * - * @apiParamTitle (ParameterGroup2) This are Parameter for Group 2: - * @apiParam (ParameterGroup2) {string} firstname Your firstname. - * @apiParam (ParameterGroup2) {string} lastname Some lastname. - */ diff --git a/test/fixtures/example/structure.js b/test/fixtures/example/structure.js deleted file mode 100644 index 78e4b0f6..00000000 --- a/test/fixtures/example/structure.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Use of multiple Structures. - */ - -/** - * @apiDefineStructure Structure1 - * - * @apiParam field1 This is Field 1. - */ - -/** - * @apiDefineStructure Structure2 - * - * @apiParam field2 This is Field 2. - */ - -/** - * @api {post} /test/structure Multiple Structures - * @apiName PostStructure - * @apiGroup Structure - * @apiVersion 0.1.0 - * @apiDescription Use of multiple Structures. - * - * @apiStructure Structure1 - * @apiStructure Structure2 - * - * @apiParam field3 This is Field 3 (local). - */ diff --git a/test/fixtures/example/success_structure.js b/test/fixtures/example/success_structure.js deleted file mode 100644 index dd17c952..00000000 --- a/test/fixtures/example/success_structure.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Use of multiple SuccessStructures. - */ - -/** - * @apiDefineSuccessStructure Success1 - * - * @apiSuccess success1 This is Success 1. - */ - -/** - * @apiDefineSuccessStructure Success2 - * - * @apiSuccess success2 This is Success 2. - */ - -/** - * @api {post} /test/success Multiple Success Structures - * @apiName PostSuccess - * @apiGroup Success - * @apiVersion 0.1.0 - * @apiDescription Use of multiple SuccessStructures. - * - * @apiSuccessStructure Success1 - * @apiSuccessStructure Success2 - * - * @apiSuccess success3 This is Success 3 (local). - */ diff --git a/test/fixtures/example/title_and_structure.js b/test/fixtures/example/title_and_structure.js deleted file mode 100644 index 200b9a4e..00000000 --- a/test/fixtures/example/title_and_structure.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Use of Title and Structures in the same block. - */ - -/** - * @apiDefineErrorStructure TitleAndError1 - * - * @apiError error1Error This is Error 1. - */ - -/** - * @api {post} /test/title_and_error Title and Structure - * @apiName PostTitleAndError - * @apiGroup Error - * @apiVersion 0.1.0 - * @apiDescription Use of Title and Structures in the same block. - * - * @apiSuccessTitle (204) 204 No Content. Added to global namespace. - * @apiSuccess (204) message Successfully deleted. - * - * @apiErrorStructure TitleAndError1 - * - * @apiError error3Error This is Error 3 (local). - */ diff --git a/test/fixtures/index.html b/test/fixtures/index.html deleted file mode 100644 index af3a3817..00000000 --- a/test/fixtures/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - apiDoc - - - - - -Empty Test Template. - - - \ No newline at end of file diff --git a/test/parser_api_param_test.js b/test/parser_api_param_test.js deleted file mode 100644 index 0c7c8e53..00000000 --- a/test/parser_api_param_test.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Test: Parser apiParam - */ - -// Node Module -var should = require('should'); - -// Lib Module -var parser = require('../lib/parsers/api_param'); - -/* -------------------------------------------------------------------------------- - * Tests - * -------------------------------------------------------------------------------- */ -describe('Parser: apiParam', function() { - - // TODO: Add 1.000 more possible cases ;-) - var testCases = [ - { - title: 'Simple fieldname only', - content: 'simple', - expected: { - group: 'Parameter', - type: undefined, - size: undefined, - allowedValues: undefined, - optional: false, - field: 'simple', - defaultValue: undefined, - description: '' - } - }, - { - title: 'Type, Fieldname, Description', - content: '{String} name The users name.', - expected: { - group: 'Parameter', - type: 'String', - size: undefined, - allowedValues: undefined, - optional: false, - field: 'name', - defaultValue: undefined, - description: 'The users name.' - } - }, - { - title: 'All options, with optional defaultValue', - content: ' ( MyGroup ) { \\Object\\String.uni-code_char[] { 1..10 } = \'abc\', \'def\' } ' + - '[ \\MyClass\\field.user_first-name = \'John Doe\' ] Some description.', - expected: { - group: 'MyGroup', - type: '\\Object\\String.uni-code_char[]', - size: '1..10', - allowedValues: [ '\'abc\'', '\'def\'' ], - optional: true, - field: '\\MyClass\\field.user_first-name', - defaultValue: 'John Doe', - description: 'Some description.' - } - }, - { - title: 'All options, without optional-marker', - content: ' ( MyGroup ) { \\Object\\String.uni-code_char[] { 1..10 } = \'abc\', \'def\' } ' + - '\\MyClass\\field.user_first-name = \'John Doe\' Some description.', - expected: { - group: 'MyGroup', - type: '\\Object\\String.uni-code_char[]', - size: '1..10', - allowedValues: [ '\'abc\'', '\'def\'' ], - optional: false, - field: '\\MyClass\\field.user_first-name', - defaultValue: 'John Doe', - description: 'Some description.' - } - }, - { - title: 'All options, without optional-marker, without default value quotes', - content: ' ( MyGroup ) { \\Object\\String.uni-code_char[] { 1..10 } = \'abc\', \'def\' } ' + - '\\MyClass\\field.user_first-name = John_Doe Some description.', - expected: { - group: 'MyGroup', - type: '\\Object\\String.uni-code_char[]', - size: '1..10', - allowedValues: [ '\'abc\'', '\'def\'' ], - optional: false, - field: '\\MyClass\\field.user_first-name', - defaultValue: 'John_Doe', - description: 'Some description.' - } - }, - ]; - - // create - it('case 1: should pass all regexp test cases', function(done) { - testCases.forEach(function(testCase) { - var parsed = parser.parse(testCase.content); - (parsed !== null).should.equal(true, 'Title: ' + testCase.title + ', Source: ' + testCase.content); - parsed.should.eql(testCase.expected); - }); - done(); - }); - -});