PageRenderTime 34ms CodeModel.GetById 31ms RepoModel.GetById 0ms 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. * @class Represents a collection of DocTags.
  12. * @constructor
  13. * @author Michael Mathews <a href="mailto:micmath@gmail.com">micmath@gmail.com</a>
  14. * @param {string} comment The entire documentation comment. The openening slash-star-star and
  15. * closing star-slash are optional. An untagged string at the start automatically gets a "desc" tag.
  16. */
  17. function Doclet(comment) {
  18. if (!comment) comment = "/** @desc undocumented */";
  19. var src = comment.replace(/(^\/\*\*|\*\/$)/g, "").replace(/^\s*\* ?/gm, "");
  20. if (src.match(/^\s*[^@\s]/)) src = "@desc "+src;
  21. var tagTexts = src.split(/(^|[\r\f\n])\s*@/);
  22. this.tags =
  23. tagTexts.filter(function(el){return el.match(/^\w/)})
  24. .map(function(el){return new DocTag(el)});
  25. var paramParent = "config"; // default
  26. for(var i = 0; i < this.tags.length; i++) {
  27. if (this.tags[i].title == "param") paramParent = this.tags[i].name;
  28. if (this.tags[i].title == "config") {
  29. this.tags[i].name = paramParent+"."+this.tags[i].name;
  30. this.tags[i].title = "param"
  31. }
  32. }
  33. }
  34. /**
  35. * Get every DocTag with the given title.
  36. * @param {string} tagTitle
  37. * @return {DocTag[]}
  38. */
  39. Doclet.prototype.getTag = function(tagTitle) {
  40. return this.tags.filter(function(el){return el.title == tagTitle});
  41. }
  42. /**
  43. * Remove from this Doclet every DocTag with the given title.
  44. * @private
  45. * @param {string} tagTitle
  46. */
  47. Doclet.prototype._dropTag = function(tagTitle) {
  48. this.tags = this.tags.filter(function(el){return el.title != tagTitle});
  49. }