花了半个多月的时间写了个小工具 Description, Description 能对你的 rails 项目的 ActiveRecord::Migration 文件进行分析,然后得到和项目有关的数据库文档
git clone https://github.com/baya/description.git
cd description
bundle install
在 description 目录下执行
chmod +x bin/describle
bin/describle /path/to/your/rails/app
然后使用浏览器访问 http://localhost:9393
1.提取 migration 文件中的 comment,比如你创建一个表 contests,
    class CreateContests < ActiveRecord::Migration
    def change
      create_table :contests do |t|
        t.integer    :itype, default: 0, null: false  # 比赛形式, 0 photo, 1 video, 2 word, 3 audio, 4 组合
        t.integer    :mode, default: 0, null: false   # 是否可加入比赛, 0 pk, 1 调查, 2 多选
        t.integer    :format, default: 0, null: false # 比赛方式, 1 pk, 0 binary(传统比赛)
        t.date       :start_day                       # 比赛开始日期
        t.integer    :length                          # 比赛时长以天为单位
        t.integer    :vote_right                      # 投票权, 0 public, 1 friends only, 2 specific
        t.integer    :contestant_right                # 参赛权, 0 public, 1 friedns only, 2 specific
        t.string     :logo                            # 比赛logo,图片
        t.timestamps
      end
    end
end
然后在后面的开发中有增加字段或者重命名字段,
class AddStatusToContests < ActiveRecord::Migration
   def change
      add_column :contests, :pub_status, :integer, default: 0 # 发布状态, 0 草稿, 1 发布
   end
end
description 会将你的代码解析成一个 markdown 格式的 table,

2.快速检索表和字段 有些项目的表很多,表很大,在 description 中,你可以通过表名和字段名快速找出你想要查看的表和字段


3.提供表的 markdown 文件的下载

结合 mou 等工具你可以很容易制作出十几页的项目文档,从此你就不需要为项目 交接时的文档发愁了
这个小工具完全是为自己的工作需要而开发的,觉得有用 (至少对我自己来说),就分享出来了。 我主要用 activerecord,所以没有提供其他 orm 框架的支持了。