forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
A collection of functions relating to resolving @borrows tags in JSDoc symbols. | ||
@module jsdoc/borrow | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
*/ | ||
'use strict'; | ||
|
||
|
@@ -35,20 +35,20 @@ exports.resolveBorrows = function(docs) { | |
logger.error('Unable to resolve borrowed symbols, because the docs have not been indexed.'); | ||
return; | ||
} | ||
|
||
docs.forEach(function(doc) { | ||
if (doc.borrowed) { | ||
doc.borrowed.forEach(function(b, i) { | ||
var lent = docs.index[b.from], // lent is an array | ||
asName = b.as || b.from; | ||
|
||
if (lent) { | ||
var cloned = doop(lent); | ||
|
||
cloned.forEach(function(clone) { | ||
asName = asName.replace(/^prototype\./, '#'); | ||
var parts = asName.split('#'); | ||
|
||
if (parts.length === 2) { clone.scope = 'instance'; } | ||
else { clone.scope = 'static'; } | ||
|
||
|
@@ -58,10 +58,10 @@ exports.resolveBorrows = function(docs) { | |
clone.longname = clone.memberof + (clone.scope === 'instance'? '#': '.') + clone.name; | ||
docs.push(clone); | ||
}); | ||
|
||
} | ||
}); | ||
|
||
delete doc.borrowed; | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/** | ||
@overview | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
*/ | ||
|
||
/** | ||
@module jsdoc/config | ||
@module jsdoc/config | ||
*/ | ||
'use strict'; | ||
|
||
|
@@ -19,7 +19,7 @@ function mergeRecurse(target, source) { | |
target[p] = source[p]; | ||
} | ||
}); | ||
|
||
return target; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
@module jsdoc/name | ||
@requires jsdoc/tag/dictionary | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
*/ | ||
'use strict'; | ||
|
||
|
@@ -53,15 +53,15 @@ exports.resolve = function(doclet) { | |
name = name.replace(/(?:^|\.)prototype\.?/g, INSTANCE); | ||
} | ||
doclet.name = name; | ||
|
||
// member of a var in an outer scope? | ||
if (name && !memberof && doclet.meta.code && doclet.meta.code.funcscope) { | ||
name = doclet.longname = doclet.meta.code.funcscope + INNER + name; | ||
} | ||
|
||
if (memberof || doclet.forceMemberof) { // @memberof tag given | ||
memberof = ('' || memberof).replace(/\.prototype\.?/g, INSTANCE); | ||
|
||
// the name is a fullname, like @name foo.bar, @memberof foo | ||
if (name && name.indexOf(memberof) === 0 && name !== memberof) { | ||
about = exports.shorten(name, (doclet.forceMemberof ? memberof : undefined)); | ||
|
@@ -89,19 +89,19 @@ exports.resolve = function(doclet) { | |
else { // no @memberof | ||
about = exports.shorten(name); | ||
} | ||
|
||
if (about.name) { | ||
doclet.name = about.name; | ||
} | ||
|
||
if (about.memberof) { | ||
doclet.setMemberof(about.memberof); | ||
} | ||
|
||
if (about.longname && !doclet.longname) { | ||
doclet.setLongname(about.longname); | ||
} | ||
|
||
if (doclet.scope === 'global') { // via @global tag? | ||
doclet.setLongname(doclet.name); | ||
delete doclet.memberof; | ||
|
@@ -146,7 +146,7 @@ function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters | |
return '"' + name.replace(/\"/g, '"') + '"'; | ||
} | ||
} | ||
|
||
return name; | ||
} | ||
|
||
|
@@ -170,7 +170,7 @@ exports.applyNamespace = function(longname, ns) { | |
if ( !/^[a-zA-Z]+?:.+$/i.test(name) ) { | ||
longname = longname.replace( new RegExp(RegExp.escape(name)+'$'), ns + ':' + name ); | ||
} | ||
|
||
return longname; | ||
}; | ||
|
||
|
@@ -184,29 +184,29 @@ exports.applyNamespace = function(longname, ns) { | |
exports.shorten = function(longname, forcedMemberof) { | ||
// quoted strings in a longname are atomic, convert to tokens | ||
var atoms = [], token; | ||
|
||
// handle quoted names like foo["bar"] or foo['bar'] | ||
longname = longname.replace(/(\[?["'].+?["']\]?)/g, function($) { | ||
var dot = ''; | ||
if ( /^\[/.test($) ) { | ||
dot = '.'; | ||
$ = $.replace( /^\[/g, '' ).replace( /\]$/g, '' ); | ||
} | ||
|
||
token = '@{' + atoms.length + '}@'; | ||
atoms.push($); | ||
|
||
return dot + token; // foo["bar"] => foo.@{1}@ | ||
}); | ||
|
||
var name = '', | ||
scope = '', // ., ~, or # | ||
memberof = '', | ||
parts, | ||
variation; | ||
|
||
longname = longname.replace(/\.prototype\.?/g, INSTANCE); | ||
|
||
if (typeof forcedMemberof !== 'undefined') { | ||
name = longname.substr(forcedMemberof.length); | ||
parts = forcedMemberof.match(/^(.*?)([#.~]?)$/); | ||
|
@@ -218,18 +218,18 @@ exports.shorten = function(longname, forcedMemberof) { | |
parts = longname? | ||
(longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ) || []).reverse() | ||
: ['']; | ||
|
||
name = parts[0] || ''; // ensure name is always initialised to avoid error being thrown when calling replace on undefined [gh-24] | ||
scope = parts[1] || ''; // ., ~, or # | ||
memberof = parts[2] || ''; | ||
} | ||
|
||
// like /** @name foo.bar(2) */ | ||
if ( /(.+)\(([^)]+)\)$/.test(name) ) { | ||
name = RegExp.$1; | ||
variation = RegExp.$2; | ||
} | ||
|
||
//// restore quoted strings back again | ||
var i = atoms.length; | ||
while (i--) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/** | ||
@overview | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
@module jsdoc/package | ||
@see http://wiki.commonjs.org/wiki/Packages/1.0 | ||
@module jsdoc/package | ||
@see http://wiki.commonjs.org/wiki/Packages/1.0 | ||
*/ | ||
|
||
/** | ||
|
@@ -22,39 +22,39 @@ exports.Package = function(json) { | |
@type {Array<String>} | ||
*/ | ||
this.files = []; | ||
|
||
/** The kind of this package. | ||
@readonly | ||
@default | ||
@type {string} | ||
*/ | ||
this.kind = 'package'; | ||
|
||
json = JSON.parse(json); | ||
|
||
/** The name of this package. | ||
This value is found in the package.json file passed in as a command line option. | ||
@type {string} | ||
*/ | ||
this.name = json.name; | ||
|
||
/** The longname of this package. | ||
@type {string} | ||
*/ | ||
this.longname = this.kind + ':' + this.name; | ||
|
||
/** The description of this package. | ||
@type {string} | ||
*/ | ||
this.description = json.description; | ||
|
||
/** | ||
The hash summary of the source file. | ||
@type {string} | ||
@since 3.2.0 | ||
*/ | ||
this.version = json.version; | ||
|
||
/** | ||
* The licenses of this package. | ||
* @type {Array<Object>} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
@overview | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
@overview | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
*/ | ||
'use strict'; | ||
|
||
|
@@ -17,9 +17,9 @@ var dictionary; | |
function TagDefinition(title, etc) { | ||
var self = this; | ||
etc = etc || {}; | ||
|
||
this.title = dictionary.normalise(title); | ||
|
||
Object.keys(etc).forEach(function(p) { | ||
self[p] = etc[p]; | ||
}); | ||
|
@@ -38,22 +38,22 @@ dictionary = { | |
var def = new TagDefinition(title, opts); | ||
// all the other dictionary functions use normalised names; we should too. | ||
_tags[def.title] = def; | ||
|
||
if (opts.isNamespace) { | ||
_namespaces.push(def.title); | ||
} | ||
|
||
return _tags[def.title]; | ||
}, | ||
|
||
/** @function */ | ||
lookUp: function(title) { | ||
title = dictionary.normalise(title); | ||
|
||
if ( hasOwnProp.call(_tags, title) ) { | ||
return _tags[title]; | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
|
@@ -65,18 +65,18 @@ dictionary = { | |
return true; | ||
} | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
/** @function */ | ||
normalise: function(title) { | ||
var canonicalName = title.toLowerCase(); | ||
|
||
if ( hasOwnProp.call(_tagSynonyms, canonicalName) ) { | ||
return _tagSynonyms[canonicalName]; | ||
} | ||
|
||
return canonicalName; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/*global env: true */ | ||
/** | ||
@module jsdoc/tag/validator | ||
@requires jsdoc/tag/dictionary | ||
@module jsdoc/tag/validator | ||
@requires jsdoc/tag/dictionary | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
@author Michael Mathews <[email protected]> | ||
@license Apache License 2.0 - See file 'LICENSE.md' in this project. | ||
*/ | ||
'use strict'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters