[ruby] anything.el + refe2 のDBとindexを自動生成するようにした
id:rubikitch のRuby リファレンスマニュアル(通称るりま)と ReFe2 をインストール・ Emacs で参照する・ anything.el との連携 - http://rubikitch.com/に移転しましたを参考にanything.elとrefe2を使えるようにした。
ただ気がつけば(とっくに)安定版は1.8.7だし開発版も1.9.2devなのでDBとかindexを作るあたりを自動化しておいた。
bitclustとhttp://doc.loveruby.net/wiki/SubversionRepository.html:るりまのSVN HEADを同じディレクトリにチェックアウトしてさらに以下のRakefileを同じディレクトリに置く。
require 'bitclust/bin/bitclust' task :default do ['1.9.1', '1.8.7'].each do |version| BASE_DIR = File.dirname(File.expand_path(__FILE__)) db_path = BASE_DIR + '/db-' + version.gsub(/\./, '_') db = BitClust::MethodDatabase.new(db_path) unless File.exists? db_path cmd = InitCommand.new cmd.exec db, ["version=#{version}", "encoding=euc-jp"] end cmd = UpdateCommand.new cmd.instance_eval do @root = BASE_DIR + '/doctree/refm/api/src' end cmd.exec db, [] list = db.classes.map {|c| c.name }.sort db.classes.sort_by {|c| c.name }.each do |c| c.entries.sort_by {|m| m.id }.each do |m| list << m.label end end list.map!{|line| "# (refe2 \"#{line}\")"} File.open(BASE_DIR + "/refe_#{version}.e", 'w') do |f| f.write(list.join("\n")) end end end
それからbitclustのコマンドラインツールをライブラリとして扱えるようにちょっとだけ手を加える
diff --git a/bin/bitclust.rb b/bin/bitclust.rb index c21a4aa..642e160 100755 --- a/bin/bitclust.rb +++ b/bin/bitclust.rb @@ -504,5 +504,6 @@ class PropertyCommand < Subcommand end - -main +if $0 == __FILE__ + main +end
で実行するとこんな感じ
$ ls Rakefile bitclust doctree $ rake // なんかいろいろ出てくる $ ls Rakefile bitclust db-1_8_7 db-1_9_1 doctree refe_1.8.7.e refe_1.9.1.e