Permalink
Browse files

* Old files removed.. These are no longer used.

  • Loading branch information...
Erik Hollensbe
Erik Hollensbe committed Jul 9, 2010
1 parent f90c5ed commit 1e2bd172404a5f7938bcfbee37a0890fa8558a54
Showing with 0 additions and 281 deletions.
  1. +0 −81 bin/hanna
  2. +0 −43 lib/hanna/rdoctask.rb
  3. +0 −119 lib/hanna/template_helpers.rb
  4. +0 −38 lib/hanna/template_page_patch.rb
View
@@ -1,81 +0,0 @@
-#!/usr/bin/ruby
-if ARGV.size == 1 and ARGV.first == '-h'
- puts <<-HELP
-Hanna -- a better RDoc template
-Synopsis:
- hanna [options] [file names...]
- [sudo] hanna --gems [gem names...]
-
-Example usage:
-
- hanna lib/**/*.rb
-
-Hanna passes all arguments to RDoc. To find more about RDoc options, see
-"rdoc -h". Default options are:
-
- -o doc --inline-source --charset=UTF-8
-
-The second form, with the "--gems" argument, serves the same purpose as
-the "gem rdoc" command: it generates documentation for installed gems.
-When no gem names are given, "hanna --gems" will install docs for EACH of
-the gems, which can, uh, take a little while.
-
-HELP
- exit 0
-end
-
-unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
- require 'pathname'
- hanna_dir = Pathname.new(__FILE__).realpath.dirname + '../lib'
-else
- # windows
- hanna_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
-end
-
-$:.unshift(hanna_dir) unless $:.include?(hanna_dir)
-
-require 'rubygems'
-require 'hanna/version'
-Hanna::require_rdoc
-require 'rdoc/rdoc'
-
-options = []
-
-options << '-f' << 'html' << '-T' << 'hanna'
-options << '--inline-source' << '--charset=UTF-8'
-
-if ARGV.first == '--gems'
- require 'rubygems/doc_manager'
- Gem::DocManager.configured_args = options
-
- gem_names = ARGV.dup
- gem_names.shift
-
- unless gem_names.empty?
- specs = gem_names.inject([]) do |arr, name|
- found = Gem::SourceIndex.from_installed_gems.find_name(name)
- spec = found.sort_by {|s| s.version }.last
- arr << spec if spec
- arr
- end
- else
- specs = Gem::SourceIndex.from_installed_gems.inject({}) do |all, pair|
- full_name, spec = pair
- if spec.has_rdoc? and (!all[spec.name] or spec.version > all[spec.name].version)
- all[spec.name] = spec
- end
- all
- end
- specs = specs.values
- puts "Hanna is installing documentation for #{specs.size} gem#{specs.size > 1 ? 's' : ''} ..."
- end
-
- specs.each do |spec|
- Gem::DocManager.new(spec).generate_rdoc
- end
-else
- options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
- options.concat ARGV
-
- RDoc::RDoc.new.document(options)
-end
View
@@ -1,43 +0,0 @@
-require 'rdoc/rdoc'
-require 'hanna'
-gem 'rdoc'
-require 'rdoc/task'
-
-class Hanna::Task < RDoc::Task
- # don't allow it
- undef :external=, :template=
-
- # Create the tasks defined by this task lib.
- def define
- options << '-f hanna'
-
- # inline source and UTF-8 are defaults:
- options << '--inline-source' unless options.include? '--inline-source' or options.include? '-S'
- options << '--charset=UTF-8' if options.grep(/^(--charset\b|-c\b)/).empty?
-
- super
- #desc "Build the HTML documentation"
- #task name
-
- #desc "Force a rebuild of the RDOC files"
- #task paste("re", name) => [paste("clobber_", name), name]
-
- #desc "Remove rdoc products"
- #task paste("clobber_", name) do
- #rm_r rdoc_dir rescue nil
- #end
-
- #task :clobber => [paste("clobber_", name)]
-
- #directory @rdoc_dir
- #task name => [rdoc_target]
- #file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
- #rm_r @rdoc_dir rescue nil
- #Hanna::require_rdoc
- #require 'rdoc/rdoc'
-
- #RDoc::RDoc.new.document(option_list + @rdoc_files)
- #end
- #return self
- end
-end
@@ -1,119 +0,0 @@
-require 'yaml'
-require 'cgi'
-
-module Hanna
- module TemplateHelpers
- protected
-
- def link_to(text, url = nil, classname = nil)
- class_attr = classname ? ' class="%s"' % classname : ''
-
- if url
- %[<a href="#{url}"#{class_attr}>#{text}</a>]
- elsif classname
- %[<span#{class_attr}>#{text}</span>]
- else
- text
- end
- end
-
- # +method_text+ is in the form of "ago (ActiveSupport::TimeWithZone)".
- def link_to_method(method_text, url = nil, classname = nil)
- method_text =~ /\A(.+) \((.+)\)\Z/
- method_name, module_name = $1, $2
- link_to %Q(<span class="method_name">#{h method_name}</span> <span class="module_name">(#{h module_name})</span>), url, classname
- end
-
- def read(*names)
- RDoc::Generator::HTML::HANNA.read(*names)
- end
-
- # We need to suppress warnings before calling into HAML because
- # HAML has lots of uninitialized instance variable accesses.
- def silence_warnings
- save = $-w
- $-w = false
-
- begin
- yield
- ensure
- $-w = save
- end
- end
- module_function :silence_warnings
-
- def debug(text)
- "<pre>#{h YAML::dump(text)}</pre>"
- end
-
- def h(html)
- CGI::escapeHTML(html)
- end
-
- # +entries+ is an array of hashes, each which has a "name" and "href" element.
- # An entry name is in the form of "ago (ActiveSupport::TimeWithZone)".
- # +entries+ must be already sorted by name.
- def build_javascript_search_index(entries)
- result = "var search_index = [\n"
- entries.each do |entry|
- entry[:name] =~ /\A(.+) \((.+)\)\Z/
- method_name, module_name = $1, $2
- html = link_to_method(entry[:name], entry[:href])
- result << " { method: '#{method_name.downcase}', " <<
- "module: '#{module_name.downcase}', " <<
- "html: '#{html}' },\n"
- end
- result << "]"
- result
- end
-
- def methods_from_sections(sections)
- sections.inject(Hash.new {|h, k| h[k] = []}) do |methods, section|
- section[:method_list].each do |ml|
- methods["#{ml[:type]} #{ml[:category]}".downcase].concat ml[:methods]
- end if section[:method_list]
- methods
- end
- end
-
- def make_class_tree(entries)
- entries.inject({}) do |tree, entry|
- if entry[:href]
- leaf = entry[:name].split('::').inject(tree) do |branch, klass|
- branch[klass] ||= {}
- end
- leaf['_href'] = entry[:href]
- end
- tree
- end
- end
-
- def render_class_tree(tree, parent = nil)
- parent = parent + '::' if parent
- tree.keys.sort.inject('') do |out, name|
- unless name == '_href'
- subtree = tree[name]
- text = parent ? '<span class="parent">%s</span>%s' % [parent, name] : name
- out << '<li>'
- out << (subtree['_href'] ? link_to(text, subtree['_href']) : %[<span class="nodoc">#{text}</span>])
- if subtree.keys.size > 1 || (subtree.keys.size == 1 && !subtree['_href'])
- out << "\n<ol>" << render_class_tree(subtree, parent.to_s + name) << "\n</ol>"
- end
- out << '</li>'
- end
- out
- end
- end
-
- # primarily for removing leading whitespace in <pre> tags
- def sanitize_code_blocks(text)
- text.gsub(/<pre>(.+?)<\/pre>/m) do
- code = $1.sub(/^\s*\n/, '')
- indent = code.gsub(/\n[ \t]*\n/, "\n").scan(/^ */).map{ |i| i.size }.min
- code.gsub!(/^#{' ' * indent}/, '') if indent > 0
-
- "<pre>#{code}</pre>"
- end
- end
- end
-end
@@ -1,38 +0,0 @@
-require 'hanna/template_helpers'
-
-RDoc::TemplatePage.class_eval do
-
- include Hanna::TemplateHelpers
-
- # overwrite the original method
- alias :old_write_html_on :write_html_on # suppresses the overwrite warning
- def write_html_on(io, values)
- result = @templates.reverse.inject(nil) do |previous, template|
- case template
- when Haml::Engine
- silence_warnings do
- template.to_html(binding, :values => values) { previous }
- end
- when Sass::Engine
- silence_warnings { template.to_css }
- when String
- ERB.new(template).result(get_binding(values){ previous })
- when nil
- previous
- else
- raise "don't know how to handle a template of class '#{template.class.name}'"
- end
- end
-
- io.write result
- rescue
- $stderr.puts "error while writing to #{io.inspect}"
- raise
- end
-
- private
-
- def get_binding(values = nil)
- binding
- end
-end

0 comments on commit 1e2bd17

Please sign in to comment.