Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Coffee Script | CodoによるJavaDoc風のドキュメンテーション出力

概要

CodoによるJavaDoc風のドキュメンテーション出力について。

内容

前提

前提としてNode.js,CoffeeScriptは下記URLの手順でインストール済みとします。
http://d.hatena.ne.jp/tbpg/20130519/1368951677

インストール

以下のコマンドを実行します

$ sudo npm install -g codo

インストール結果を確認します

$ codo -v
ドキュメント生成サンプル

GitHubに載っている導入用サンプルのソースコードからドキュメント生成してみます。
また複数クラスのシュッツ力サンプル用にサンプルのAnimalクラスのクラス名をDocに変更しただけの
クラスも作成してからドキュメント生成してみました。

# Base class for all animals.
#
# @example How to subclass an animal
#   class Lion extends Animal
#     move: (direction, speed): ->
#
class Example.Animal

  # The Answer to the Ultimate Question of Life, the Universe, and Everything
  @ANSWER = 42

  # Construct a new animal.
  #
  # @param [String] name the name of the animal
  # @param [Date] birthDate when the animal was born
  #
  constructor: (@name, @birthDate = new Date()) ->

  # Move the animal.
  #
  # @example Move an animal
  #   new Lion('Simba').move('south', 12)
  #
  # @param [Object] options the moving options
  # @option options [String] direction the moving direction
  # @option options [Number] speed the speed in mph
  #
  move: (options = {}) ->
出力結果