123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834 |
- /*
- Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
- Copyright (C) 2014 Dan Tao <daniel.tao@gmail.com>
- Copyright (C) 2013 Andrew Eisenberg <andrew@eisenberg.as>
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- (function () {
- 'use strict';
-
- var typed,
- utility,
- isArray,
- jsdoc,
- esutils,
- hasOwnProperty;
-
- esutils = require('esutils');
- isArray = require('isarray');
- typed = require('./typed');
- utility = require('./utility');
-
- function sliceSource(source, index, last) {
- return source.slice(index, last);
- }
-
- hasOwnProperty = (function () {
- var func = Object.prototype.hasOwnProperty;
- return function hasOwnProperty(obj, name) {
- return func.call(obj, name);
- };
- }());
-
- function shallowCopy(obj) {
- var ret = {}, key;
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- ret[key] = obj[key];
- }
- }
- return ret;
- }
-
- function isASCIIAlphanumeric(ch) {
- return (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) ||
- (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) ||
- (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */);
- }
-
- function isParamTitle(title) {
- return title === 'param' || title === 'argument' || title === 'arg';
- }
-
- function isReturnTitle(title) {
- return title === 'return' || title === 'returns';
- }
-
- function isProperty(title) {
- return title === 'property' || title === 'prop';
- }
-
- function isNameParameterRequired(title) {
- return isParamTitle(title) || isProperty(title) ||
- title === 'alias' || title === 'this' || title === 'mixes' || title === 'requires';
- }
-
- function isAllowedName(title) {
- return isNameParameterRequired(title) || title === 'const' || title === 'constant';
- }
-
- function isAllowedNested(title) {
- return isProperty(title) || isParamTitle(title);
- }
-
- function isTypeParameterRequired(title) {
- return isParamTitle(title) || isReturnTitle(title) ||
- title === 'define' || title === 'enum' ||
- title === 'implements' || title === 'this' ||
- title === 'type' || title === 'typedef' || isProperty(title);
- }
-
- // Consider deprecation instead using 'isTypeParameterRequired' and 'Rules' declaration to pick when a type is optional/required
- // This would require changes to 'parseType'
- function isAllowedType(title) {
- return isTypeParameterRequired(title) || title === 'throws' || title === 'const' || title === 'constant' ||
- title === 'namespace' || title === 'member' || title === 'var' || title === 'module' ||
- title === 'constructor' || title === 'class' || title === 'extends' || title === 'augments' ||
- title === 'public' || title === 'private' || title === 'protected';
- }
-
- function trim(str) {
- return str.replace(/^\s+/, '').replace(/\s+$/, '');
- }
-
- function unwrapComment(doc) {
- // JSDoc comment is following form
- // /**
- // * .......
- // */
- // remove /**, */ and *
- var BEFORE_STAR = 0,
- STAR = 1,
- AFTER_STAR = 2,
- index,
- len,
- mode,
- result,
- ch;
-
- doc = doc.replace(/^\/\*\*?/, '').replace(/\*\/$/, '');
- index = 0;
- len = doc.length;
- mode = BEFORE_STAR;
- result = '';
-
- while (index < len) {
- ch = doc.charCodeAt(index);
- switch (mode) {
- case BEFORE_STAR:
- if (esutils.code.isLineTerminator(ch)) {
- result += String.fromCharCode(ch);
- } else if (ch === 0x2A /* '*' */) {
- mode = STAR;
- } else if (!esutils.code.isWhiteSpace(ch)) {
- result += String.fromCharCode(ch);
- mode = AFTER_STAR;
- }
- break;
-
- case STAR:
- if (!esutils.code.isWhiteSpace(ch)) {
- result += String.fromCharCode(ch);
- }
- mode = esutils.code.isLineTerminator(ch) ? BEFORE_STAR : AFTER_STAR;
- break;
-
- case AFTER_STAR:
- result += String.fromCharCode(ch);
- if (esutils.code.isLineTerminator(ch)) {
- mode = BEFORE_STAR;
- }
- break;
- }
- index += 1;
- }
-
- return result.replace(/\s+$/, '');
- }
-
- // JSDoc Tag Parser
-
- (function (exports) {
- var Rules,
- index,
- lineNumber,
- length,
- source,
- recoverable,
- sloppy,
- strict;
-
- function advance() {
- var ch = source.charCodeAt(index);
- index += 1;
- if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(index) === 0x0A /* '\n' */)) {
- lineNumber += 1;
- }
- return String.fromCharCode(ch);
- }
-
- function scanTitle() {
- var title = '';
- // waste '@'
- advance();
-
- while (index < length && isASCIIAlphanumeric(source.charCodeAt(index))) {
- title += advance();
- }
-
- return title;
- }
-
- function seekContent() {
- var ch, waiting, last = index;
-
- waiting = false;
- while (last < length) {
- ch = source.charCodeAt(last);
- if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(last + 1) === 0x0A /* '\n' */)) {
- waiting = true;
- } else if (waiting) {
- if (ch === 0x40 /* '@' */) {
- break;
- }
- if (!esutils.code.isWhiteSpace(ch)) {
- waiting = false;
- }
- }
- last += 1;
- }
- return last;
- }
-
- // type expression may have nest brace, such as,
- // { { ok: string } }
- //
- // therefore, scanning type expression with balancing braces.
- function parseType(title, last) {
- var ch, brace, type, direct = false;
-
-
- // search '{'
- while (index < last) {
- ch = source.charCodeAt(index);
- if (esutils.code.isWhiteSpace(ch)) {
- advance();
- } else if (ch === 0x7B /* '{' */) {
- advance();
- break;
- } else {
- // this is direct pattern
- direct = true;
- break;
- }
- }
-
-
- if (direct) {
- return null;
- }
-
- // type expression { is found
- brace = 1;
- type = '';
- while (index < last) {
- ch = source.charCodeAt(index);
- if (esutils.code.isLineTerminator(ch)) {
- advance();
- } else {
- if (ch === 0x7D /* '}' */) {
- brace -= 1;
- if (brace === 0) {
- advance();
- break;
- }
- } else if (ch === 0x7B /* '{' */) {
- brace += 1;
- }
- type += advance();
- }
- }
-
- if (brace !== 0) {
- // braces is not balanced
- return utility.throwError('Braces are not balanced');
- }
-
- if (isParamTitle(title)) {
- return typed.parseParamType(type);
- }
- return typed.parseType(type);
- }
-
- function scanIdentifier(last) {
- var identifier;
- if (!esutils.code.isIdentifierStart(source.charCodeAt(index))) {
- return null;
- }
- identifier = advance();
- while (index < last && esutils.code.isIdentifierPart(source.charCodeAt(index))) {
- identifier += advance();
- }
- return identifier;
- }
-
- function skipWhiteSpace(last) {
- while (index < last && (esutils.code.isWhiteSpace(source.charCodeAt(index)) || esutils.code.isLineTerminator(source.charCodeAt(index)))) {
- advance();
- }
- }
-
- function parseName(last, allowBrackets, allowNestedParams) {
- var name = '', useBrackets;
-
- skipWhiteSpace(last);
-
- if (index >= last) {
- return null;
- }
-
- if (allowBrackets && source.charCodeAt(index) === 0x5B /* '[' */) {
- useBrackets = true;
- name = advance();
- }
-
- if (!esutils.code.isIdentifierStart(source.charCodeAt(index))) {
- return null;
- }
-
- name += scanIdentifier(last);
-
- if (allowNestedParams) {
- if (source.charCodeAt(index) === 0x3A /* ':' */ && (
- name === 'module' ||
- name === 'external' ||
- name === 'event')) {
- name += advance();
- name += scanIdentifier(last);
-
- }
- if(source.charCodeAt(index) === 0x5B /* '[' */ && source.charCodeAt(index + 1) === 0x5D /* ']' */){
- name += advance();
- name += advance();
- }
- while (source.charCodeAt(index) === 0x2E /* '.' */ ||
- source.charCodeAt(index) === 0x23 /* '#' */ ||
- source.charCodeAt(index) === 0x7E /* '~' */) {
- name += advance();
- name += scanIdentifier(last);
- }
- }
-
- if (useBrackets) {
-
-
- // do we have a default value for this?
- if (source.charCodeAt(index) === 0x3D /* '=' */) {
- // consume the '='' symbol
- name += advance();
- var bracketDepth = 1;
- // scan in the default value
- while (index < last) {
- if (source.charCodeAt(index) === 0x5B /* '[' */) {
- bracketDepth++;
- } else if (source.charCodeAt(index) === 0x5D /* ']' */ &&
- --bracketDepth === 0) {
- break;
- }
- name += advance();
- }
- }
-
- if (index >= last || source.charCodeAt(index) !== 0x5D /* ']' */) {
- // we never found a closing ']'
- return null;
- }
-
- // collect the last ']'
- name += advance();
- }
-
- return name;
- }
-
- function skipToTag() {
- while (index < length && source.charCodeAt(index) !== 0x40 /* '@' */) {
- advance();
- }
- if (index >= length) {
- return false;
- }
- utility.assert(source.charCodeAt(index) === 0x40 /* '@' */);
- return true;
- }
-
- function TagParser(options, title) {
- this._options = options;
- this._title = title;
- this._tag = {
- title: title,
- description: null
- };
- if (this._options.lineNumbers) {
- this._tag.lineNumber = lineNumber;
- }
- this._last = 0;
- // space to save special information for title parsers.
- this._extra = { };
- }
-
- // addError(err, ...)
- TagParser.prototype.addError = function addError(errorText) {
- var args = Array.prototype.slice.call(arguments, 1),
- msg = errorText.replace(
- /%(\d)/g,
- function (whole, index) {
- utility.assert(index < args.length, 'Message reference must be in range');
- return args[index];
- }
- );
-
- if (!this._tag.errors) {
- this._tag.errors = [];
- }
- if (strict) {
- utility.throwError(msg);
- }
- this._tag.errors.push(msg);
- return recoverable;
- };
-
- TagParser.prototype.parseType = function () {
- // type required titles
- if (isTypeParameterRequired(this._title)) {
- try {
- this._tag.type = parseType(this._title, this._last);
- if (!this._tag.type) {
- if (!isParamTitle(this._title) && !isReturnTitle(this._title)) {
- if (!this.addError('Missing or invalid tag type')) {
- return false;
- }
- }
- }
- } catch (error) {
- this._tag.type = null;
- if (!this.addError(error.message)) {
- return false;
- }
- }
- } else if (isAllowedType(this._title)) {
- // optional types
- try {
- this._tag.type = parseType(this._title, this._last);
- } catch (e) {
- //For optional types, lets drop the thrown error when we hit the end of the file
- }
- }
- return true;
- };
-
- TagParser.prototype._parseNamePath = function (optional) {
- var name;
- name = parseName(this._last, sloppy && isParamTitle(this._title), true);
- if (!name) {
- if (!optional) {
- if (!this.addError('Missing or invalid tag name')) {
- return false;
- }
- }
- }
- this._tag.name = name;
- return true;
- };
-
- TagParser.prototype.parseNamePath = function () {
- return this._parseNamePath(false);
- };
-
- TagParser.prototype.parseNamePathOptional = function () {
- return this._parseNamePath(true);
- };
-
-
- TagParser.prototype.parseName = function () {
- var assign, name;
-
- // param, property requires name
- if (isAllowedName(this._title)) {
- this._tag.name = parseName(this._last, sloppy && isParamTitle(this._title), isAllowedNested(this._title));
- if (!this._tag.name) {
- if (!isNameParameterRequired(this._title)) {
- return true;
- }
-
- // it's possible the name has already been parsed but interpreted as a type
- // it's also possible this is a sloppy declaration, in which case it will be
- // fixed at the end
- if (isParamTitle(this._title) && this._tag.type && this._tag.type.name) {
- this._extra.name = this._tag.type;
- this._tag.name = this._tag.type.name;
- this._tag.type = null;
- } else {
- if (!this.addError('Missing or invalid tag name')) {
- return false;
- }
- }
- } else {
- name = this._tag.name;
- if (name.charAt(0) === '[' && name.charAt(name.length - 1) === ']') {
- // extract the default value if there is one
- // example: @param {string} [somebody=John Doe] description
- assign = name.substring(1, name.length - 1).split('=');
- if (assign[1]) {
- this._tag['default'] = assign[1];
- }
- this._tag.name = assign[0];
-
- // convert to an optional type
- if (this._tag.type && this._tag.type.type !== 'OptionalType') {
- this._tag.type = {
- type: 'OptionalType',
- expression: this._tag.type
- };
- }
- }
- }
- }
-
- return true;
- };
-
- TagParser.prototype.parseDescription = function parseDescription() {
- var description = trim(sliceSource(source, index, this._last));
- if (description) {
- if ((/^-\s+/).test(description)) {
- description = description.substring(2);
- }
- this._tag.description = description;
- }
- return true;
- };
-
- TagParser.prototype.parseKind = function parseKind() {
- var kind, kinds;
- kinds = {
- 'class': true,
- 'constant': true,
- 'event': true,
- 'external': true,
- 'file': true,
- 'function': true,
- 'member': true,
- 'mixin': true,
- 'module': true,
- 'namespace': true,
- 'typedef': true
- };
- kind = trim(sliceSource(source, index, this._last));
- this._tag.kind = kind;
- if (!hasOwnProperty(kinds, kind)) {
- if (!this.addError('Invalid kind name \'%0\'', kind)) {
- return false;
- }
- }
- return true;
- };
-
- TagParser.prototype.parseAccess = function parseAccess() {
- var access;
- access = trim(sliceSource(source, index, this._last));
- this._tag.access = access;
- if (access !== 'private' && access !== 'protected' && access !== 'public') {
- if (!this.addError('Invalid access name \'%0\'', access)) {
- return false;
- }
- }
- return true;
- };
-
- TagParser.prototype.parseVariation = function parseVariation() {
- var variation, text;
- text = trim(sliceSource(source, index, this._last));
- variation = parseFloat(text, 10);
- this._tag.variation = variation;
- if (isNaN(variation)) {
- if (!this.addError('Invalid variation \'%0\'', text)) {
- return false;
- }
- }
- return true;
- };
-
- TagParser.prototype.ensureEnd = function () {
- var shouldBeEmpty = trim(sliceSource(source, index, this._last));
- if (shouldBeEmpty) {
- if (!this.addError('Unknown content \'%0\'', shouldBeEmpty)) {
- return false;
- }
- }
- return true;
- };
-
- TagParser.prototype.epilogue = function epilogue() {
- var description;
-
- description = this._tag.description;
- // un-fix potentially sloppy declaration
- if (isParamTitle(this._title) && !this._tag.type && description && description.charAt(0) === '[') {
- this._tag.type = this._extra.name;
- if (!this._tag.name) {
- this._tag.name = undefined;
- }
-
- if (!sloppy) {
- if (!this.addError('Missing or invalid tag name')) {
- return false;
- }
- }
- }
-
- return true;
- };
-
- Rules = {
- // http://usejsdoc.org/tags-access.html
- 'access': ['parseAccess'],
- // http://usejsdoc.org/tags-alias.html
- 'alias': ['parseNamePath', 'ensureEnd'],
- // http://usejsdoc.org/tags-augments.html
- 'augments': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-constructor.html
- 'constructor': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // Synonym: http://usejsdoc.org/tags-constructor.html
- 'class': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // Synonym: http://usejsdoc.org/tags-extends.html
- 'extends': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-deprecated.html
- 'deprecated': ['parseDescription'],
- // http://usejsdoc.org/tags-global.html
- 'global': ['ensureEnd'],
- // http://usejsdoc.org/tags-inner.html
- 'inner': ['ensureEnd'],
- // http://usejsdoc.org/tags-instance.html
- 'instance': ['ensureEnd'],
- // http://usejsdoc.org/tags-kind.html
- 'kind': ['parseKind'],
- // http://usejsdoc.org/tags-mixes.html
- 'mixes': ['parseNamePath', 'ensureEnd'],
- // http://usejsdoc.org/tags-mixin.html
- 'mixin': ['parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-member.html
- 'member': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-method.html
- 'method': ['parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-module.html
- 'module': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // Synonym: http://usejsdoc.org/tags-method.html
- 'func': ['parseNamePathOptional', 'ensureEnd'],
- // Synonym: http://usejsdoc.org/tags-method.html
- 'function': ['parseNamePathOptional', 'ensureEnd'],
- // Synonym: http://usejsdoc.org/tags-member.html
- 'var': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-name.html
- 'name': ['parseNamePath', 'ensureEnd'],
- // http://usejsdoc.org/tags-namespace.html
- 'namespace': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
- // http://usejsdoc.org/tags-private.html
- 'private': ['parseType', 'parseDescription'],
- // http://usejsdoc.org/tags-protected.html
- 'protected': ['parseType', 'parseDescription'],
- // http://usejsdoc.org/tags-public.html
- 'public': ['parseType', 'parseDescription'],
- // http://usejsdoc.org/tags-readonly.html
- 'readonly': ['ensureEnd'],
- // http://usejsdoc.org/tags-requires.html
- 'requires': ['parseNamePath', 'ensureEnd'],
- // http://usejsdoc.org/tags-since.html
- 'since': ['parseDescription'],
- // http://usejsdoc.org/tags-static.html
- 'static': ['ensureEnd'],
- // http://usejsdoc.org/tags-summary.html
- 'summary': ['parseDescription'],
- // http://usejsdoc.org/tags-this.html
- 'this': ['parseNamePath', 'ensureEnd'],
- // http://usejsdoc.org/tags-todo.html
- 'todo': ['parseDescription'],
- // http://usejsdoc.org/tags-typedef.html
- 'typedef': ['parseType', 'parseNamePathOptional'],
- // http://usejsdoc.org/tags-variation.html
- 'variation': ['parseVariation'],
- // http://usejsdoc.org/tags-version.html
- 'version': ['parseDescription']
- };
-
- TagParser.prototype.parse = function parse() {
- var i, iz, sequences, method;
-
- // empty title
- if (!this._title) {
- if (!this.addError('Missing or invalid title')) {
- return null;
- }
- }
-
- // Seek to content last index.
- this._last = seekContent(this._title);
-
- if (hasOwnProperty(Rules, this._title)) {
- sequences = Rules[this._title];
- } else {
- // default sequences
- sequences = ['parseType', 'parseName', 'parseDescription', 'epilogue'];
- }
-
- for (i = 0, iz = sequences.length; i < iz; ++i) {
- method = sequences[i];
- if (!this[method]()) {
- return null;
- }
- }
-
- return this._tag;
- };
-
- function parseTag(options) {
- var title, parser, tag;
-
- // skip to tag
- if (!skipToTag()) {
- return null;
- }
-
- // scan title
- title = scanTitle();
-
- // construct tag parser
- parser = new TagParser(options, title);
- tag = parser.parse();
-
- // Seek global index to end of this tag.
- while (index < parser._last) {
- advance();
- }
- return tag;
- }
-
- //
- // Parse JSDoc
- //
-
- function scanJSDocDescription(preserveWhitespace) {
- var description = '', ch, atAllowed;
-
- atAllowed = true;
- while (index < length) {
- ch = source.charCodeAt(index);
-
- if (atAllowed && ch === 0x40 /* '@' */) {
- break;
- }
-
- if (esutils.code.isLineTerminator(ch)) {
- atAllowed = true;
- } else if (atAllowed && !esutils.code.isWhiteSpace(ch)) {
- atAllowed = false;
- }
-
- description += advance();
- }
-
- return preserveWhitespace ? description : trim(description);
- }
-
- function parse(comment, options) {
- var tags = [], tag, description, interestingTags, i, iz;
-
- if (options === undefined) {
- options = {};
- }
-
- if (typeof options.unwrap === 'boolean' && options.unwrap) {
- source = unwrapComment(comment);
- } else {
- source = comment;
- }
-
- // array of relevant tags
- if (options.tags) {
- if (isArray(options.tags)) {
- interestingTags = { };
- for (i = 0, iz = options.tags.length; i < iz; i++) {
- if (typeof options.tags[i] === 'string') {
- interestingTags[options.tags[i]] = true;
- } else {
- utility.throwError('Invalid "tags" parameter: ' + options.tags);
- }
- }
- } else {
- utility.throwError('Invalid "tags" parameter: ' + options.tags);
- }
- }
-
- length = source.length;
- index = 0;
- lineNumber = 0;
- recoverable = options.recoverable;
- sloppy = options.sloppy;
- strict = options.strict;
-
- description = scanJSDocDescription(options.preserveWhitespace);
-
- while (true) {
- tag = parseTag(options);
- if (!tag) {
- break;
- }
- if (!interestingTags || interestingTags.hasOwnProperty(tag.title)) {
- tags.push(tag);
- }
- }
-
- return {
- description: description,
- tags: tags
- };
- }
- exports.parse = parse;
- }(jsdoc = {}));
-
- exports.version = utility.VERSION;
- exports.parse = jsdoc.parse;
- exports.parseType = typed.parseType;
- exports.parseParamType = typed.parseParamType;
- exports.unwrapComment = unwrapComment;
- exports.Syntax = shallowCopy(typed.Syntax);
- exports.Error = utility.DoctrineError;
- exports.type = {
- Syntax: exports.Syntax,
- parseType: typed.parseType,
- parseParamType: typed.parseParamType,
- stringify: typed.stringify
- };
- }());
- /* vim: set sw=4 ts=4 et tw=80 : */
|