Permalink
Browse files

adding initial horo template

  • Loading branch information...
0 parents commit ef380609031c27c3e3cb2fa2a1641aa7791080a6 @tenderlove committed Jul 13, 2010
Showing with 223 additions and 0 deletions.
  1. +23 −0 .autotest
  2. +6 −0 CHANGELOG.rdoc
  3. +10 −0 Manifest.txt
  4. +48 −0 README.rdoc
  5. +14 −0 Rakefile
  6. +22 −0 lib/app/views/root/index.html.erb
  7. +3 −0 lib/horo.rb
  8. +1 −0 lib/rdoc/discover.rb
  9. +60 −0 lib/rdoc/generator/horo.rb
  10. +36 −0 test/test_horo.rb
@@ -0,0 +1,23 @@
+# -*- ruby -*-
+
+require 'autotest/restart'
+
+# Autotest.add_hook :initialize do |at|
+# at.extra_files << "../some/external/dependency.rb"
+#
+# at.libs << ":../some/external"
+#
+# at.add_exception 'vendor'
+#
+# at.add_mapping(/dependency.rb/) do |f, _|
+# at.files_matching(/test_.*rb$/)
+# end
+#
+# %w(TestA TestB).each do |klass|
+# at.extra_class_map[klass] = "test/test_misc.rb"
+# end
+# end
+
+# Autotest.add_hook :run_command do |at|
+# system "rake build"
+# end
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2010-07-13
+
+* 1 major enhancement
+
+ * Birthday!
+
@@ -0,0 +1,10 @@
+.autotest
+CHANGELOG.rdoc
+Manifest.txt
+README.rdoc
+Rakefile
+lib/app/views/root/index.html.erb
+lib/horo.rb
+lib/rdoc/discover.rb
+lib/rdoc/generator/horo.rb
+test/test_horo.rb
@@ -0,0 +1,48 @@
+= horo
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2010 Aaron Patterson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+
+Hoe.spec 'horo' do
+ developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
+ self.readme_file = 'README.rdoc'
+ self.history_file = 'CHANGELOG.rdoc'
+ self.extra_rdoc_files = FileList['*.rdoc']
+ self.extra_dev_deps << ['nokogiri', '>= 1.4.2']
+end
+
+# vim: syntax=ruby
@@ -0,0 +1,22 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title><%= title %></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
+</head>
+
+<frameset cols="20%,*">
+ <frameset rows="15%,55%,30%">
+ <frame src="fr_file_index.html" title="Files" name="Files" />
+ <frame src="fr_class_index.html" name="Classes" />
+ <frame src="fr_method_index.html" name="Methods" />
+ </frameset>
+ <frame src="<%= main_page %>" name="docwin" />
+ <noframes>
+ <body bgcolor="white">
+ Click <a href="html/index.html">here</a> for a non-frames
+ version of this page.
+ </body>
+ </noframes>
+</frameset>
+
+</html>
@@ -0,0 +1,3 @@
+class Horo
+ VERSION = '1.0.0'
+end
@@ -0,0 +1 @@
+require 'rdoc/generator/horo'
@@ -0,0 +1,60 @@
+require 'rdoc/generator'
+require 'rdoc/rdoc'
+require 'erb'
+
+class RDoc::Generator::Horo
+ RDoc::RDoc.add_generator self
+
+ class << self
+ alias :for :new
+ end
+
+ def initialize options
+ @options = options
+ @files = nil
+ @classes = nil
+ @methods = nil
+ @app_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
+ @op_dir = File.expand_path options.op_dir
+ end
+
+ def generate top_levels
+ @files = top_levels
+ @classes = RDoc::TopLevel.all_classes_and_modules
+ @methods = @classes.map { |x| x.method_list }.flatten
+
+ write_index
+ end
+
+ private
+ def write_index
+ filename = File.join @app_root, 'app', 'views', 'root', 'index.html.erb'
+ ctx = TemplateContext.new @options
+ ctx.extend IndexHelper
+ File.open(File.join(@op_dir, 'index.html'), 'wb') do |fh|
+ fh.write ctx.eval File.read(filename), filename
+ end
+ end
+
+ module IndexHelper
+ def title
+ options.title
+ end
+
+ def charset
+ options.charset
+ end
+
+ def main_page
+ options.main_page + ".html"
+ end
+ end
+
+ class TemplateContext < Struct.new :options
+ def eval src, filename
+ template = ERB.new src
+ template.filename = filename
+ template.result binding
+ end
+ end
+end
@@ -0,0 +1,36 @@
+require 'test/unit'
+require 'rdoc/generator/horo'
+require 'tempfile'
+require 'nokogiri'
+
+class TestHoro < Test::Unit::TestCase
+ def setup
+ $-w = false
+ rdoc = RDoc::RDoc.new
+ @title = 'Ruby on Rails Documentation'
+
+ rdoc.document [
+ '-q',
+ '-f', 'horo',
+ '--title', @title,
+ '--main', 'railties/README',
+ '--charset', 'utf-8',
+ ]
+ $-w = true
+ end
+
+ def test_index
+ assert_file 'doc/index.html'
+ doc = File.open('doc/index.html', 'rb') { |f| Nokogiri.HTML f }
+ assert_equal @title, doc.css('title').first.content
+ end
+
+ def teardown
+ FileUtils.rm_rf(File.join(File.dirname(__FILE__), '..', 'doc'))
+ end
+
+ private
+ def assert_file name
+ assert File.exists?(name), "missing file: #{name}"
+ end
+end

0 comments on commit ef38060

Please sign in to comment.