Commits

wolframkriesing committed daedec9

+ a raw viewer demo, needs some more docs and design to look nice

Comments (0)

Files changed (3)

dojox/docs/Inspector.js

 	null,
 	{
 		__doc__:{
-			summary:"Functionality for inspecting the docs of a given module."
+			summary:"Functionality for inspecting the docs of a given module.",
+			description:"",
+			params:{
+				moduleName:{
+					summary:"The module name, such as 'dojo.cookie'.",
+					type:"string"
+				}
+			}
 		},
-	
-		constructor:function(module){
-			this.module = module;
+		
+		constructor:function(moduleName){
+			dojo.require(moduleName);
+			this.moduleName = moduleName;
+			this.module = dojo.getObject(moduleName);
 		},
-	
+		
 		isClass:function(){
+			return !!this.module.prototype.declaredClass;
+		},
+		
+		getApi:function(){
+			var m = this.module;
+			// Is the current module a class?
+			if (m.prototype && m.prototype.declaredClass==this.moduleName){
+				return this._getClassApi();
+			}
+			return {};
+		},
+		
+		getMethods:function(module){
 			
 		},
-	
-		getMethods:function(module){
+		
+		getCoverage:function(){
 			
+		},
+		
+		_getClassApi:function(){
+			var m = this.module;
+			var ret = {methods:[], properties:[]};
+			for (var i in m.prototype){
+				switch(typeof m.prototype[i]){
+					case "function":
+						ret.methods.push(i);
+						break;
+					default:
+						ret.properties.push(i);
+						break;
+				}
+			}
+			
+			return ret;
 		}
 	}
 );
+
+dojox.docs.Inspector.prototype.getApi.__doc__ = {
+	summary:"Get the entire API of the module, all methods, properties, etc.",
+	params:{
+		test:{
+			summary:"bla",
+			type:"string"
+		}
+	}
+};
+dojox.docs.Inspector.prototype._getClassApi.__doc__ = {
+	summary:"Get the API of a class, all methods, properties, etc.",
+	params:{}
+};

dojox/docs/demos/Viewer.html

+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+	<title>Dojox Docs Viewer</title>
+	<style type="text/css">
+		@import "../../../dojo/resources/dojo.css";
+		@import "../../../dijit/themes/tundra/tundra.css";
+		@import "../../../dijit/themes/dijit.css";
+	</style>
+
+	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad:true"></script>
+	<script type="text/javascript" src="../../../dijit/_Templated.js"></script>
+</head>
+<body class="tundra">
+
+	<div class="class">
+		<div class="doc"></div>
+		<div class="api">
+			<h1>Methods</h1>
+			<div class="methods"></div>
+			<h1>Properties</h1>
+			<div class="properties"></div>
+		</div>
+	</div>
+
+	<script type="text/javascript">
+		dojo.require("dojox.dtl.Context");
+		dojo.require("dojox.docs.Inspector");
+		
+		var templates = {
+			classDoc:'<h1>{{ name }}</h1>'
+				+'<p class="summary">{{ doc.summary }}</p>'
+				+'<p class="description">{{ doc.description }}</p>'
+				,
+			method:'<h2>{{ name }}</h2>'
+				+'<p class="summary">{{ doc.summary }}</p>'
+				+'{% if doc.description %}<p class="description">{{ doc.description }}</p>{% endif %}'
+				+'<h3>Parameters</h3>'
+				+'{% for p in doc.params %}<h4>{{ p }}</h4>'
+				+'Type: {{ p }}<br />'
+				+'{% endfor %}'
+			,
+			property:'<h2>{{ name }}</h2>'
+				+'<p class="summary">{{ doc.summary }}</p>'
+				+'{% if doc.description %}<p class="description">{{ doc.description }}</p>{% endif %}'
+				+'Type: {{ doc.type }}'
+		};
+		
+		//var inspector = new dojox.docs.Inspector("dojox.docs.Inspector");
+		var inspector = new dojox.docs.Inspector("dojox.form.Rating");
+		var api = inspector.getApi();
+		if (inspector.isClass()){
+			var c = new dojox.dtl.Context({
+				name:inspector.moduleName,
+				doc:inspector.module.__doc__
+			});
+			var t = new dojox.dtl.Template(templates.classDoc);
+			dojo.query(".class .doc")[0].innerHTML = t.render(c);
+		}
+		dojo.query(".api .methods")[0].innerHTML = dojo.map(api.methods, function(method){
+			var data = {
+				name:method,
+				doc:inspector.module.prototype[method].__doc__
+			};
+			var c = new dojox.dtl.Context(data);
+			var t = new dojox.dtl.Template(templates.method);
+			return t.render(c);
+		}).join("<br />");
+		dojo.query(".api .properties")[0].innerHTML = dojo.map(api.properties, function(prop){
+			var data = {
+				name:prop,
+				doc:inspector.module.prototype.__doc__.properties[prop]
+			};
+			var c = new dojox.dtl.Context(data);
+			var t = new dojox.dtl.Template(templates.property);
+			return t.render(c);
+		}).join("<br />");
+		
+	</script>
+</body>
+</html>

dojox/form/Rating.js

 	
 	__doc__:{
 		summary:"A widget for rating using stars.",
+		description:"rating description .... loooong",
 		properties:{
 			numStars:{
-				description:"The number of stars to show, default is 3.",
+				summary:"The number of stars to show, default is 3.",
 				type:"Integer/Float"
 			},
 			value:{
-				description:"The current value of the Rating",
+				summary:"The current value of the Rating",
 				type:"Integer/Float"
 			}
 		}