Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/165527

Change subject: Hygiene: Cleanup Mantle documentation
......................................................................

Hygiene: Cleanup Mantle documentation

Also:
* Remove dead code relating to default compiler
* Add singleton classes
* Wrap template compiler registration in closure

Bug: 71250
Change-Id: Ib50391973555efb0dcc505e59e7bd555378bff0d
---
M javascripts/common/Class.js
M javascripts/common/eventemitter.js
M javascripts/common/modules.js
M javascripts/common/templates.js
M javascripts/common/templates/handlebars.js
M javascripts/common/templates/hogan.js
6 files changed, 53 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Mantle 
refs/changes/27/165527/1

diff --git a/javascripts/common/Class.js b/javascripts/common/Class.js
index e61a764..82885cd 100644
--- a/javascripts/common/Class.js
+++ b/javascripts/common/Class.js
@@ -1,4 +1,3 @@
-/* jshint loopfunc: true */
 /**
  * @class Class
  */
diff --git a/javascripts/common/eventemitter.js 
b/javascripts/common/eventemitter.js
index 858937c..d52cdf7 100644
--- a/javascripts/common/eventemitter.js
+++ b/javascripts/common/eventemitter.js
@@ -7,6 +7,11 @@
        // This needs some hackery to make oojs's
        // and Mantle's different OO models get along,
        // and we need to alias one() to once().
+       /**
+        * @class EventEmitter
+        * @extends Class
+        * @uses OO.EventEmitter
+       **/
        EventEmitter = Class.extend( $.extend( {
                initialize: OO.EventEmitter,
                one: OO.EventEmitter.prototype.once
diff --git a/javascripts/common/modules.js b/javascripts/common/modules.js
index 21b280b..cbad05f 100644
--- a/javascripts/common/modules.js
+++ b/javascripts/common/modules.js
@@ -1,3 +1,8 @@
+/**
+ *
+ * @class mw.mantle
+ * @singleton
+ */
 ( function( M, $ ) {
        $.extend( M, {
                _modules: {},
diff --git a/javascripts/common/templates.js b/javascripts/common/templates.js
index f89d5ef..0648663 100644
--- a/javascripts/common/templates.js
+++ b/javascripts/common/templates.js
@@ -7,14 +7,18 @@
        templates = {}, template;
        template = {
                _compilers: {},
-               registerCompiler: function( name, obj, isDefault ) {
+               /**
+                * Register a compiler for a given template language
+                *
+                * @method
+                * @param {String} name the name of the compiler
+                * @param {HoganTemplateCompiler|HandlebarsTemplateCompiler} a 
compiler to associate with the name. Must implement a compile and 
registerPartial function.
+                */
+               registerCompiler: function( name, obj ) {
                        if ( obj.compile ) {
                                this._compilers[name] = obj;
                        } else {
                                throw new Error( 'Template compiler must 
implement compile function.' );
-                       }
-                       if ( isDefault ) {
-                               this._compilerDefault = name;
                        }
                },
                /**
diff --git a/javascripts/common/templates/handlebars.js 
b/javascripts/common/templates/handlebars.js
index 9c39975..5df51e4 100644
--- a/javascripts/common/templates/handlebars.js
+++ b/javascripts/common/templates/handlebars.js
@@ -1,7 +1,10 @@
-/**
- * Register the Handlebars compiler with MediaWiki.
- */
-mw.mantle.template.registerCompiler( 'handlebars', {
+// Register the Handlebars compiler with MediaWiki.
+( function( M ) {
+       /**
+        * @class HandlebarsTemplateCompiler
+        * @singleton
+        */
+       M.template.registerCompiler( 'handlebars', {
        /**
         * Registers a partial internally in the compiler.
         *
@@ -25,4 +28,5 @@
                        render: Handlebars.compile( src )
                };
        }
-}, true );
+       }, true );
+}( mw.mantle ) );
diff --git a/javascripts/common/templates/hogan.js 
b/javascripts/common/templates/hogan.js
index d464ebc..cc91ca2 100644
--- a/javascripts/common/templates/hogan.js
+++ b/javascripts/common/templates/hogan.js
@@ -1,24 +1,28 @@
-/**
- * Register the Hogan compiler with MediaWiki.
- */
-mw.mantle.template.registerCompiler( 'hogan', {
+// Register the Hogan compiler with MediaWiki.
+( function( M ) {
        /**
-        * Registers a partial internally in the compiler.
-        * Not used in Hogan compiler
-        *
-        * @method
-        * @param {String} name Name of the template
-        * @param {HandleBars.Template} partial
+        * @class HoganTemplateCompiler
+        * @singleton
         */
-       registerPartial: function( /* name, partial */ ) {},
-       /**
-        * Compiler source code into a template object
-        *
-        * @method
-        * @param {String} src the source of a template
-        * @return {Hogan.Template} template object
-        */
-       compile: function( src ) {
-               return Hogan.compile( src );
-       }
-} );
+       mw.mantle.template.registerCompiler( 'hogan', {
+               /**
+                * Registers a partial internally in the compiler.
+                * Not used in Hogan compiler
+                *
+                * @method
+                * @param {String} name Name of the template
+                * @param {HandleBars.Template} partial
+                */
+               registerPartial: function( /* name, partial */ ) {},
+               /**
+                * Compiler source code into a template object
+                *
+                * @method
+                * @param {String} src the source of a template
+                * @return {Hogan.Template} template object
+                */
+               compile: function( src ) {
+                       return Hogan.compile( src );
+               }
+       } );
+}( mw.mantle ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/165527
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib50391973555efb0dcc505e59e7bd555378bff0d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Mantle
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to