首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用YUIDoc的EmberJS文档,注释样式?

使用YUIDoc的EmberJS文档,注释样式?
EN

Stack Overflow用户
提问于 2016-08-03 00:27:49
回答 2查看 495关注 0票数 1

这里我有一个emberJS控制器作为例子。如何正确注释它以使用YUIDoc生成文档?

代码语言:javascript
复制
import Ember from 'ember';

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

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

  /**
   * ?
   */
  param2: 10,

  /**
  *
  */
  testFunc1(param) {

  },

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

    },

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

    }

  }
});

我有兴趣知道emberJS代码文档的最佳实践,这样最后我就可以获得具有完整层次结构的适当文档。任何帮助都将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 2016-08-03 23:36:12

我找到了一个这样的答案。如果有人有更好的解决方案,请分享。

代码语言:javascript
复制
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
EN

Stack Overflow用户

发布于 2016-08-04 01:06:36

下面是我使用的一个组件示例,这些组件也可以在控制器中使用。

代码语言:javascript
复制
/**
 * @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!');
      });
    }
  }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38725886

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档