LoginSignup
1
1

More than 5 years have passed since last update.

Pow(powder) + Yard で rubygemsのドキュメントをローカルで手軽に読む

Posted at

何をするのか

yard server --gems と同等のものを、コマンドライン入力なしでブラウザから yard.ded にアクセスするだけで見れるようにする

前提

環境によってはgemの前にsudo必要だったり色々あるけど、僕はrbenv使ってるので必要ない。適宜読み替えてください。

# pow 入れとく
curl get.pow.cx | sh
# powder も入れとく
gem install powder
# yardも入れとく
gem install yard

やること

# 適当な所でyardディレクトリを作る。 Documentsとかその辺がオススメ
mkdir yard
cd yard
# config.ru を編集
vim config.ru
config.ru
require "bundler/setup"

require "rack"
require "yard"

# YARD exposes a global `log`, yuck
log.level = Logger::DEBUG

# Global state lololololol
YARD::Server::RackAdapter.setup

# We need to tell YARD what to serve
#
# A little Sinatra app which dynamically browses gems and ruby versions would
# be nice eventually. Perhaps even a way to publish a project directory with a
# Gemfile.lock to expose the project docs and with its bundled gems would be
# cool, too.
libraries = {}

Gem.source_index.find_name('').each do |spec|
  libraries[spec.name] ||= []
  libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)]
end

run YARD::Server::RackAdapter.new(libraries)

※これはここから拝借してきました
https://github.com/sj26/yard-rack/blob/master/config.ru

# yard ディレクトリで
powder link

これだけ。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1