Exemplo n.º 1
0
        var TypeViewModel = function(type, symbols, context) {
            this._type = type;
            this._protoType = type.getPropertyType("prototype");
            this.symbols = symbols;
            this.name = type.name;
            this.label = type.getLabel();
            this._isClass = type.isJavaScriptFunction() && type.raptorType !== 'module';

            this.sourceLink = null;

            if (type.sourceFile) {
                this.sourceLink = jsdocUtil.sourceLink(type.sourceFile);
            }

            var comment = null;
            if (type.raptorType) {
                comment = type.raptorDefineComment;
            }
            else {
                comment = type.getComment();    
            }
            if (comment) {
                this.desc = comment.getDescription();
            }
            
            this.permaLinkHref = jsdocUtil.symbolUrl(this.name);

            this.staticMethods = new PropertiesViewModel(this, context);
            this.staticProperties = new PropertiesViewModel(this, context);
            
            this.instanceMethods = new PropertiesViewModel(this, context, "this.");
            this.instanceProperties = new PropertiesViewModel(this, context, "this.");
            
            this.protoMethods = new PropertiesViewModel(this, context, "prototype.");
            this.protoProperties = new PropertiesViewModel(this, context, "prototype.");

            this.ctorProperties = new PropertiesViewModel(this, context);

            if (this.isClass()) {
                this.ctorProperties.addProperty({
                    ctor: true,
                    name: type.getShortName(),
                    type: type,
                    comment: type.getComment()
                });
            }
            

            this.addStaticProps();
            this.addProtoProps(type);
        };
Exemplo n.º 2
0
        var PropertyViewModel = function(prop, context, anchorPrefix, sourceType) {
            var attrs = context.getAttributes().jsdocs;
            if (!attrs) {
                throw raptor.createError(new Error('"jsdocs" attribute not set for context'));
            }

            this._prop = prop;
            this._sourceType = sourceType;
            this.name = prop.name;
            this.params = [];
            this.modifiers = [];
            this.context = context;
            this.sections = [];

            this.anchorName = (anchorPrefix ? anchorPrefix + prop.name : prop.name);
            this.moreElId = null;

            this.permaLinkHref = jsdocUtil.symbolUrl(attrs.currentSymbolName) + "#" + this.anchorName;
            
            this._isMixin = prop.mixinSource != null;

            

            var comment = prop.comment;
            if (!comment && prop.type && prop.type.hasComment()) {
                comment = prop.type.getComment();
            }

            if (comment) {
                var summary = summarize(comment.getDescription());
                this.shortDesc = summary.shortDesc;
                this.remainingDesc = summary.remainingDesc;
                
                var deprecatedTag = comment.getTag("deprecated");
                if (deprecatedTag) {
                    this.deprecated = true;
                    this.sections.push({
                        type: "deprecated",
                        label: "Deprecated",
                        message: deprecatedTag.getValue()
                    });
                    this.modifiers.push({
                        type: "deprecated"
                    });
                }
                
                
            }

            if (this.isFunction()) {
                var params = this.params = [];
                
                this._prop.type.forEachFunctionParam(function(param) {
                    params.push(param);
                }, this, this._prop.comment);

                if (params.length) {
                    this.sections.push({
                        type: "params",
                        label: "Parameters",
                        params: params
                    });    
                }
                
                
            }
            
            if (comment) {
                var returnTag = comment.getTag("return");

                if (returnTag) {
                    this.returnType = returnTag.returnType;
                    this.returnDesc = returnTag.returnDesc;
                    
                    this.sections.push({
                        type: "returns",
                        label: "Returns",
                        returnType: returnTag.returnType,
                        returnDesc: returnTag.returnDesc
                    });    
                }
            }

            if (comment) {
                var seeTags = comment.getTags('see');
                if (seeTags.length) {
                    this.sections.push({
                        type: "see",
                        label: "See",
                        see: seeTags
                    });     
                }
            }

            

            if (prop.borrowFrom) {
                this.modifiers.push({
                    type: "borrow",
                    borrowFrom: prop.borrowFrom,
                    borrowFromPropName: prop.borrowFromPropName
                });
            }
            
            if (prop.mixinSource) {
                this.modifiers.push({
                    type: "mixin",
                    mixinSource: prop.mixinSource
                });
            }

            if (this.hasMore()) {
                this.moreElId = this.anchorName + "-more";
            }

        };