From 659af29adbd041fbbbaf041ead53266210a61f4e Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Wed, 27 Oct 2010 15:31:10 -0700
Subject: jsdoc parser + generator + viewer + scenario runner
- parse jsdocs from source code
- generate prerendered (markdown + mustache) partials
- generate json
- generate scenario runner for examples in docs
- basic angular doc viewer
---
src/Angular.js | 10 +++++-----
src/filters.js | 30 +++++++++++++++---------------
src/widgets.js | 14 ++++++++++++++
3 files changed, 34 insertions(+), 20 deletions(-)
(limited to 'src')
diff --git a/src/Angular.js b/src/Angular.js
index 62cfdef6..004ab48f 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -10,7 +10,7 @@ if (typeof document.getAttribute == $undefined)
*
* @description Converts string to lowercase
* @param {string} value
- * @return {string} Lowercased string.
+ * @returns {string} Lowercased string.
*/
var lowercase = function (value){ return isString(value) ? value.toLowerCase() : value; };
@@ -22,7 +22,7 @@ var lowercase = function (value){ return isString(value) ? value.toLowerCase() :
*
* @description Converts string to uppercase.
* @param {string} value
- * @return {string} Uppercased string.
+ * @returns {string} Uppercased string.
*/
var uppercase = function (value){ return isString(value) ? value.toUpperCase() : value; };
@@ -100,7 +100,7 @@ var _undefined = undefined,
* @ngdoc overview
* @name angular.filter
* @namespace Namespace for all filters.
- *
+ * @description
* # Overview
* Filters are a standard way to format your data for display to the user. For example, you
* might have the number 1234.5678 and would like to display it as US currency: $1,234.57.
@@ -364,7 +364,7 @@ function isLeafNode (node) {
* @param {*} source The source to be used during copy.
* Can be any type including primitives, null and undefined.
* @param {(Object|Array)=} destination Optional destination into which the source is copied
- * @return {*}
+ * @returns {*}
*/
function copy(source, destination){
if (!destination) {
@@ -507,7 +507,7 @@ function compile(element, existingScope) {
/**
* Parses an escaped url query string into key-value pairs.
- * @return Object.<(string|boolean)>
+ * @returns Object.<(string|boolean)>
*/
function parseKeyValue(/**string*/keyValue) {
var obj = {}, key_value, key;
diff --git a/src/filters.js b/src/filters.js
index ed824f93..767c1234 100644
--- a/src/filters.js
+++ b/src/filters.js
@@ -6,24 +6,25 @@
* @description
* Formats a number as a currency (ie $1,234.56).
*
- * @param {number} amout Input to filter.
+ * @param {number} amount Input to filter.
* @returns {string} Formated number.
*
* @css ng-format-negative
* When the value is negative, this css class is applied to the binding making it by default red.
- *
+ *
* @example
*
* {{amount | currency}}
*
* @scenario
* it('should init with 1234.56', function(){
- * expect(bind('amount')).toEqual('$1,234.56');
+ * expect(binding('amount')).toEqual('$1,234.56');
* });
* it('should update', function(){
- * element(':input[name=amount]').value('-1234');
- * expect(bind('amount')).toEqual('-$1,234.00');
- * expect(bind('amount')).toHaveColor('red');
+ * input('amount').enter('-1234');
+ * expect(binding('amount')).toEqual('$-1,234.00');
+ * // TODO: implement
+ * // expect(binding('amount')).toHaveColor('red');
* });
*/
angularFilter.currency = function(amount){
@@ -31,7 +32,6 @@ angularFilter.currency = function(amount){
return '$' + angularFilter['number'].apply(this, [amount, 2]);
};
-
/**
* @ngdoc filter
* @name angular.filter.number
@@ -43,7 +43,7 @@ angularFilter.currency = function(amount){
* If the input is not a number empty string is returned.
*
* @param {(number|string)} number Number to format.
- * @param {(number|string)=} fractionSize Number of decimal places to round the number to. Default 2.
+ * @param {(number|string)=2} fractionSize Number of decimal places to round the number to. Default 2.
* @returns {string} Number rounded to decimalPlaces and places a “,” after each third digit.
*
* @example
@@ -54,10 +54,10 @@ angularFilter.currency = function(amount){
*
* @scenario
* it('should format numbers', function(){
- * expect(element('span[ng\\:bind="1234.56789|number"]').val()).toBe('1,234.57');
- * expect(element('span[ng\\:bind="1234.56789|number:0"]').val()).toBe('1,234');
- * expect(element('span[ng\\:bind="1234.56789|number:2"]').val()).toBe('1,234.56');
- * expect(element('span[ng\\:bind="-1234.56789|number:4"]').val()).toBe('-1,234.56789');
+ * expect(binding('1234.56789|number')).toEqual('1,234.57');
+ * expect(binding('1234.56789|number:0')).toEqual('1,235');
+ * expect(binding('1234.56789|number:2')).toEqual('1,234.57');
+ * expect(binding('-1234.56789|number:4')).toEqual('-1,234.5679');
* });
*/
angularFilter.number = function(number, fractionSize){
@@ -204,10 +204,10 @@ angularFilter.date = function(date, format) {
*
* @scenario
* it('should jsonify filtered objects', function() {
- * expect(element('pre[ng\\:bind-template="{{ {a:1, b:[]} | json }}"]').val()).toBe(
+ * expect(binding('{{ {a:1, b:[]} | json')).toEqual(
* '{\n "a":1,\n "b":[]}'
* );
- * }
+ * });
*
*/
angularFilter.json = function(object) {
@@ -257,7 +257,7 @@ angularFilter.uppercase = uppercase;
* filtered and you can't get the content through the sanitizer.
*
* @param {string} html Html input.
- * @param {string=} option If 'unsafe' then do not sanitize the HTML input.
+ * @param {string='safe'} option If 'unsafe' then do not sanitize the HTML input.
* @returns {string} Sanitized or raw html.
*/
angularFilter.html = function(html, option){
diff --git a/src/widgets.js b/src/widgets.js
index 4d8c71d5..5eda5345 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -1,3 +1,7 @@
+/**
+ *
+ */
+
function modelAccessor(scope, element) {
var expr = element.attr('name');
if (!expr) throw "Required field 'name' not found.";
@@ -240,6 +244,16 @@ angularWidget('option', function(){
});
+/*ng:doc
+ * @type widget
+ * @name ng:include
+ *
+ * @description
+ *
+ * @example
+ *
+ * @scenario
+ */
angularWidget('ng:include', function(element){
var compiler = this,
srcExp = element.attr("src"),
--
cgit v1.2.3