Skip to content

Commit

Permalink
Generate docs using YARD
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Jun 20, 2014
1 parent c22d7c8 commit 4d8faed
Show file tree
Hide file tree
Showing 41 changed files with 7,300 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--no-private
--protected
--readme README.md
--files lib/**/*.rb
--markup markdown
--hide-tag return
--hide-tag param
-e ./doc_config/yard/setup.rb
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ gem 'rails', '~> 3.0'
gem 'rake', '>= 0.9.2'
gem 'rspec-rails', '>= 2.13.1', '< 3'

# YARD
gem 'yard'
gem 'redcarpet'
gem 'pygments.rb'
gem 'watchr'

# For test Rails application
gem 'shoulda-context', '~> 1.2.0'
gem 'sqlite3', :platform => :ruby
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ GEM
multi_json (1.8.4)
multi_test (0.0.3)
polyglot (0.3.3)
posix-spawn (0.3.8)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.3.7)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
Expand All @@ -104,6 +108,7 @@ GEM
rake (10.1.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.0.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
Expand All @@ -130,6 +135,9 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)

PLATFORMS
ruby
Expand All @@ -145,10 +153,14 @@ DEPENDENCIES
jdbc-sqlite3
jruby-openssl
pry
pygments.rb
rails (~> 3.0)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
shoulda-context (~> 1.2.0)
shoulda-matchers!
sqlite3
therubyrhino
watchr
yard
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ gem 'shoulda-matchers'
gem 'activemodel'
```

## Generating documentation

YARD is used to generate documentation, which can be viewed online at
<http://thoughtbot.github.com/shoulda-matchers>. You can preview changes you
make to the documentation locally by running

yard doc

from this directory. Then, open `doc/index.html` in your browser.

If you want to see a live preview as you work without having to run `yard` over
and over again, keep this command running in a separate terminal session:

watchr yard.watchr

## Versioning

shoulda-matchers follows Semantic Versioning 2.0 as defined at
Expand Down
22 changes: 22 additions & 0 deletions doc_config/yard/setup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/templates')

require 'pygments.rb'

module YARD
module Templates
module Helpers
module HtmlSyntaxHighlightHelper
def html_syntax_highlight_ruby(source)
highlight_with_pygments(:ruby, source)
end

private

def highlight_with_pygments(language, source)
html = Pygments.highlight(source, lexer: language.to_s)
html.sub(%r{\A<div class="highlight">\s*<pre>}, '').sub(%r{</pre>\s*</div>\Z}, '')
end
end
end
end
end
Loading

0 comments on commit 4d8faed

Please sign in to comment.