From 57c43dd3762ea665125bff7e4727bce06a225b32 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Thu, 22 Aug 2013 12:32:42 -0700 Subject: docs(module): improve the installation instructions for optional modules Currently, the documentation does a bad job of explaining the distinction between the services that it provides, and the module itself. Furthermore, the instructions for using optional modules are inconsistent or missing. This commit addresses the problem by ading a new `{@installModule foo}` annotation to the docs generator that inlines the appropriate instructions based on the name of the module. --- docs/src/ngdoc.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'docs/src/ngdoc.js') diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index e752b447..a9f470cc 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -276,6 +276,9 @@ Doc.prototype = { replace(/{@type\s+(\S+)(?:\s+(\S+))?}/g, function(_, type, url) { url = url || '#'; return '' + type + ''; + }). + replace(/{@installModule\s+(\S+)?}/g, function(_, module) { + return explainModuleInstallation(module); }); }); text = parts.join(''); @@ -450,7 +453,6 @@ Doc.prototype = { dom.text(' Improve this doc'); }); dom.h(title(this), function() { - notice('deprecated', 'Deprecated API', self.deprecated); if (self.ngdoc === 'error') { minerrMsg = lookupMinerrMsg(self); @@ -1169,3 +1171,28 @@ function dashCase(name){ return (pos ? '-' : '') + letter.toLowerCase(); }); } +////////////////////////////////////////////////////////// + +function explainModuleInstallation(moduleName){ + var ngMod = ngModule(moduleName), + modulePackage = 'angular-' + moduleName, + modulePackageFile = modulePackage + '.js'; + + return '

Installation

' + + '

First include ' + modulePackageFile +' in your HTML:

' +
+    '    <script src="angular.js">\n' +
+    '    <script src="' + modulePackageFile + '">
' + + + '

You can also find this file on the [Google CDN](https://developers.google.com/speed/libraries/devguide#angularjs), ' + + 'Bower (as ' + modulePackage + '), ' + + 'and on code.angularjs.org.

' + + + '

Then load the module in your application by adding it as a dependant module:

' +
+    '    angular.module(\'app\', [\'' + ngMod + '\']);
' + + + '

With that you\'re ready to get started!

'; +} + +function ngModule(moduleName) { + return 'ng' + moduleName[0].toUpperCase() + moduleName.substr(1); +} -- cgit v1.2.3