paddle 1.0.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.
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-04-11
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,16 @@
1
+ .autotest
2
+ CHANGELOG.rdoc
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/images/ruby.png
7
+ lib/paddle.rb
8
+ lib/rdoc/discover.rb
9
+ lib/rdoc/generator/paddle.rb
10
+ lib/templates/classfile.html.erb
11
+ lib/templates/container.xml
12
+ lib/templates/content.opf.erb
13
+ lib/templates/cover.html.erb
14
+ lib/templates/title.html.erb
15
+ lib/templates/toc.ncx.erb
16
+ test/test_paddle.rb
@@ -0,0 +1,62 @@
1
+ = paddle
2
+
3
+ * http://tenderlovemaking.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ Paddle is an RDoc plugin that emits documentation suitable for use as an epub
8
+ book. The epub book can then be imported to iBooks for reading on iPad!
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Converts RDoc to epub format
13
+ * Sometimes it doesn't escape everything properly
14
+ * Links aren't working yet
15
+ * The tests are poor. *Very* poor.
16
+
17
+ == SYNOPSIS:
18
+
19
+ First, make sure to have the latest RDoc. Install paddle, then rdoc your code
20
+ like this:
21
+
22
+ $ rdoc -o epub -f paddle -t 'My Documentation' lib
23
+
24
+ Next, convert the documentation to an epub file:
25
+
26
+ $ cd epub
27
+ $ zip -Xr9D mydocs.epub mimetype *
28
+
29
+ Then drag "mydocs.epub" to iTunes, and sync up your iPad.
30
+
31
+ == REQUIREMENTS:
32
+
33
+ * RDoc
34
+
35
+ == INSTALL:
36
+
37
+ * sudo gem install rdoc
38
+
39
+ == LICENSE:
40
+
41
+ (The MIT License)
42
+
43
+ Copyright (c) 2010 Aaron Patterson
44
+
45
+ Permission is hereby granted, free of charge, to any person obtaining
46
+ a copy of this software and associated documentation files (the
47
+ 'Software'), to deal in the Software without restriction, including
48
+ without limitation the rights to use, copy, modify, merge, publish,
49
+ distribute, sublicense, and/or sell copies of the Software, and to
50
+ permit persons to whom the Software is furnished to do so, subject to
51
+ the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be
54
+ included in all copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
57
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
59
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
60
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
61
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
62
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.spec 'paddle' do
7
+ developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
8
+ self.readme_file = 'README.rdoc'
9
+ self.history_file = 'CHANGELOG.rdoc'
10
+ self.extra_rdoc_files = FileList['*.rdoc']
11
+ self.extra_deps << ['rdoc', '>= 2.5.3']
12
+ end
13
+
14
+ # vim: syntax=ruby
Binary file
@@ -0,0 +1,8 @@
1
+ ###
2
+ # Paddle is an RDoc template that will emit iPad compatible books!
3
+ module Paddle
4
+ # Test Attribute
5
+ attr_accessor :foo
6
+
7
+ VERSION = '1.0.0'
8
+ end
@@ -0,0 +1 @@
1
+ require 'rdoc/generator/paddle'
@@ -0,0 +1,144 @@
1
+ require 'rdoc/generator'
2
+ require 'rdoc/rdoc'
3
+ require 'paddle'
4
+ require 'erb'
5
+ require 'md5'
6
+ require 'fileutils'
7
+
8
+ class RDoc::Generator::Paddle
9
+ RDoc::RDoc.add_generator self
10
+
11
+ TEMPLATE_DIR = File.expand_path(
12
+ File.join(File.dirname(__FILE__), '..', '..', 'templates'))
13
+ IMAGE_DIR = File.expand_path(
14
+ File.join(File.dirname(__FILE__), '..', '..', 'images'))
15
+
16
+ class << self
17
+ alias :for :new
18
+ end
19
+
20
+ def initialize options
21
+ @options = options
22
+ @class_dir = nil
23
+ @file_dir = nil
24
+ @odir = Pathname.new(options.op_dir).expand_path(Pathname.pwd)
25
+ @fh = nil
26
+ @files = nil
27
+ end
28
+
29
+ def generate top_levels
30
+ @files = top_levels
31
+ @classes = RDoc::TopLevel.all_classes_and_modules.reject { |x|
32
+ x.name =~ /[<>]/
33
+ }
34
+
35
+ FileUtils.mkdir_p(File.join(@odir, class_dir))
36
+
37
+ emit_mimetype
38
+ emit_meta_inf
39
+ emit_cover
40
+ emit_title
41
+ emit_opf
42
+ emit_toc
43
+ emit_classfiles
44
+ copy_images
45
+ end
46
+
47
+ def class_dir
48
+ '/doc'
49
+ end
50
+
51
+ def title
52
+ @options.title
53
+ end
54
+
55
+ def identifier
56
+ MD5.hexdigest title
57
+ end
58
+
59
+ private
60
+ def h string
61
+ string.strip.gsub(/<pre>\s*<\/pre>/, '').gsub(/&/, '&amp;').gsub(/<</, '&lt;&lt;')
62
+ end
63
+
64
+ def copy_images
65
+ imgs = File.join @odir, 'images'
66
+ FileUtils.mkdir_p imgs
67
+
68
+ FileUtils.cp File.join(IMAGE_DIR, 'ruby.png'), imgs
69
+ end
70
+
71
+ def emit_meta_inf
72
+ meta_inf = File.join @odir, 'META-INF'
73
+ FileUtils.mkdir_p meta_inf
74
+
75
+ FileUtils.cp File.join(TEMPLATE_DIR, 'container.xml'), meta_inf
76
+ end
77
+
78
+ def emit_mimetype
79
+ File.open(File.join(@odir, 'mimetype'), 'wb') do |f|
80
+ f.write 'application/epub+zip'
81
+ end
82
+ end
83
+
84
+ def emit_cover
85
+ template = ERB.new File.read(File.join(TEMPLATE_DIR, 'cover.html.erb')),
86
+ nil, '<>'
87
+
88
+ File.open(File.join(@odir, class_dir, 'cover.html'), 'wb') do |f|
89
+ f.write template.result binding
90
+ end
91
+ end
92
+
93
+ def emit_title
94
+ template = ERB.new File.read(File.join(TEMPLATE_DIR, 'title.html.erb')),
95
+ nil, '<>'
96
+
97
+ File.open(File.join(@odir, class_dir, 'title.html'), 'wb') do |f|
98
+ f.write template.result binding
99
+ end
100
+ end
101
+
102
+ def emit_classfiles
103
+ @classes.each do |klass|
104
+ klass_methods = []
105
+ instance_methods = []
106
+
107
+ klass.method_list.each do |method|
108
+ next if 'private' == method.visibility.to_s
109
+ if method.type == 'class'
110
+ klass_methods << method
111
+ else
112
+ instance_methods << method
113
+ end
114
+ end
115
+
116
+ template = ERB.new File.read(File.join(TEMPLATE_DIR, 'classfile.html.erb')),
117
+ nil, '<>'
118
+
119
+ FileUtils.mkdir_p(File.dirname(File.join(@odir, klass.path)))
120
+
121
+ File.open(File.join(@odir, klass.path), 'wb') do |f|
122
+ f.write template.result binding
123
+ end
124
+ end
125
+ end
126
+
127
+ def emit_opf
128
+ template = ERB.new File.read(File.join(TEMPLATE_DIR, 'content.opf.erb')),
129
+ nil, '<>'
130
+
131
+ File.open(File.join(@odir, 'content.opf'), 'wb') do |f|
132
+ f.write template.result binding
133
+ end
134
+ end
135
+
136
+ def emit_toc
137
+ template = ERB.new File.read(File.join(TEMPLATE_DIR, 'toc.ncx.erb')),
138
+ nil, '<>'
139
+
140
+ File.open(File.join(@odir, 'toc.ncx'), 'wb') do |f|
141
+ f.write template.result binding
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,115 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
5
+ <title>
6
+ <%= klass.name %>
7
+ </title>
8
+ <style>
9
+ dt, dd {
10
+ margin: 0;
11
+ }
12
+ dt.name {
13
+ float: left;
14
+ }
15
+ dd.explanation {
16
+ clear: both;
17
+ margin-bottom: 0.5em;
18
+ margin-left: 1.5em;
19
+ }
20
+ dt.name {
21
+ font-weight: bold;
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+ <h1>
27
+ <% if klass.type == 'class' %>
28
+ <span class="class">
29
+ <%= klass.type.capitalize %>
30
+ <a href="<%= klass.path %>">
31
+ <%= klass.full_name %>
32
+ </a>
33
+ <% if klass.superclass %>
34
+ inherits from
35
+ <% end %>
36
+ <% unless String === klass.superclass %>
37
+ <a href="<%= klass.superclass.path %>">
38
+ <%= klass.superclass.name %>
39
+ </a>
40
+ <% else %>
41
+ <%= klass.superclass %>
42
+ <% end %>
43
+ </span>
44
+ <% else %>
45
+ <span class="module">
46
+ <%= klass.type.capitalize %>
47
+ <a href="<%= klass.path %>">
48
+ <%= klass.name %>
49
+ </a>
50
+ </span>
51
+ <% end %>
52
+ </h1>
53
+ <% if klass.description && !klass.description.empty? %>
54
+ <div id="description" class="alt">
55
+ <%= h klass.description %>
56
+ </div>
57
+ <% end %>
58
+
59
+ <!-- Constants -->
60
+ <% unless klass.constants.empty? %>
61
+ <h3>Constants</h3>
62
+ <% klass.constants.sort_by { |x| x.name }.each do |const| %>
63
+ <dl>
64
+ <dt class="name">
65
+ <%= h const.name %>
66
+ </dt>
67
+ <dd class="explanation"><%= h const.description %></dd>
68
+ </dl>
69
+ <% end %>
70
+ <% end %>
71
+
72
+ <!-- Attributes -->
73
+ <% unless klass.attributes.empty? %>
74
+ <h3>Attributes</h3>
75
+ <% klass.attributes.sort_by { |x| x.name }.each do |attr| %>
76
+ <dl>
77
+ <dt class="name">
78
+ <%= h attr.name %>
79
+ <span class="optional"><%= attr.rw %></span>
80
+ </dt>
81
+ <dd class="explanation"><%= h attr.description %></dd>
82
+ </dl>
83
+ <% end %>
84
+ <% end %>
85
+
86
+ <!-- Class Methods -->
87
+ <% unless klass_methods.empty? %>
88
+ <h3>Public Class Methods</h3>
89
+ <% klass_methods.each do |method| %>
90
+ <dl class="method">
91
+ <dt class="name">
92
+ <a name="<%= method.aref %>" ></a>
93
+ <%= h method.name %><%= h method.params %>
94
+ </dt>
95
+ <dd class="explanation"><%= h method.description %></dd>
96
+ </dl>
97
+ <% end %>
98
+ <% end %>
99
+
100
+ <!-- Instance Methods -->
101
+ <% unless instance_methods.empty? %>
102
+ <h3>Public Instance Methods</h3>
103
+ <% instance_methods.each do |method| %>
104
+ <dl class="method">
105
+ <dt class="name">
106
+ <a name="<%= method.aref %>" ></a>
107
+ <%= h method.name %><%= h method.params %>
108
+ </dt>
109
+ <dd class="explanation"><%= h method.description %></dd>
110
+ </dl>
111
+ <% end %>
112
+ <% end %>
113
+
114
+ </body>
115
+ </html>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0"?>
2
+ <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
3
+ <rootfiles>
4
+ <rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
5
+ </rootfiles>
6
+ </container>
7
+
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <package xmlns="http://www.idpf.org/2007/opf"
3
+ version="2.0"
4
+ unique-identifier="internet">
5
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+ xmlns:dcterms="http://purl.org/dc/terms/"
7
+ xmlns:opf="http://www.idpf.org/2007/opf"
8
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
9
+ <dc:title><%= title %></dc:title>
10
+ <dc:language xsi:type="dcterms:RFC3066">en</dc:language>
11
+ <dc:identifier id="dcidid" opf:scheme="URI">
12
+ <%= identifier %>
13
+ </dc:identifier>
14
+ </metadata>
15
+ <manifest>
16
+ <item id="ncx" href="toc.ncx" media-type="text/xml"/>
17
+ <item id="cover" href="doc/cover.html" media-type="application/xhtml+xml"/>
18
+ <item id="title" href="doc/title.html" media-type="application/xhtml+xml"/>
19
+ <item id="ruby" href="images/ruby.png" media-type="image/png"/>
20
+ <% @classes.each do |klass| %>
21
+ <item id="<%= MD5.hexdigest(klass.full_name) %>" href="<%= klass.path %>" media-type="application/xhtml+xml"/>
22
+ <% end %>
23
+ </manifest>
24
+ <spine toc="ncx">
25
+ <itemref idref="cover"/>
26
+ <itemref idref="title"/>
27
+ <% @classes.sort_by { |x| x.full_name }.each do |klass| %>
28
+ <itemref idref="<%= MD5.hexdigest(klass.full_name) %>"/>
29
+ <% end %>
30
+ </spine>
31
+ <guide>
32
+ <reference type="cover" title="Cover" href="doc/cover.html" />
33
+ </guide>
34
+ </package>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
5
+ <title>
6
+ <%= title %>
7
+ </title>
8
+ <style>
9
+ h1 {
10
+ text-align: center;
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1><%= title %></h1>
16
+ <img src="/images/ruby.png" />
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
5
+ <title>
6
+ <%= title %>
7
+ </title>
8
+ <style>
9
+ h1 {
10
+ text-align: center;
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1><%= title %></h1>
16
+ <img src="/images/ruby.png" />
17
+ </body>
18
+ </html>
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
3
+ "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
4
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en">
5
+ <head>
6
+ <meta name="dtb:uid" content="<%= identifier %>"/>
7
+ <meta name="dtb:depth" content="2"/>
8
+ <meta name="dtb:totalPageCount" content="0"/>
9
+ <meta name="dtb:maxPageNumber" content="0"/>
10
+ </head>
11
+ <docTitle>
12
+ <text><%= title %></text>
13
+ </docTitle>
14
+ <navMap>
15
+ <navPoint id="navPoint-1" playOrder="1">
16
+ <navLabel>
17
+ <text>Cover</text>
18
+ </navLabel>
19
+ <content src="doc/cover.html"/>
20
+ </navPoint>
21
+ <navPoint id="navPoint-2" playOrder="2">
22
+ <navLabel>
23
+ <text>Title</text>
24
+ </navLabel>
25
+ <content src="doc/title.html"/>
26
+ </navPoint>
27
+ <% @classes.sort_by { |x| x.full_name }.each_with_index do |klass, i| %>
28
+ <navPoint id="navPoint-<%= i + 3 %>" playOrder="<%= i + 3 %>">
29
+ <navLabel>
30
+ <text><%= klass.full_name %></text>
31
+ </navLabel>
32
+ <content src="<%= klass.path %>"/>
33
+ </navPoint>
34
+ <% end %>
35
+ </navMap>
36
+ </ncx>
@@ -0,0 +1,13 @@
1
+ require "test/unit"
2
+ require 'rdoc/generator/paddle'
3
+ require 'tempfile'
4
+ require 'fileutils'
5
+
6
+ class TestPaddle < Test::Unit::TestCase
7
+ def setup
8
+ @dirname = File.join(Dir.tmpdir, Time.now.to_i.to_s)
9
+ p @dirname
10
+ rdoc = RDoc::RDoc.new
11
+ rdoc.document ['--op', @dirname, '-q', '-f', 'paddle']
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paddle
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Aaron Patterson
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-12 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rdoc
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 5
30
+ - 3
31
+ version: 2.5.3
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rubyforge
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 0
44
+ - 3
45
+ version: 2.0.3
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: gemcutter
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 5
58
+ - 0
59
+ version: 0.5.0
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 2
71
+ - 5
72
+ - 0
73
+ version: 2.5.0
74
+ type: :development
75
+ version_requirements: *id004
76
+ description: |-
77
+ Paddle is an RDoc plugin that emits documentation suitable for use as an epub
78
+ book. The epub book can then be imported to iBooks for reading on iPad!
79
+ email:
80
+ - aaron@tenderlovemaking.com
81
+ executables: []
82
+
83
+ extensions: []
84
+
85
+ extra_rdoc_files:
86
+ - Manifest.txt
87
+ - CHANGELOG.rdoc
88
+ - README.rdoc
89
+ files:
90
+ - .autotest
91
+ - CHANGELOG.rdoc
92
+ - Manifest.txt
93
+ - README.rdoc
94
+ - Rakefile
95
+ - lib/images/ruby.png
96
+ - lib/paddle.rb
97
+ - lib/rdoc/discover.rb
98
+ - lib/rdoc/generator/paddle.rb
99
+ - lib/templates/classfile.html.erb
100
+ - lib/templates/container.xml
101
+ - lib/templates/content.opf.erb
102
+ - lib/templates/cover.html.erb
103
+ - lib/templates/title.html.erb
104
+ - lib/templates/toc.ncx.erb
105
+ - test/test_paddle.rb
106
+ has_rdoc: true
107
+ homepage: http://tenderlovemaking.com
108
+ licenses: []
109
+
110
+ post_install_message:
111
+ rdoc_options:
112
+ - --main
113
+ - README.rdoc
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ requirements: []
131
+
132
+ rubyforge_project: paddle
133
+ rubygems_version: 1.3.6
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: Paddle is an RDoc plugin that emits documentation suitable for use as an epub book
137
+ test_files:
138
+ - test/test_paddle.rb