JavaScriptでのコーティング量も増えaltJSを使う機会も増しCoffeeScriptを利用しています。そんなときに使用するのが grunt-codo です。
インストール
npm install grunt-codo --save-dev
Gruntfile.jsでの読み込み
grunt.loadNpmTasks('grunt-codo');
使い方
grunt.initConfig({
codo: {
options: {
title: "My library",
output: 'jsdoc',
inputs: ["app/scripts"]
}
},
})
コメントの書き方
コメントの書き方はここを読んでください。ソースにコメントを書いてcodoを動かしてみました。
define [ 'jquery' 'underscore' 'backbone' 'templates' ], ($, _, Backbone, JST) -> class AboutView extends Backbone.View template: JST['app/scripts/templates/about.ejs'] el: '#main-contents' ### Rendering of AboutView @author Fumio.SAGAWA @example Rendering of AboutView new AboutView.render() ### render: -> console.log 'ContactView.render' $(@el).html @template
実行すると
といった形式でコメントが書かれているかチェックしてくれます。出力されるファイルはこちらです。
かっこよくないですか?
最後に
CoffeeScriptでもちゃんとドキュメント化して保守性を高めましょう。