Вопрос

How I can run Yard server on production server? Maybe use some task? Load from capistrano, using passenger and nginx, Jenkins(Hudson).

Это было полезно?

Решение 3

I'm use this shell script:

#!/bin/sh
#or you process here
PROCESS='ruby */yard server'
PID=`pidof $PROCESS`

start() {
  yard server &
}

stop() {
  if [ "$PID" ];then
    kill -KILL $PID
    echo 'yard is stopped'
  fi
}

case "$1" in
start)
  start
;;
stop)
  stop
;;
restart)
  stop
  start
;;
*)
echo Usage: $0 [start|stop|restart]
;;
esac

And in Hudson: yard doc && ./yard.sh restart.

Другие советы

I found the simplest option to be just symlinking the generated docs folder from /public in my rails app. You just need to be sure that the js/css resources are accessible via the same path.

For example:

$ cd <railsapp>
$ ls
Gemfile
app/
..
public/
doc/ <- Folder that contains the html files generated by yard
$ cd public/
$ ln -s ../doc/ docs

This would serve your docs at /docs/index.html

The javascript based search for classes/methods/files still works as it is javascript based. However the search that appears on the top won't appear in this method. However I found the javascript based search sufficient.

I use nginx and passenger, serving this tiny web app:

# ~/Documentation/config.ru
require 'rubygems'
require 'yard'

libraries = {}
gems = 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

Nginx virtual host:

# /opt/nginx/config/sites-enabled/gems.doc
server {
  listen 80;
  server_name gems.doc;
  root /Users/your-user/Documentation/yard/public;
  rails_env development;
  passenger_enabled on;
}

More in this post: http://makarius.me/offline-rails-ruby-jquery-and-gems-docs-with

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top