hanna_gudao 0.3.0

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.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Add dependencies to develop your gem here.
4
+ # Include everything needed to run rake, tests, features, etc.
5
+ group :development do
6
+ gem "rake", "~> 0.9.2.2"
7
+ gem "bundler", "~> 1.1.3"
8
+ gem "jeweler", "~> 1.8.3"
9
+ gem 'rdoc', "~> 3.12"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.3)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.7.3)
11
+ rake (0.9.2.2)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.1.3)
20
+ jeweler (~> 1.8.3)
21
+ rake (~> 0.9.2.2)
22
+ rdoc (~> 3.12)
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009 Mislav Marohnić
2
+ Copyright (c) 2010, 2011 Erik Hollensbe
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ the Software, and to permit persons to whom the Software is furnished to do so,
9
+ subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,81 @@
1
+ = Hanna Nouveau — a better RDoc template, now for RDoc 2.5 and 3.0.
2
+
3
+ Based on the original Hanna by Mislav.
4
+
5
+ Hanna is an RDoc generator that scales. It's implemented in Haml, making the
6
+ sources clean and readable. It's built with simplicity, beauty and ease of
7
+ browsing in mind. (See more in {the
8
+ wiki}[http://github.com/mislav/hanna/wikis/home].)
9
+
10
+ Hanna gem is available from http://rubygems.org:
11
+
12
+ gem install hanna-nouveau
13
+
14
+ The template was created by {Mislav}[http://mislav.caboo.se/] and since then
15
+ has seen contributions from:
16
+
17
+ 1. {Tony Strauss}[http://github.com/DesigningPatterns], who participated from
18
+ the early start and made tons of fixes and enhancements to the template;
19
+ 2. {Hongli Lai}[http://blog.phusion.nl/] with the search filter for methods.
20
+ 3. {Erik Hollensbe}[http://github.com/erikh] a serious refactoring and up to
21
+ date with RDoc 2.5.x and 3.x, now named 'hanna-nouveau'.
22
+ 4. {James Tucker}[http://github.com/raggi] minor cleanups for Erik.
23
+
24
+ == Usage
25
+
26
+ rdoc -o doc -f hanna lib/*.rb
27
+
28
+ An alternative is to set the `RDOCOPT` environment variable:
29
+
30
+ RDOCOPT="-f hanna"
31
+
32
+ This will make RDoc always use Hanna unless it is explicitly overridden.
33
+
34
+ == Integrating with RubyGems
35
+
36
+ Another neat trick is to put the following line in your .gemrc, this will make
37
+ RubyGems use Hanna for all rdoc generation:
38
+
39
+ rdoc: -f hanna
40
+
41
+ This will make RubyGems use Hanna when generating documentation for installed
42
+ gems. Remember, if you wish to have all your gems be formatted in hanna:
43
+
44
+ gem rdoc --all --overwrite
45
+
46
+ The first time. To easily browse your newly created documentation, use:
47
+
48
+ gem server
49
+
50
+ == Rake task
51
+
52
+ For repeated generation of API docs, it's better to set up a Rake task. Simply
53
+ add the hanna format argument to your RDoc::Task options:
54
+
55
+ gem 'rdoc'
56
+ require 'rdoc/task'
57
+ RDoc::Task.new do |rdoc|
58
+ # this only works with RDoc 3.1 or greater
59
+ rdoc.generator = 'hanna'
60
+ # this is what you use pre RDoc 3.1:
61
+ rdoc.options.push '-f', 'hanna'
62
+ end
63
+
64
+ Tip: you can do this in the Rakefile of your Rails project before running
65
+ `rake doc:rails`.
66
+
67
+ Here is an example of a task for the {rdbi
68
+ library}[http://github.com/rdbi/rdbi/tree/master/Rakefile]:
69
+
70
+ gem 'rdoc'
71
+ require 'rdoc/task'
72
+ RDoc::Task.new do |rdoc|
73
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
74
+
75
+ rdoc.generator = 'hanna'
76
+ rdoc.main = 'README.rdoc'
77
+ rdoc.rdoc_dir = 'rdoc'
78
+ rdoc.title = "RDBI #{version} Documentation"
79
+ rdoc.rdoc_files.include('README*')
80
+ rdoc.rdoc_files.include('lib/**/*.rb')
81
+ end
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "hanna_gudao"
16
+ gem.homepage = "http://github.com/erikh/hanna-nouveau"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{A rework of the Hanna generator for RDoc 2.5 and 3.x}
19
+ gem.description = %Q{}
20
+ gem.email = "erik@hollensbe.org"
21
+ gem.authors = ["Erik Hollensbe", "James Tucker", "Mislav Marohnic"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ gem.add_runtime_dependency 'haml', "= 3.0.25"
25
+ gem.add_runtime_dependency 'rdoc', "~> 3.12"
26
+ gem.add_development_dependency 'jeweler', "~> 1.8.3"
27
+ gem.add_development_dependency 'rake', "~> 0.9.2.2"
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rdoc/task'
32
+ RDoc::Task.new do |rdoc|
33
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
34
+
35
+ rdoc.rdoc_dir = 'rdoc'
36
+ rdoc.title = "hanna-nouveau #{version}"
37
+ rdoc.rdoc_files.include('README*')
38
+ rdoc.rdoc_files.include('lib/**/*.rb')
39
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,80 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "hanna_gudao"
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Erik Hollensbe", "James Tucker", "Mislav Marohnic"]
12
+ s.date = "2012-05-22"
13
+ s.description = ""
14
+ s.email = "erik@hollensbe.org"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "hanna_gudao.gemspec",
27
+ "lib/hanna_gudao.rb",
28
+ "lib/hanna_gudao/template_files/class_index.haml",
29
+ "lib/hanna_gudao/template_files/file_index.haml",
30
+ "lib/hanna_gudao/template_files/index.haml",
31
+ "lib/hanna_gudao/template_files/layout.haml",
32
+ "lib/hanna_gudao/template_files/method_index.haml",
33
+ "lib/hanna_gudao/template_files/method_list.haml",
34
+ "lib/hanna_gudao/template_files/method_search.js",
35
+ "lib/hanna_gudao/template_files/page.haml",
36
+ "lib/hanna_gudao/template_files/prototype-1.6.0.3.js",
37
+ "lib/hanna_gudao/template_files/sections.haml",
38
+ "lib/hanna_gudao/template_files/styles.sass",
39
+ "lib/rdoc/discover.rb"
40
+ ]
41
+ s.homepage = "http://github.com/erikh/hanna-nouveau"
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = "1.8.22"
45
+ s.summary = "A rework of the Hanna generator for RDoc 2.5 and 3.x"
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<rake>, ["~> 0.9.2.2"])
52
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
54
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_runtime_dependency(%q<haml>, ["= 3.0.25"])
56
+ s.add_runtime_dependency(%q<rdoc>, ["~> 3.12"])
57
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
58
+ s.add_development_dependency(%q<rake>, ["~> 0.9.2.2"])
59
+ else
60
+ s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
61
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
63
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
64
+ s.add_dependency(%q<haml>, ["= 3.0.25"])
65
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
67
+ s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
68
+ end
69
+ else
70
+ s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
71
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
72
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
73
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
74
+ s.add_dependency(%q<haml>, ["= 3.0.25"])
75
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
76
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
77
+ s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
78
+ end
79
+ end
80
+
@@ -0,0 +1,3 @@
1
+ %h1= values[:list_title]
2
+ %ol#index-entries.classes
3
+ = render_class_tree values[:classes].select { |x| x.full_name !~ /::/ }
@@ -0,0 +1,12 @@
1
+ %h1= values[:list_title]
2
+ - any_hidden = false
3
+
4
+ %ol#index-entries{ :class => 'files' }
5
+ - values[:files].each do |file|
6
+ - hide = file.name =~ /\.rb$/
7
+ - any_hidden = true if hide
8
+ %li{ :class => hide ? 'other' : nil }= link_to file.name, file.path
9
+
10
+ - if any_hidden
11
+ %li
12
+ %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= @options.title
5
+ %meta{ :content => "text/html; charset=#{@options.charset}", "http-equiv" => "Content-Type" }
6
+ %frameset{ :cols => "20%, *", :border => "1", :frameborder => "1", :bordercolor => "gray" }
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 => @main_page_uri }=""
@@ -0,0 +1,34 @@
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=#{@options.charset}" }
7
+ %link{ :rel => "stylesheet", :href => values[:stylesheet], :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/tree/master'
@@ -0,0 +1,15 @@
1
+ %h1= values[:list_title]
2
+
3
+ %script{:type => 'text/javascript'}
4
+ = File.read(File.join(@templatedir, "prototype-1.6.0.3.js"))
5
+ = build_javascript_search_index(values[:methods] + values[:attributes])
6
+ = File.read(File.join(@templatedir, "method_search.js"))
7
+ %form{:onsubmit => 'return performSearch()'}
8
+ %input{:type => 'text', :id => 'search', :class => 'untouched', :value => 'Enter search terms...'}
9
+ %ol#search-results{ :class => 'methods', :style => 'display: none' }
10
+
11
+ %ol#index-entries{ :class => 'methods' }
12
+ - values[:attributes].each do |entry|
13
+ %li= link_to_method entry, [classfile(entry.parent), "method-#{entry.html_name}"].join('#')
14
+ - values[:methods].each do |entry|
15
+ %li= link_to_method entry, [classfile(entry.parent), entry.aref].join('#')
@@ -0,0 +1,56 @@
1
+ - entry = values[:entry]
2
+ - sections = values[:sections].keys if values.has_key?(:sections)
3
+ - methods = entry.method_list + entry.attributes
4
+ - unless methods.empty?
5
+ #method-list
6
+ %h2 Methods
7
+ - %w[attr attr_accessor attr_reader attr_writer class instance].each do |type|
8
+ - (RDoc::VISIBILITIES rescue RDoc::Context::VISIBILITIES).each do |vis|
9
+ -# FIXME ugly
10
+ - list = methods.reject { |x| x.respond_to?(:is_alias_for) && x.is_alias_for }.select { |x| x.visibility == vis && x.type == type.to_s }.sort
11
+ - unless list.empty?
12
+ - type_result = ""
13
+ - if type =~ /^attr_/
14
+ - type_result += type.sub(/^attr_/, '').capitalize
15
+ - else
16
+ - type_result += type.capitalize
17
+ - type_result = "#{vis.to_s.capitalize} #{type_result}"
18
+ %h3= type_result
19
+ %ol
20
+ - list.each do |method|
21
+ - if method.respond_to?(:aref)
22
+ - if method.name.to_s.empty? && method.call_seq
23
+ %li= link_to method.call_seq.gsub(/<br\s*\/?>/, "").split(/[\r\n]+/).map{ |s| s.split(/([({]+|\[\{|\s+(#?=>|&rarr;)\s+)/).first.sub(/^[A-Za-z0-9_:]+\./, "").sub(/\s+=\s+.*/, "=").strip }.uniq.join("<br />\n"), '#' + method.aref
24
+ - else
25
+ %li= link_to method.name, '#' + method.aref
26
+ - elsif method.respond_to?(:html_name)
27
+ %li= link_to method.name, "#method-#{method.html_name}"
28
+ - else
29
+ %li= method.name
30
+
31
+ - if entry.requires or sections or entry.includes
32
+ #context
33
+ - unless entry.requires.empty?
34
+ #requires
35
+ %h2 Required files
36
+ %ol
37
+ - entry.requires.each do |req|
38
+ %li= req.name
39
+
40
+ - if sections && (sections.length > 1 || sections.first.title.to_s != '')
41
+ #contents
42
+ %h2 Contents
43
+ %ol
44
+ - sections.sort_by{|s| s.title.to_s}.each do |section|
45
+ %li= link_to section.title, "##{section.aref}"
46
+
47
+ - unless entry.includes.empty?
48
+ #includes
49
+ %h2 Included modules
50
+ %ol
51
+ - entry.includes.each do |inc|
52
+ - if (mod = inc.module).is_a?(String)
53
+ %li= inc.name
54
+ - else
55
+ %li= link_to inc.name, entry.aref_to(mod.path)
56
+
@@ -0,0 +1,63 @@
1
+ $(document).observe('dom:loaded', function() {
2
+ // Setup search-during-typing.
3
+ new Form.Element.Observer('search', 0.3, function(element, value) {
4
+ performSearch();
5
+ });
6
+
7
+ // Remove the default search box value when the user puts the focus on
8
+ // the search box for the first time.
9
+ var search_box = $('search');
10
+ if ($F('search') == 'Enter search terms...') {
11
+ search_box.observe('focus', function() {
12
+ if (search_box.hasClassName('untouched')) {
13
+ search_box.removeClassName('untouched');
14
+ search_box.value = '';
15
+ }
16
+ });
17
+ } else {
18
+ search_box.removeClassName('untouched');
19
+ }
20
+
21
+ search_box.insert({
22
+ after: new Element('span', { 'class': 'clear_button' }).update('x').observe('click', function(e) {
23
+ e.stopPropagation()
24
+ search_box.setValue('')
25
+ search_box.focus()
26
+ })
27
+ })
28
+ });
29
+
30
+ function searchInIndex(query) {
31
+ var i;
32
+ var results = [];
33
+ query = query.toLowerCase();
34
+ for (i = 0; i < search_index.length; i++) {
35
+ if (search_index[i].method.indexOf(query) != -1) {
36
+ results.push(search_index[i]);
37
+ }
38
+ }
39
+ return results;
40
+ }
41
+
42
+ function buildHtmlForResults(results) {
43
+ var html = "";
44
+ var i;
45
+ for (i = 0; i < results.length; i++) {
46
+ html += '<li>' + results[i].html + '</li>';
47
+ }
48
+ return html;
49
+ }
50
+
51
+ function performSearch() {
52
+ var query = $F('search');
53
+ if (query == '') {
54
+ $('index-entries').show();
55
+ $('search-results').hide();
56
+ } else {
57
+ var results = searchInIndex(query);
58
+ $('search-results').update(buildHtmlForResults(results));
59
+ $('index-entries').hide();
60
+ $('search-results').show();
61
+ }
62
+ return false;
63
+ }
@@ -0,0 +1,45 @@
1
+ - file_page = !values[:classmod]
2
+ - title_in_description = values[:entry].description && values[:entry].description =~ /^\s*<h1>/m
3
+
4
+ .header
5
+ - title = capture_haml do
6
+ - if file_page
7
+ = values[:file].name
8
+ - else
9
+ %span.type= values[:classmod]
10
+ = values[:entry].full_name
11
+ - if title_in_description
12
+ .name= title
13
+ - else
14
+ %h1.name= title
15
+
16
+ - if file_page
17
+ .paths
18
+ = values[:file].relative_name
19
+ - else
20
+ %ol.paths
21
+ - values[:entry].in_files.each_with_index do |file, index|
22
+ %li{ :class => index > 0 ? 'other' : nil }
23
+ -# FIXME cleanup
24
+ = link_to file.full_name, Pathname.new(file.path).relative_path_from(Pathname.new(values[:entry].path).dirname)
25
+ - if values[:entry].in_files.size > 1
26
+ %li
27
+ %a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
28
+
29
+ - if values[:entry].parent
30
+ .parent
31
+ Parent:
32
+ -# FIXME helper method
33
+ %strong= link_to values[:entry].parent.name, Pathname.new(class_dir) + Pathname.new(values[:entry].parent.path).relative_path_from(Pathname.new values[:entry].path)
34
+
35
+ - if values[:entry].respond_to?(:last_modified) and values[:entry].last_modified
36
+ .last-update
37
+ Last Update:
38
+ %span.datetime= values[:entry].last_modified
39
+
40
+ #content
41
+ #text
42
+ - if values[:description]
43
+ #description~ sanitize_code_blocks frame_link values[:description]
44
+
45
+ = frame_link yield