Generate Swagger documents
@api    private
@param  {Object} opt
7365
function generate(opt) {
  if (!opt) {
    throw new Error('\'option\' is required.');
  }

  if (!opt.swaggerUI) {
    throw new Error('\'swaggerUI\' is required.');
  }

  if (!opt.basePath) {
    throw new Error('\'basePath\' is required.');
  }

  descriptor.basePath = opt.basePath;
  descriptor.apiVersion = (opt.apiVersion) ? opt.apiVersion : '1.0';
  descriptor.swaggerVersion = (opt.swaggerVersion) ? opt.swaggerVersion : '1.0';
  descriptor.swaggerURL = (opt.swaggerURL) ? opt.swaggerURL : '/swagger';
  descriptor.swaggerJSON = (opt.swaggerJSON) ? opt.swaggerJSON : '/api-docs.json';
  descriptor.apis = [];

  if (opt.info) {
    descriptor.info = opt.info;
  }

  opt.apiVersion = descriptor.apiVersion;
  opt.swaggerVersion = descriptor.swaggerVersion;
  opt.swaggerURL = descriptor.swaggerURL;
  opt.swaggerJSON = descriptor.swaggerJSON;

  if (!opt.fullSwaggerJSONPath) {
    opt.fullSwaggerJSONPath = url.parse(opt.basePath + opt.swaggerJSON).path;
  }

  if (opt.apis) {
    opt.apis.forEach(function(api) {
      readApi(api, function(err) {
        if (err) {
          throw err;
        }
      });
    });
  }
}
706336
function create(data, opts) {
  const { html, reportOptions } = prepare(data, opts);
  const {
    saveJson,
    saveHtml,
    autoOpen,
    overwrite,
    jsonFile,
    htmlFile
  } = reportOptions;

  const savePromises = [];

  savePromises.push(saveHtml !== false
    ? saveFile(htmlFile, html, overwrite)
      .then(savedHtml => (autoOpen && openFile(savedHtml)) || savedHtml)
    : null);

  savePromises.push(saveJson
    ? saveFile(jsonFile, JSON.stringify(data, null, 2), overwrite)
    : null);

  return Promise.all(savePromises);
}
388371
function convertMarkdown(opts) {
  return new Promise((resolve, reject) => {
    marked(opts.data, {}, (err, content) => {
      if(err) return reject(err);
      return resolve(content);
    });
  });
}
463340
function generateDocs(specjs) {
  var docs = GENERATE_MODULE(specjs.MODULE, '');
  GENERATE_TYPE = (function(enums) { 
    return function(type) {
      return (_.contains(enums, type) ? ('Enum ' + type) : type);  
    }
  })(_.keys(specjs.ENUMS_BY_GROUP));
  docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) {
    return memo += GENERATE_METHOD(methodName, methodSpec);
  }, docs);
  docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) {
    return memo += GENERATE_ENUM(enumName, enumSpec);
  }, docs);
  if (_.isEmpty(specjs.CLASSGROUPS)) {
      docs += GENERATE_CLASSES(specjs.CLASSES);
  } else {
    docs += GENERATE_MODULE('common', '');
    var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
    var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
    docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common'); 
    _.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
      docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
    });
    // TODO: figure out why yuidoc won't associate the class with the right module if module definitions are interspersed
    _.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
        docs += GENERATE_MODULE(groupName, groupSpec.description);
    });
  }
  return docs;
}
455108
function generate(target, data, done) {
        var files = this.files,
            dest = null,
            paths = [],
            promises = [],
            folders = [];

        //by default, we generate a table of contents called readme.md
        var options = this.options({
            contentsEnabled: true,
            contentsFile: 'readme.md',
            contentsTitle: 'Documentation',
            templateDir: null
        });

        //map the list of files we'll be generating documentation for
        files.forEach(function(group) {
            dest = group.dest;
            group.src.filter(function(file) {
                var obj = {
                    filename: path.basename(file),
                    folder: path.dirname(file),
                    path: file
                };

                if(options.pathFilter)
                    obj.folder = obj.folder.replace(options.pathFilter, '');

                folders.push(obj);
            });
        });

        //map the set of folders, sort, and generate documentation
        folders = _(folders)
            .groupBy(function(p) { return p.folder; })
            .sortBy(function(p) { return p.length && p[0].folder; })
            .map(function(group) {
                var file = group.length && group[0] || {};
                return {
                    name: file.folder,
                    path: file.path.replace(file.filename, ''),
                    files: group,
                    fileData: {}
                };
            })
            .each(function(folder) {
                var def = Q.defer();

                //queue the promise for the docs, and ensure the target exists (can safely run on an existing folder)
                promises.push(def.promise);
                grunt.file.mkdir(dest +'/'+ folder.name);

                //generate the docs for the folder, resolving the promise when complete
                jsdox.generateForDir(folder.path, dest +'/'+ folder.name, options.templateDir, def.resolve, function(file, fileData) {
                    folder.fileData[file] = fileData;
                });
            });

        //when all docs have been generated, build the table of contents, if needed (this stuff should be moved into a template)
        Q.all(promises).then(function() {
            if(!options.contentsEnabled) return done();

            var buf = [],
                w = function() { buf.push.apply(buf, arguments); };

            w(options.contentsTitle || 'Documentation', '===');

            folders.forEach(function(folder) {
                var docs = [];

                //derive the set of documents we *actually* generated docs for; that way we only add documented
                //code to the table of contents
                folder.files.forEach(function(file) {
                    //reset the path, pointing to the markdown file, and set the file data parsed by jsdox
                    file.path = path.join(file.folder, file.filename.replace('.js', '')).replace(/^\//, '');
                    file.data = folder.fileData[file.filename]||{};
                    if(grunt.file.exists(dest, file.path + '.md')) docs.push(file);
                });

                if(docs.length > 0) {
                    w(folder.name || 'Root', '---');
                    w('name | overview', ':-- | :--');
                    docs.forEach(function(file) {
                        w('['+ file.path +'.js]('+ file.path + '.md' + ') | '+ (file.data.overview?'_'+ file.data.overview +'_':''));
                    });
                    w('- - -');
                }

                w('\n');
            });

            //write out the table of contents, and complete the async generate task
            fs.writeFileSync(path.join(dest, (options.contentsFile || 'readme.md')), buf.join('\n'));
            done();
        });
    }
964431
function esmangleify(opt) {

  // options is mostly the escodegen format
  var format = {
    renumber   : true,
    hexadecimal: true,
    escapeless : true,
    compact    : true,
    semicolons : false,
    parentheses: false
  }

  // fail silently allows us to process json (and other non js) files that make it through the transform process
  //  alternatively you could implement a options.filter
  var options = merge(format, {
    failSilently: true
  }, opt);

  // transform
  return esprimaTools.createTransform(updater, options);
}
834506
function signature(opt) {

  var options = opt || Object.create(null);
  var my = {
    header: String(options.header || 'Server'),
    signature: String(options.signature || 'Nodejs'),
    token: String(options.token || 'Full'),
    custom: options.custom,
    extra: options.extra,
    standalone: Boolean(options.standalone)
  };
  if (my.token == 'Full') {
    my.Prod = my.Major = my.Minor = my.Min = my.OS = true;
  } else if (my.token == 'OS') {
    my.Prod = my.Major = my.Minor = my.Min = my.OS = true;
  } else if (my.token == 'Min') {
    my.Prod = my.Major = my.Minor = my.Min = true;
  } else if (my.token == 'Minor') {
    my.Prod = my.Major = my.Minor = true;
  } else if (my.token == 'Major') {
    my.Prod = my.Major = true;
  } else if (my.token == 'Prod') {
    my.Prod = true;
  }
  return wrapper(my);
}
1094992
function (opt) {
    if (typeof opt !== "object" || opt === null) {
        opt = {};
    }
    if (typeof opt.tag !== "string") {
        opt.tag = null;
    }
    if (typeof opt.encoding !== "string") {
        opt.encoding = "utf8";
    }

    //Extends the readable stream
    stream.Readable.call(this, {encoding: opt.encoding});

    this._tag = (typeof opt.tag === "string") ? opt.tag.trim() : null;
    this._level = labels.length;
    this._disabled = false;

    //Default message format
    this._format = function (tag, label, text) {
        let list = [];
        if (tag) {
            //Add the tag if it is provided
            list.push("[" + tag + "]");
        }
        list.push("[" + timestamp("YYYY-MM-DD hh:mm:ss") + "]");
        list.push("[" + label.toUpperCase() + "]");
        list.push(text.trim());
        return list.join(" ");
    };

    return this;
}
598680
function (opts) {
    this.options = opts || {};
    this.pattern = null;
    this.middleware = {};
    this.includes = {};
    this.excludes = {};
    this.files = [];
    this.fns = [];

    options(this);
    iterators(this);
    symlinks(this);
    readers(this);
  }
1159944
function (opts, id) {
        let uri = this.classUrl
        if (id) {
          uri += '/' + id
        }

        return new Promise(function (resolve, reject) {
          new Requestor({ api_version: instance.api_version }).request({
            method: 'post',
            url: [Conekta.api_base, uri].join(''),
            data: opts.data || {},
            next: function (error, response) {
              if (!error) {
                response = this.listObjectsToArray(response)
                this._json = response
                this._id = response.id
                this.build_children()
              }
              if (opts.next !== undefined) {
                opts.next(error, this)
              } else {
                if (error) {
                  reject(error)
                } else {
                  resolve(this)
                }
              }
            }.bind(this)
          })
        }.bind(this))
      }
699136
function generate(spec) {
  createProjectDirectory();
  spec = addHttpEndpointNames(spec);
  spec = addSocketEndpointFlag(spec);
  spec = addSocketEmitTypeFlag(spec);
  spec = isProxyEndpointAvailable(spec);
  writeFileSync('server.mustache', spec, 'server.js');
  writeFileSync('package.mustache', spec, 'package.json');
}
1186560
function (opts) {
  var paths = es.through();
  var files = es.through();
  
  paths.pipe(es.writeArray(function (err, srcs) {
    gulp.src(srcs, opts).pipe(files);
  }));
  
  return es.duplex(paths, files);
}
257193
def create_doc(doc, opts = {})
      data, _status_code, _headers = create_doc_with_http_info(doc, opts)
      return data
    end
55248
public function generate_post_object_url($bucket, $object, $opt = array()) {
		$this->assertParameterArray ( $opt );
		return $this->generate_user_url ( "POST", $bucket, $object, $opt );
	}
40244
def to_json(opts={})
      hsh = self.to_ordered_hash(opts)
      if opts.fetch(:pretty, false)
        JSON.pretty_generate(hsh)
      else
        hsh.to_json
      end
    end
17751
function ngSwaggerGen(options) {
  if (typeof options.swagger != 'string') {
    console.error("Swagger file not specified in the 'swagger' option");
    process.exit(1);
  }

  var globalTunnel = require('global-tunnel-ng');
  globalTunnel.initialize();
  
  $RefParser.bundle(options.swagger, { dereference: { circular: false } }).then(
    data => {
      doGenerate(data, options);
    },
    err => {
      console.error(
        `Error reading swagger location ${options.swagger}: ${err}`
      );
    }
  ).catch(function (error) {
    console.error(`Error: ${error}`);
  });
}
1131207
function getOptions(rules, opts) {
	var dir;
	var obj = {
		source: opts.source,
		transform: opts.transform || function (val) {
			return val;
		}
	};

	obj.path = opts.path || [];
	obj.path = Array.isArray(obj.path) ? obj.path : [obj.path];

	if (rules.length && rules[0].position && rules[0].position.source) {
		dir = path.dirname(rules[0].position.source);
	}

	if (dir && obj.path.indexOf(dir) === -1) {
		obj.path.unshift(dir);
	}

	if (!obj.path.length) {
		obj.path.push(process.cwd());
	}

	return obj;
}