2016-10-01 65 views
4

什麼是流星應用程序中使用JSDoc正確的方法是什麼? 下面是我編寫代碼的方法,但所有部分之間沒有「連接」。 所有內容都屬於示例模板,所以jsdoc的輸出結構應該正確。如何使用jsdoc爲流星應用

如何改善這個文件?

Template.example.helpers({ 
    /** 
    * Get all categories 
    * @name  categories 
    * @return  {Cursor} 
    * @summary  Cursor categories 
    */ 
    categories() { 
     return Categories.find({}); 
    }, 
}); 

Template.example.onCreated(
    /** 
    * If template is created (still not rendered), ReactiveDict variable is initialized 
    * @function 
    * @name  onCreated 
    * @summary  Set ReactiveDict 
    */ 
    function() { 
     this.something = new ReactiveDict(); 
    } 
); 

Template.example.events({ 
    /** 
    * Clicking on category will show a console message 
    * @event 
    * @summary  Console message 
    */ 
    'click #category': (event, template) => { 
     console.log('nice') 
    } 
}); 

回答

0

我在哪裏工作,我們遇到了同樣的情況在幾個月前,我們得出的結論是,jsdoc只是不適合自動文檔與Meteor的實現。我們最終使用https://github.com/fabienb4/meteor-jsdoc,這讓我們完全滿意。 它基本上延伸jsdoc語法與流星特定的關鍵字,以便您可以指定哪些是Meteor.call,什麼是收集幫助等等。一旦配置和運行,輸出基本上就是Meteor的文檔1.3以前的樣子(正如作者所說,它是「基於Meteor自己的文檔的模板」)。

編輯:正如我們不使用流星的模板系統,我沒有一個現有的例子,但我適應集合幫手,你的情況,告訴我,如果有什麼不清楚的地方。關鍵是要看你如何要顯示您的文檔與@memberOf@isMethod,等玩。

/** 
    * @memberOf Foo Template 
    * @summary Returns Bar conversation attached to stuff 
    * @param {String} fooId 
    * @param {Boolean} forced # Use to create foo when it's not found 
    * @returns {Object} Bar 
    */ 
    getStuff: function(fooId, forced=false) { 
      'use strict'; 
      /** your code **/ 
    } 
+0

您能否給我舉個示例代碼?我不知道我應該用什麼'isTemplate',我應該如何紀念'events' ... – user3142695

+0

我編輯它,讓我知道它是否適合。 – ko0stik