簡體   English   中英

使用YUIDoc,評論風格的EmberJS文檔?

[英]EmberJS documentation using YUIDoc, Comment Style?

這里我以emberJS控制器為例。 如何正確評論使用YUIDoc生成文檔?

import Ember from 'ember';

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

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

  /**
   * ?
   */
  param2: 10,

  /**
  *
  */
  testFunc1(param) {

  },

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

    },

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

    }

  }
});

我有興趣了解emberJS代碼文檔的最佳實踐,所以最后我可以獲得具有完整層次結構的正確doco。 任何幫助將受到高度贊賞。

我找到了這樣一個答案。 如果有人有更好的解決方案,請分享。

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'));
    }

  }

});

這是我用於組件的示例,也可用於控制器。

/**
 * @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!');
      });
    }
  }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM