//>>built // wrapped by build app define("dojox/lang/docs", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){ dojo.provide("dojox.lang.docs"); // Extracts information from the API docs to apply a schema representation to dojo classes. // This can be utilized for runtime metadata retrieval and type checking (function(){ function error(error){ console.log("Warning, the API docs must be available at ../util/docscripts/api.json "+ "or ../util/docscripts/api/*.json "+ "in order for dojox.lang.docs to supply schema information, but it could not be loaded: " + error); } var declaredClasses = {}; var requiredModules = []; var _docs = dojox.lang.docs._loadedDocs = {}; var schemifyClass = function(clazz, name){ // initial implementation records classes until they are ready declaredClasses[name] = clazz; }; var getType = function(typeDef){ var type = typeDef.type || ''; var typeObj, optional = false, array = false, dontModify; type = type.replace(/\?/, function(){ optional = true; return ''; }); type = type.replace(/\[\]/, function(){ array = true; return ''; }); if(type.match(/HTML/)){ // HTML String and other "types" of strings are really just strings type = "string"; }else if(type == 'String' || type == 'Number' || type == 'Boolean' || type == 'Object' || type == 'Array' || type == 'Integer' || type == "Function"){ type = type.toLowerCase(); }else if(type == "bool"){ type = "boolean"; }else if(type){ typeObj = dojo.getObject(type) || {}; dontModify = true; }else{ typeObj = {}; } typeObj = typeObj || {type:type}; if(array){ typeObj = {items:typeObj, type:"array"}; dontModify = false; } if(!dontModify){ if(optional){ typeObj.optional = true; } if(/const/.test(typeDef.tags)){ typeObj.readonly = true; } } return typeObj; }; var actualSchemifyClass = function(clazz, name){ var docForClass = _docs[name]; if(docForClass){ clazz.description = docForClass.description; clazz.properties = {}; clazz.methods = {}; if(docForClass.properties){ var props = docForClass.properties; for(var i=0, l=props.length; i