ddollar-hanna 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ bin/hanna
2
+ lib/hanna/hanna.rb
3
+ lib/hanna/rdoc_version.rb
4
+ lib/hanna/rdoctask.rb
5
+ lib/hanna/template_files/class_index.haml
6
+ lib/hanna/template_files/file_index.haml
7
+ lib/hanna/template_files/index.haml
8
+ lib/hanna/template_files/layout.haml
9
+ lib/hanna/template_files/method_list.haml
10
+ lib/hanna/template_files/method_search.js
11
+ lib/hanna/template_files/page.haml
12
+ lib/hanna/template_files/prototype-1.6.0.3.js
13
+ lib/hanna/template_files/sections.haml
14
+ lib/hanna/template_files/styles.sass
15
+ lib/hanna/template_helpers.rb
16
+ lib/hanna/template_page_patch.rb
17
+ lib/hanna.rb
18
+ Rakefile
19
+ README.markdown
20
+ Manifest
@@ -0,0 +1,106 @@
1
+ # Hanna -- a better RDoc template
2
+
3
+ Hanna is an RDoc template that scales. It's implemented in Haml, making the
4
+ sources clean and readable. It's built with simplicity, beauty and ease of
5
+ browsing in mind. (See more in [the wiki][wiki].)
6
+
7
+ Hanna was made by [Mislav][] and is available from [GitHub][]:
8
+
9
+ gem install mislav-hanna
10
+
11
+
12
+ ## Usage
13
+
14
+ After installing, you have several options.
15
+ ---
16
+ Hanna can be used as a normal RDoc template by specifying
17
+ -S -T hanna
18
+ to rdoc. Note that Hanna requires the -S option, which inlines source
19
+ code.
20
+ ---
21
+ You can use the command-line tool included in the Hanna gem:
22
+
23
+ hanna -h
24
+
25
+ This is a wrapper over the rdoc script that makes RDoc use the Hanna
26
+ template.
27
+ ---
28
+ For repeated generation of API docs, it's better to set up a Rake task.
29
+ If you already have an RDocTask set up in your Rakefile, the only thing
30
+ you need to change is this:
31
+
32
+ # replace this:
33
+ require 'rake/rdoctask'
34
+ # with this:
35
+ require 'hanna/rdoctask'
36
+
37
+ Tip: you can do this in the Rakefile of your Rails project before running `rake
38
+ doc:rails`.
39
+
40
+ Here is an example of a task for the [will_paginate library][wp]:
41
+
42
+ # instead of 'rake/rdoctask':
43
+ require 'hanna/rdoctask'
44
+
45
+ desc 'Generate RDoc documentation for the will_paginate plugin.'
46
+ Rake::RDocTask.new(:rdoc) do |rdoc|
47
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG').
48
+ include('lib/**/*.rb').
49
+ exclude('lib/will_paginate/named_scope*').
50
+ exclude('lib/will_paginate/array.rb').
51
+ exclude('lib/will_paginate/version.rb')
52
+
53
+ rdoc.main = "README.rdoc" # page to start on
54
+ rdoc.title = "will_paginate documentation"
55
+
56
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
57
+ rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
58
+ end
59
+
60
+ Alternatively, you can use the the standard RDocTask and simply set the
61
+ task's +template+ attribute to +hanna+ and append +--inline-source+ to its
62
+ options attribute.
63
+
64
+ A third alternative is to set the +RDOCOPT+ environment variable to
65
+
66
+ -T hanna -S
67
+
68
+ which will make RDoc always use Hanna unless this is overridden on the
69
+ command-line.
70
+ --
71
+ You also can generate documentation for installed gems, which might be more
72
+ convenient than the
73
+
74
+ gem rdoc
75
+
76
+ command (with the +RDOCOPT+ environment variable set as above). For this, do:
77
+
78
+ [sudo] hanna --gems haml will_paginate
79
+
80
+ ## A work in progress
81
+
82
+ Hanna is far from done, but it is the first RDoc template that's actually
83
+ _maintainable_. First thing I have done is converted the original HTML
84
+ template to Haml and Sass, cleaning up and removing the (ridiculous amount of)
85
+ duplication.
86
+
87
+ Also, the template fragments are now in _separate files_. You would have
88
+ fainted if you seen how it was before. (It's really no wonder why there are no
89
+ other RDoc templates around ... save one: [Allison][].)
90
+
91
+ Ultimately, I'd like to lose the frameset. Currently that is far from possible
92
+ because the whole RDoc HTML Generator is built for frames. Still, that is my
93
+ goal.
94
+
95
+ ## You can help
96
+
97
+ Don't like something? Think you can design better? (You probably can.)
98
+
99
+ This is git. I welcome all submissions towards my goal.
100
+
101
+
102
+ [wiki]: http://github.com/mislav/hanna/wikis/home "Hanna wiki"
103
+ [GitHub]: http://gems.github.com/ "GitHub gem source"
104
+ [wp]: http://github.com/mislav/will_paginate
105
+ [Mislav]: http://mislav.caboo.se/ "Mislav Marohnić"
106
+ [Allison]: http://blog.evanweaver.com/files/doc/fauna/allison/ "A modern, pretty RDoc template"
@@ -0,0 +1,24 @@
1
+ #
2
+ # This can be made cleaner by using the relative gem.
3
+ #
4
+ require File.join(File.dirname(__FILE__), "lib/hanna/rdoc_version")
5
+
6
+ require 'echoe'
7
+
8
+ Echoe.new('hanna') do |p|
9
+ p.version = '0.1.4'
10
+
11
+ p.summary = "An RDoc template that rocks"
12
+ p.description = "Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind."
13
+
14
+ p.author = 'Mislav Marohnić'
15
+ p.email = 'mislav.marohnic@gmail.com'
16
+ p.url = 'http://github.com/mislav/hanna'
17
+
18
+ p.executable_pattern = ['bin/hanna']
19
+ p.has_rdoc = false
20
+ p.runtime_dependencies = []
21
+ p.runtime_dependencies << ['rdoc', Hanna::RDOC_VERSION_REQUIREMENT]
22
+ p.runtime_dependencies << ['haml', '~> 2.0']
23
+ p.runtime_dependencies << ['rake', '~> 0.8.2']
24
+ end
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/ruby
2
+ if ARGV.size == 1 and ARGV.first == '-h'
3
+ puts <<-HELP
4
+ Hanna -- a better RDoc template
5
+ Synopsis:
6
+ hanna [options] [file names...]
7
+ [sudo] hanna --gems [gem names...]
8
+
9
+ Example usage:
10
+
11
+ hanna lib/**/*.rb
12
+
13
+ Hanna passes all arguments to RDoc. To find more about RDoc options, see
14
+ "rdoc -h". Default options are:
15
+
16
+ -o doc --inline-source --charset=UTF-8
17
+
18
+ The second form, with the "--gems" argument, serves the same purpose as
19
+ the "gem rdoc" command: it generates documentation for installed gems.
20
+ When no gem names are given, "hanna --gems" will install docs for EACH of
21
+ the gems, which can, uh, take a little while.
22
+
23
+ HELP
24
+ exit 0
25
+ end
26
+
27
+ require 'rubygems'
28
+
29
+ hanna_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $:.unshift(hanna_dir) unless $:.include?(hanna_dir)
31
+
32
+ require 'hanna/rdoc_version'
33
+ Hanna::require_rdoc
34
+ require 'rdoc/rdoc'
35
+
36
+ options = []
37
+
38
+ options << '-T' << 'hanna'
39
+ options << '--inline-source' << '--charset=UTF-8'
40
+
41
+ if ARGV.first == '--gems'
42
+ require 'rubygems/doc_manager'
43
+ Gem::DocManager.configured_args = options
44
+
45
+ gem_names = ARGV.dup
46
+ gem_names.shift
47
+
48
+ unless gem_names.empty?
49
+ specs = gem_names.inject([]) do |arr, name|
50
+ found = Gem::SourceIndex.from_installed_gems.find_name(name)
51
+ spec = found.sort_by {|s| s.version }.last
52
+ arr << spec if spec
53
+ arr
54
+ end
55
+ else
56
+ specs = Gem::SourceIndex.from_installed_gems.inject({}) do |all, pair|
57
+ full_name, spec = pair
58
+ if spec.has_rdoc? and (!all[spec.name] or spec.version > all[spec.name].version)
59
+ all[spec.name] = spec
60
+ end
61
+ all
62
+ end
63
+ specs = specs.values
64
+ puts "Hanna is installing documentation for #{specs.size} gem#{specs.size > 1 ? 's' : ''} ..."
65
+ end
66
+
67
+ specs.each do |spec|
68
+ Gem::DocManager.new(spec).generate_rdoc
69
+ end
70
+ else
71
+ options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
72
+ options.concat ARGV
73
+
74
+ RDoc::RDoc.new.document(options)
75
+ end
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{hanna}
5
+ s.version = "0.1.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Mislav Marohni\304\207"]
9
+ s.date = %q{2008-11-18}
10
+ s.default_executable = %q{hanna}
11
+ s.description = %q{Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind.}
12
+ s.email = %q{mislav.marohnic@gmail.com}
13
+ s.executables = ["hanna"]
14
+ s.extra_rdoc_files = ["bin/hanna", "lib/hanna/hanna.rb", "lib/hanna/rdoc_version.rb", "lib/hanna/rdoctask.rb", "lib/hanna/template_files/class_index.haml", "lib/hanna/template_files/file_index.haml", "lib/hanna/template_files/index.haml", "lib/hanna/template_files/layout.haml", "lib/hanna/template_files/method_list.haml", "lib/hanna/template_files/method_search.js", "lib/hanna/template_files/page.haml", "lib/hanna/template_files/prototype-1.6.0.3.js", "lib/hanna/template_files/sections.haml", "lib/hanna/template_files/styles.sass", "lib/hanna/template_helpers.rb", "lib/hanna/template_page_patch.rb", "lib/hanna.rb", "README.markdown"]
15
+ s.files = ["bin/hanna", "lib/hanna/hanna.rb", "lib/hanna/rdoc_version.rb", "lib/hanna/rdoctask.rb", "lib/hanna/template_files/class_index.haml", "lib/hanna/template_files/file_index.haml", "lib/hanna/template_files/index.haml", "lib/hanna/template_files/layout.haml", "lib/hanna/template_files/method_list.haml", "lib/hanna/template_files/method_search.js", "lib/hanna/template_files/page.haml", "lib/hanna/template_files/prototype-1.6.0.3.js", "lib/hanna/template_files/sections.haml", "lib/hanna/template_files/styles.sass", "lib/hanna/template_helpers.rb", "lib/hanna/template_page_patch.rb", "lib/hanna.rb", "Rakefile", "README.markdown", "Manifest", "hanna.gemspec"]
16
+ s.homepage = %q{http://github.com/mislav/hanna}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Hanna", "--main", "README.markdown"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{hanna}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{An RDoc template that rocks}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<rdoc>, ["~> 2.2.0"])
29
+ s.add_runtime_dependency(%q<haml>, ["~> 2.0"])
30
+ s.add_runtime_dependency(%q<rake>, ["~> 0.8.2"])
31
+ s.add_development_dependency(%q<echoe>, [">= 0"])
32
+ else
33
+ s.add_dependency(%q<rdoc>, ["~> 2.2.0"])
34
+ s.add_dependency(%q<haml>, ["~> 2.0"])
35
+ s.add_dependency(%q<rake>, ["~> 0.8.2"])
36
+ s.add_dependency(%q<echoe>, [">= 0"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<rdoc>, ["~> 2.2.0"])
40
+ s.add_dependency(%q<haml>, ["~> 2.0"])
41
+ s.add_dependency(%q<rake>, ["~> 0.8.2"])
42
+ s.add_dependency(%q<echoe>, [">= 0"])
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ require 'hanna/hanna'
@@ -0,0 +1,48 @@
1
+ # = A better RDoc HTML template
2
+ #
3
+ # Authors: Mislav Marohnić <mislav.marohnic@gmail.com>
4
+ # Tony Strauss (http://github.com/DesigningPatterns)
5
+ # Michael Granger <ged@FaerieMUD.org>, who had maintained the original RDoc template
6
+
7
+ require 'haml'
8
+ require 'sass'
9
+ require 'rdoc/generator/html'
10
+ require 'hanna/template_page_patch'
11
+
12
+ module RDoc::Generator::HTML::HANNA
13
+ class << self
14
+ def dir
15
+ @dir ||= File.join File.dirname(__FILE__), 'template_files'
16
+ end
17
+
18
+ def read(*names)
19
+ content = names.inject('') { |all, name| all << File.read(File.join(dir, name)) }
20
+ extension = names.first =~ /\.(\w+)$/ && $1
21
+
22
+ Hanna::TemplateHelpers.silence_warnings do
23
+ case extension
24
+ when 'sass'
25
+ Sass::Engine.new(content)
26
+ when 'haml'
27
+ Haml::Engine.new(content, :format => :html4)
28
+ else
29
+ content
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ STYLE = read('styles.sass')
36
+
37
+ CLASS_PAGE = read('page.haml')
38
+ FILE_PAGE = CLASS_PAGE
39
+ METHOD_LIST = read('method_list.haml', 'sections.haml')
40
+
41
+ FR_INDEX_BODY = BODY = read('layout.haml')
42
+
43
+ FILE_INDEX = read('file_index.haml')
44
+ CLASS_INDEX = read('class_index.haml')
45
+ METHOD_INDEX = FILE_INDEX
46
+
47
+ INDEX = read('index.haml')
48
+ end
@@ -0,0 +1,21 @@
1
+ module Hanna
2
+ #
3
+ # The version of RDoc that Hanna should use.
4
+ #
5
+ RDOC_VERSION = '2.2.0'
6
+ RDOC_VERSION_REQUIREMENT = "~> #{RDOC_VERSION}"
7
+
8
+ #
9
+ # This method loads the correct version of RDoc. If the correct
10
+ # version of RDoc is not present, this method will terminate the
11
+ # program with a helpful error message.
12
+ #
13
+ def self.require_rdoc
14
+ begin
15
+ gem 'rdoc', RDOC_VERSION_REQUIREMENT
16
+ rescue Gem::LoadError
17
+ $stderr.puts "Error: hanna requires the RDoc #{RDOC_VERSION} gem!"
18
+ exit 1
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ require 'hanna/rdoc_version'
2
+ require 'rake'
3
+ require 'rake/rdoctask'
4
+
5
+ Rake::RDocTask.class_eval do
6
+ # don't allow it
7
+ undef :external=, :template=
8
+
9
+ # Create the tasks defined by this task lib.
10
+ def define
11
+ @template = 'hanna'
12
+
13
+ # inline source and UTF-8 are defaults:
14
+ options << '--inline-source' unless options.include? '--inline-source' or options.include? '-S'
15
+ options << '--charset=UTF-8' if options.grep(/^(--charset\b|-c\b)/).empty?
16
+
17
+ desc "Build the HTML documentation"
18
+ task name
19
+
20
+ desc "Force a rebuild of the RDOC files"
21
+ task paste("re", name) => [paste("clobber_", name), name]
22
+
23
+ desc "Remove rdoc products"
24
+ task paste("clobber_", name) do
25
+ rm_r rdoc_dir rescue nil
26
+ end
27
+
28
+ task :clobber => [paste("clobber_", name)]
29
+
30
+ directory @rdoc_dir
31
+ task name => [rdoc_target]
32
+ file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
33
+ rm_r @rdoc_dir rescue nil
34
+ Hanna::require_rdoc
35
+ require 'rdoc/rdoc'
36
+
37
+ RDoc::RDoc.new.document(option_list + @rdoc_files)
38
+ end
39
+ return self
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ %h1= values["list_title"]
2
+ %ol#index-entries.classes
3
+ = render_class_tree make_class_tree(values["entries"])
@@ -0,0 +1,25 @@
1
+ %h1= values["list_title"]
2
+ - type = values["list_title"].downcase
3
+ - any_hidden = false
4
+
5
+ - if type == 'methods'
6
+ %script{:type => 'text/javascript'}
7
+ = read("prototype-1.6.0.3.js")
8
+ = build_javascript_search_index(values["entries"])
9
+ = read("method_search.js")
10
+ %form{:onsubmit => 'return performSearch()'}
11
+ %input{:type => 'text', :id => 'search', :class => 'untouched', :value => 'Enter search terms...'}
12
+ %ol#search-results{ :class => type, :style => 'display: none' }
13
+
14
+ %ol#index-entries{ :class => type }
15
+ - for entry in values["entries"]
16
+ - hide = type == 'files' && entry['name'] =~ /\.rb$/
17
+ - any_hidden = true if hide
18
+ - if type == 'methods'
19
+ %li{ :class => hide ? 'other' : nil }= link_to_method entry['name'], entry['href']
20
+ - else
21
+ %li{ :class => hide ? 'other' : nil }= link_to entry['name'], entry['href']
22
+
23
+ - if any_hidden
24
+ %li
25
+ %a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
@@ -0,0 +1,11 @@
1
+ !!! Frameset
2
+ %html{ "xml:lang" => "en", :lang => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
3
+ %head
4
+ %title= values["title"]
5
+ %meta{ :content => "text/html; charset=#{values['charset']}", "http-equiv" => "Content-Type" }
6
+ %frameset{ :cols => "20%, *" }
7
+ %frameset{ :rows => "15%, 35%, 50%" }
8
+ %frame{ :name => "Files", :title => "Files", :src => "fr_file_index.html" }
9
+ %frame{ :name => "Classes", :src => "fr_class_index.html" }
10
+ %frame{ :name => "Methods", :src => "fr_method_index.html" }
11
+ %frame{ :name => "docwin", :src => values['initial_page'] }=""
@@ -0,0 +1,38 @@
1
+ !!! strict
2
+ - index = values['list_title']
3
+ %html{ :lang => "en" }
4
+ %head
5
+ %title= values['title']
6
+ %meta{ 'http-equiv' => "Content-Type", :content => "text/html; charset=#{values['charset']}" }
7
+ %link{ :rel => "stylesheet", :href => values["style_url"], :type => "text/css", :media => "screen" }
8
+ - unless index
9
+ :javascript
10
+ function popupCode(url) {
11
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
12
+ }
13
+
14
+ function toggleCode(id) {
15
+ var code = document.getElementById(id)
16
+
17
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
18
+ return true
19
+ }
20
+
21
+ // Make codeblocks hidden by default
22
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
23
+ - else
24
+ %base{ :target => 'docwin' }/
25
+
26
+ %body{ :class => index ? 'list' : 'page' }
27
+ - if index
28
+ #index= yield
29
+ - else
30
+ #wrapper{ :class => values["classmod"] ? 'class' : 'file' }
31
+ = yield
32
+ #footer-push
33
+ #footer
34
+ = link_to '<strong>Hanna</strong> RDoc template', 'http://github.com/mislav/hanna'
35
+ hand-crafted by
36
+ %strong= link_to 'Mislav', 'http://mislav.caboo.se/'
37
+ and
38
+ %strong= link_to 'Hongli', 'http://blog.phusion.nl/'