PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/tags/jsdoc_toolkit-1.3.3/app/Doclet.js

http://jsdoc-toolkit.googlecode.com/
JavaScript | 56 lines | 23 code | 7 blank | 26 comment | 9 complexity | a75420def2c1e23866b9428a78f36a33 MD5 | raw file
 1/**
 2 * @fileOverview
 3 * @name Doclet
 4 * @author Michael Mathews micmath@gmail.com
 5 * @url $HeadURL: http://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-1.3.3/app/Doclet.js $
 6 * @revision $Id: Doclet.js 213 2007-08-22 10:21:50Z micmath $
 7 * @license <a href="http://en.wikipedia.org/wiki/MIT_License">X11/MIT License</a>
 8 *          (See the accompanying README file for full details.)
 9 */
10 
11/**
12 * @class Represents a collection of DocTags.
13 * @constructor
14 * @author Michael Mathews <a href="mailto:micmath@gmail.com">micmath@gmail.com</a>
15 * @param {string} comment The entire documentation comment. The openening slash-star-star and
16 * closing star-slash are optional. An untagged string at the start automatically gets a "desc" tag.
17 */
18function Doclet(comment) {
19	if (!comment) comment = "/** @desc undocumented */";
20
21	var src = comment.replace(/(^\/\*\*|\*\/$)/g, "").replace(/^\s*\* ?/gm, "");
22	if (src.match(/^\s*[^@\s]/)) src = "@desc "+src;
23	
24	var tagTexts = src.split(/(^|[\r\f\n])\s*@/);
25	
26	this.tags =
27		tagTexts.filter(function(el){return el.match(/^\w/)})
28		.map(function(el){return new DocTag(el)});
29	
30	var paramParent = "config"; // default
31	for(var i = 0; i < this.tags.length; i++) {
32		if (this.tags[i].title == "param") paramParent = this.tags[i].name;
33		if (this.tags[i].title == "config") {
34			this.tags[i].name = paramParent+"."+this.tags[i].name;
35			this.tags[i].title = "param"
36		}
37	}
38}
39
40/**
41 * Get every DocTag with the given title.
42 * @param {string} tagTitle
43 * @return {DocTag[]}
44 */
45Doclet.prototype.getTag = function(tagTitle) {
46	return this.tags.filter(function(el){return el.title == tagTitle});
47}
48
49/**
50 * Remove from this Doclet every DocTag with the given title.
51 * @private
52 * @param {string} tagTitle
53 */
54Doclet.prototype._dropTag = function(tagTitle) {
55	this.tags = this.tags.filter(function(el){return el.title != tagTitle});
56}