finish some docs

This commit is contained in:
John Bintz 2011-06-18 12:33:23 -04:00
parent 9515c25b23
commit cfa7f86bc9
3 changed files with 25 additions and 2 deletions

13
README.md Normal file
View File

@ -0,0 +1,13 @@
It's a [Guard](http://github.com/guard/guard) for the [Rocco](http://github.com/rtomayko/rocco) documentation system!
guard 'rocco' do
watch(%r{app/.*\.(rb|coffee)})
watch(%r{lib/.*\.rb})
end
Only one option for now:
* `:dir` specifies the output dir (default `doc`)
`gem install guard-rocco` or Bundle it up with `gem 'guard-rocco'`. Yeah!

View File

@ -22,8 +22,8 @@ module Guard
end
private
def build(path)
target = File.join(@options[:dir], path).gsub(%r{\.[^\.]+$}, '.html')
def build(path, target = nil)
target ||= self.filename_to_target(path)
puts "rocco: #{path} -> #{target}"
File.open(target, 'wb') { |fh| fh.print ::Rocco.new(path, all_paths).to_html }
end
@ -31,6 +31,10 @@ module Guard
def all_paths
Watcher.match_files(self, Dir['**/*'])
end
def self.filename_to_target(path)
File.join(@options[:dir], path).gsub(%r{\.[^\.]+$}, '.html')
end
end
end

View File

@ -0,0 +1,6 @@
guard 'rocco' do
# For Rails 3.0.x and 3.1
watch(%r{app/.*\.(rb|coffee)})
watch(%r{lib/.*\.rb})
end