2016-08-02 26 views
1

Hier habe ich einen EmberJS-Controller als Beispiel. Wie man es richtig kommentiert, um Dokumentation mit YUIDoc zu erzeugen?EmberJS Dokumentation mit YUIDoc, Kommentar Stil?

import Ember from 'ember'; 

/** 
* ? 
*/ 
export default Ember.Controller.extend({ 
    queryParams: ['param1', 'param2'], 

    /** 
    * ? 
    */ 
    param1: '', 

    /** 
    * ? 
    */ 
    param2: 10, 

    /** 
    * 
    */ 
    testFunc1(param) { 

    }, 

    /** 
    * 
    */ 
    actions: { 
    /** 
    * ? 
    */ 
    testFunc2(id) { 

    }, 

    /** 
    * ? 
    */ 
    testFunc3() { 
     /** 
     * ? 
     */ 
     function testFunc4() { 
     } 

    } 

    } 
}); 

Ich habe Interesse, die Best Practices für die emberJS Code-Dokumentation zu kennen, so dass am Ende ich die richtige doco mit vollständiger Hierarchie erhalten. Jede Hilfe würde sehr geschätzt werden.

Antwort

0

Ich habe eine Antwort wie folgt gefunden. Wenn jemand eine bessere Lösung hat dann bitte teilen.

import Ember from 'ember'; 

/** 
* The login controller shows the login form and sends authentication data to the session. 
* 
* @class login 
* @namespace Controller 
*/ 
export default Ember.Controller.extend({ 

    /** 
    * The session service. 
    * 
    * @property session 
    * @readOnly 
    * @type Service 
    */ 
    session: Ember.inject.service('session'), 

    /** 
    * The identification, usually an username or e-mailaddress. 
    * 
    * @property identification 
    * @type String 
    * @default null 
    */ 
    identification: '', 

    /** 
    * The password. 
    * 
    * @property password 
    * @type String 
    * @default null 
    */ 
    password: '', 


    actions: { 

    /** 
    * The authenticate action sends the identification and password to the session. 
    * 
    * @event authenticate 
    * @return undefined 
    */ 
    authenticate() { 
     this.get('session').authenticate('authenticator:jwt', this.getProperties('identification', 'password')); 
    } 

    } 

}); 
+0

Ich neige dazu, '@ method' für Aktionen und Aktionen zu verwenden. Ich tendiere auch dazu, eine Eigenschaft oder Methode, die ich für die Vorlagen meiner eigenen Komponenten/Controller habe, oder die interne Verwendung als @ private zu markieren, während Eigenschaften und Aktionen, mit denen die Anwendung arbeiten soll, als @ public angezeigt werden. – Sukima

0

Hier ist ein Beispiel für Komponenten, die auch in Controllern verwendet werden können.

/** 
* @module Components 
*/ 
import Ember from 'ember'; 
import MyMixin from '../mixins/my-mixin'; 
const { Component, inject, computed } = Ember; 

/** 
* My aweseome component 
* 
* ## Example Ussage: 
* ```handlebars 
* {{awesome-thing 
*  foo="bar" 
*  baz=boundProp 
*  doit=(action "myAction")}} 
* ``` 
* 
* @class AwesomeThingComponent 
* @extends Ember.Component 
* @uses Mixins.MyMixin 
*/ 
export default Component.extend(MyMixin, { 
    /** 
    * @property {Services.MyService} myService 
    * @private 
    */ 
    myService: inject.service(), 

    /** 
    * Set this to "bar". 
    * @property {String} foo 
    * @default foobar 
    * @public 
    */ 
    foo: 'foobar', 

    /** 
    * Bind this property (Data Down). 
    * @property {Boolean} baz 
    * @public 
    */ 

    /** 
    * Private function 
    * @method myFunc 
    * @private 
    */ 
    myFunc() { 
    // Code 
    }, 

    actions: { 
    /** 
    * This is my closure action 
    * @method actions.doit 
    * @param {Object} payload the payload that will be sent to the action 
    * @return {Promise} any expectation that the action closure will return 
    * a value 
    * @required 
    * @public 
    */ 

    /** 
    * Internal action that will call `doit`. 
    * @method actions.myAction 
    * @private 
    */ 
    myAction() { 
     get(this, 'doit')({payload: 1}).then(() => { 
     console.log('yeah!'); 
     }); 
    } 
    } 
});