From 3d6a099d6e40f1e12f6349843218987d472d0f3c Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 4 Nov 2010 17:41:14 -0700 Subject: [PATCH] changed to showdown from markup. added validator overview --- .externalToolBuilders/JSTD_Tests.launch | 2 +- docs/collect.js | 14 +- docs/filter.template | 6 +- docs/index.html | 4 +- docs/overview.template | 2 +- docs/spec/collectSpec.js | 38 +- docs/validator.template | 27 + docs/widget.template | 7 +- gen_docs.sh | 2 +- lib/markdown/index.js | 1446 ----------------------- lib/showdown/index.js | 6 + lib/showdown/showdown-0.9.js | 1296 ++++++++++++++++++++ src/Angular.js | 63 +- src/validators.js | 56 + 14 files changed, 1496 insertions(+), 1473 deletions(-) create mode 100644 docs/validator.template delete mode 100644 lib/markdown/index.js create mode 100644 lib/showdown/index.js create mode 100644 lib/showdown/showdown-0.9.js diff --git a/.externalToolBuilders/JSTD_Tests.launch b/.externalToolBuilders/JSTD_Tests.launch index 250aa755..439cb407 100644 --- a/.externalToolBuilders/JSTD_Tests.launch +++ b/.externalToolBuilders/JSTD_Tests.launch @@ -1,7 +1,7 @@ - + diff --git a/docs/collect.js b/docs/collect.js index c16366ab..04735985 100644 --- a/docs/collect.js +++ b/docs/collect.js @@ -4,7 +4,7 @@ var fs = require('fs'), spawn = require('child_process').spawn, mustache = require('mustache'), callback = require('callback'), - markdown = require('markdown'); + Showdown = require('showdown').Showdown; var documentation = { section:{}, @@ -99,7 +99,12 @@ function escapedHtmlTag(doc, name, value) { } function markdownTag(doc, name, value) { - doc[name] = markdown.toHTML(value.replace(/^#/gm, '##')); + doc[name] = markdown(value.replace(/^#/gm, '##')); +} + +function markdown(text) { + text = text.replace(//gm, '<angular/>'); + return new Showdown.converter().makeHtml(text); } var TAG = { @@ -114,6 +119,8 @@ var TAG = { description: markdownTag, TODO: markdownTag, returns: markdownTag, + paramDescription: markdownTag, + exampleDescription: markdownTag, name: function(doc, name, value) { doc.name = value; doc.shortName = value.split(/\./).pop(); @@ -127,7 +134,8 @@ var TAG = { type: match[2], name: match[6] || match[5], 'default':match[7], - description:match[8]}; + description:value.replace(match[0], match[8]) + }; doc.param.push(param); if (!doc.paramFirst) { doc.paramFirst = param; diff --git a/docs/filter.template b/docs/filter.template index 0602aff9..9375f422 100644 --- a/docs/filter.template +++ b/docs/filter.template @@ -1,4 +1,7 @@

{{name}}

+

Description

+{{{description}}} +

Usage

In HTML Template Binding

@@ -25,9 +28,6 @@ angular.filter.{{shortName}}({{paramFirst.name}}{{#paramRest}}, {{name}}{{/param

CSS

{{{css}}} -

Description

-{{{description}}} - {{{example}}} \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index a2cad87e..2f5a8234 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,8 +4,8 @@ - - + + + * + * + */ angularValidator = extensionMap(angular, 'validator'), @@ -139,13 +192,13 @@ var _undefined = undefined, * You can use these variables in the function: * * * `this` — The current scope. - * * `$element` — The DOM element containing the binding. This allows the filter to manipulate + * * `this.$element` — The DOM element containing the binding. This allows the filter to manipulate * the DOM in addition to transforming the input. * * * @example The following example filter reverses a text string. In addition, it conditionally makes the text upper-case (to demonstrate optional arguments) and assigns color (to demonstrate DOM @@ -169,10 +222,6 @@ var _undefined = undefined, {{"hello"|reverse:true:"blue"}}: {{"hello"|reverse:true:"blue"}} - * @TODO: I completely dropped a mention of using the other option (setter method), it's - * confusing to have two ways to do the same thing. I just wonder if we should prefer using the - * setter way over direct assignment because in the future we might want to be able to intercept - * filter registrations for some reason. */ angularFilter = extensionMap(angular, 'filter'), angularFormatter = extensionMap(angular, 'formatter'), diff --git a/src/validators.js b/src/validators.js index fd18d66c..a1543f41 100644 --- a/src/validators.js +++ b/src/validators.js @@ -84,6 +84,62 @@ extend(angularValidator, { } }, + /** + * @ngdoc validator + * @name angular.validator.asynchronous + * @description + * Use asynchronous validator if the validation can not be computed + * immediately, but is provided through a callback. The widget + * automatically shows a spinning indicator while the validity of + * the widget is computed. This validator caches the result. + * + * @param {string} value value to validate + * @param {function(inputToValidate,validationDone)} validate function to call to validate the state + * of the input. + * @param {function(data)=} [update=noop] function to call when state of the + * validator changes + * + * @paramDescription + * The `validate` function (specified by you) is called as + * `validate(inputToValidate, validationDone)`: + * + * * `inputToValidate`: value of the input box. + * * `validationDone`: `function(error, data){...}` + * * `error`: error text to display if validation fails + * * `data`: data object to pass to update function + * + * The `update` function is optionally specified by you and is + * called by on input change. Since the + * asynchronous validator caches the results, the update + * function can be called without a call to `validate` + * function. The function is called as `update(data)`: + * + * * `data`: data object as passed from validate function + * + * @css ng-input-indicator-wait + * + * @exampleDescription + *
+   * function myValidator (value, callback) {
+   *  // simulate delayed response, validate on even input length
+   *  setTimeout(function(){
+   *    callback(value.length % 2);
+   *  }, 2000);
+   * };
+   * 
+ * + * @example + * + * This input is validated asynchronously: + * + * + */ /* * cache is attached to the element * cache: {