From 404c9a653a1e28de1c6dda996875d6616812313a Mon Sep 17 00:00:00 2001
From: Matias Niemelä
Date: Tue, 7 May 2013 11:02:17 -0400
Subject: feat(ngdocs): add variable type hinting with colors
---
docs/src/ngdoc.js | 85 ++++++++++++++++++++++++++++++-----------
docs/src/templates/css/docs.css | 39 +++++++++++++++++++
2 files changed, 101 insertions(+), 23 deletions(-)
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js
index f4187d47..3bcfb196 100644
--- a/docs/src/ngdoc.js
+++ b/docs/src/ngdoc.js
@@ -348,28 +348,59 @@ Doc.prototype = {
},
+ prepare_type_hint_class_name : function(type) {
+ var typeClass = type.toLowerCase().match(/^[-\w]+/) || [];
+ typeClass = typeClass[0] ? typeClass[0] : 'object';
+ return 'label type-hint type-hint-' + typeClass;
+ },
+
html_usage_parameters: function(dom) {
- dom.h('Parameters', this.param, function(param){
- dom.tag('code', function() {
- dom.text(param.name);
- if (param.optional) {
- dom.tag('i', function() {
- dom.text('(optional');
- if(param['default']) {
- dom.text('=' + param['default']);
- }
- dom.text(')');
- });
+ var self = this;
+ var params = this.param ? this.param : [];
+ if(params.length > 0) {
+ dom.html('
Parameters
');
+ dom.html('');
+ dom.html('');
+ dom.html('');
+ dom.html('| Param | ');
+ dom.html('Type | ');
+ dom.html('Details | ');
+ dom.html('
');
+ dom.html('');
+ dom.html('');
+ for(var i=0;i)/);
+ var description = param.description;
if (param.optional) {
- dom.text('=');
+ name += ' (optional)
';
}
- dom.text('} – ');
- });
- dom.html(param.description);
- });
+ dom.html('');
+ dom.html('| ' + name + ' | ');
+ dom.html('');
+ for(var j=0;j');
+ dom.text(type);
+ dom.html('');
+ }
+ dom.html(' | ');
+ dom.html('' + description + ' | ');
+ dom.html('
');
+ };
+ dom.html('');
+ dom.html('
');
+ }
if(this.animations) {
dom.h('Animations', this.animations, function(animations){
dom.html('');
@@ -387,11 +418,19 @@ Doc.prototype = {
html_usage_returns: function(dom) {
var self = this;
if (self.returns) {
- dom.h('Returns', function() {
- dom.tag('code', '{' + self.returns.type + '}');
- dom.text('– ');
- dom.html(self.returns.description);
- });
+ dom.html('Returns
');
+ dom.html('');
}
},
diff --git a/docs/src/templates/css/docs.css b/docs/src/templates/css/docs.css
index 7d22baab..fdc74736 100644
--- a/docs/src/templates/css/docs.css
+++ b/docs/src/templates/css/docs.css
@@ -202,3 +202,42 @@ ul.events > li > h3 {
.clear {
clear: both;
}
+
+.variables-matrix td {
+ vertical-align:top;
+ padding:5px;
+}
+
+.type-hint {
+ display:inline-block;
+}
+
+.variables-matrix .type-hint {
+ text-align:center;
+ display:block;
+ min-width:60px;
+}
+
+.type-hint + .type-hint {
+ margin-top:5px;
+}
+
+.type-hint-string {
+ background:#3a87ad;
+}
+
+.type-hint-object {
+ background:#999;
+}
+
+.type-hint-array {
+ background:#F90;;
+}
+
+.type-hint-boolean {
+ background:rgb(18, 131, 39);
+}
+
+.type-hint-number {
+ background:rgb(189, 63, 66);
+}
--
cgit v1.2.3