docubot 0.6.1 → 0.6.2
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/bin/docubot +125 -125
- data/lib/docubot.rb +43 -43
- data/lib/docubot/bundle.rb +182 -182
- data/lib/docubot/converter.rb +28 -28
- data/lib/docubot/converters/haml.rb +9 -9
- data/lib/docubot/converters/markdown.rb +14 -14
- data/lib/docubot/index.rb +67 -67
- data/lib/docubot/link_tree.rb +111 -111
- data/lib/docubot/metasection.rb +61 -61
- data/lib/docubot/page.rb +167 -167
- data/lib/docubot/shells/default/0_License.md +59 -59
- data/lib/docubot/shells/default/Appendix/Glossary.md +4 -4
- data/lib/docubot/shells/default/Appendix/Index_Page.md +8 -8
- data/lib/docubot/shells/default/Appendix/Table of Contents.md +4 -4
- data/lib/docubot/shells/docubot-help/0_License.md +20 -20
- data/lib/docubot/shells/docubot-help/1_Getting_Started.md +47 -47
- data/lib/docubot/shells/docubot-help/2_Basic_Concepts/4 Adding Images.md +1 -1
- data/lib/docubot/shells/docubot-help/2_Basic_Concepts/index.md +5 -5
- data/lib/docubot/shells/docubot-help/3_Advanced_Topics/Controlling Glossary.md +2 -2
- data/lib/docubot/shells/docubot-help/3_Advanced_Topics/Controlling Indexing.md +9 -9
- data/lib/docubot/shells/docubot-help/3_Advanced_Topics/Controlling the Table of Contents.md +5 -5
- data/lib/docubot/shells/docubot-help/4_Appendix/Glossary.md +4 -4
- data/lib/docubot/shells/docubot-help/4_Appendix/Index_Page.md +5 -5
- data/lib/docubot/shells/docubot-help/4_Appendix/Table of Contents.md +7 -7
- data/lib/docubot/shells/docubot-help/index.txt +7 -7
- data/lib/docubot/snippet.rb +19 -19
- data/lib/docubot/snippets/glossary.rb +7 -7
- data/lib/docubot/snippets/index_entries.rb +6 -6
- data/lib/docubot/templates/_root/glossary.css +3 -3
- data/lib/docubot/templates/_root/glossary.js +57 -57
- data/lib/docubot/templates/index.haml +14 -14
- data/lib/docubot/templates/toc.haml +2 -2
- data/lib/docubot/templates/top.haml +32 -32
- data/lib/docubot/writers/chm/hhc.erb +1 -1
- data/lib/docubot/writers/chm/hhk.erb +2 -2
- data/lib/docubot/writers/html.rb +87 -87
- data/spec/_all.rb +12 -12
- data/spec/_helper.rb +16 -16
- data/spec/bundle.rb +339 -339
- data/spec/command.rb +3 -3
- data/spec/converters.rb +2 -2
- data/spec/global.rb +27 -27
- data/spec/glossary.rb +94 -94
- data/spec/index.rb +2 -2
- data/spec/page.rb +80 -80
- data/spec/samples/attributes/defaults.haml +34 -34
- data/spec/samples/attributes/explicit1.haml +42 -42
- data/spec/samples/attributes/explicit2.haml +41 -41
- data/spec/samples/attributes/hidden.haml +39 -39
- data/spec/samples/attributes/index.md +8 -8
- data/spec/samples/collisions/page1.md +2 -2
- data/spec/samples/collisions/page1.textile +2 -2
- data/spec/samples/collisions/page2.haml +3 -3
- data/spec/samples/collisions/page2.html +2 -2
- data/spec/samples/collisions/page2.txt +2 -2
- data/spec/samples/collisions/page3.md +2 -2
- data/spec/samples/files/index.md +1 -1
- data/spec/samples/glossary/Glossary.txt +4 -4
- data/spec/samples/glossary/Some Page.md +2 -2
- data/spec/samples/glossary/_glossary/Simple Term.md +2 -2
- data/spec/samples/glossary/_glossary/complex.haml +8 -8
- data/spec/samples/glossary/_glossary/project_x.md +3 -3
- data/spec/samples/hierarchy/1/1.1/1.1.1/index.haml +1 -1
- data/spec/samples/hierarchy/1/1.1/1.1.1/page.haml +3 -3
- data/spec/samples/hierarchy/1/1.1/page.haml +3 -3
- data/spec/samples/hierarchy/1/page.haml +3 -3
- data/spec/samples/hierarchy/2/2.1/2.1.1/page.haml +3 -3
- data/spec/samples/hierarchy/2/2.1/index.haml +1 -1
- data/spec/samples/hierarchy/2/2.1/page.haml +3 -3
- data/spec/samples/hierarchy/2/page.haml +3 -3
- data/spec/samples/hierarchy/main.haml +1 -1
- data/spec/samples/hierarchy/toc.md +1 -1
- data/spec/samples/links/index.txt +11 -11
- data/spec/samples/links/root.md +13 -13
- data/spec/samples/links/sub1/inner1.md +11 -11
- data/spec/samples/links/sub2.md +4 -4
- data/spec/samples/links/sub2/inner2.md +7 -7
- data/spec/samples/simplest/HTML.html +9 -9
- data/spec/samples/simplest/Haml.haml +12 -12
- data/spec/samples/simplest/Markdown.md +9 -9
- data/spec/samples/simplest/Text.txt +9 -9
- data/spec/samples/simplest/Textile.textile +9 -9
- data/spec/samples/templates/_templates/doubler.haml +6 -6
- data/spec/samples/templates/_templates/page.haml +1 -1
- data/spec/samples/templates/goaway.txt +2 -2
- data/spec/samples/templates/onepara_html.html +2 -2
- data/spec/samples/templates/onepara_md.md +4 -4
- data/spec/samples/templates/twopara_haml.haml +6 -6
- data/spec/samples/templates/twopara_textile.textile +5 -5
- data/spec/samples/titles/3_renamed.txt +1 -1
- data/spec/samples/titles/index.txt +1 -1
- data/spec/templates.rb +43 -43
- data/spec/toc.rb +128 -128
- data/spec/writer/chm.rb +2 -2
- data/spec/writer/html.rb +2 -2
- metadata +56 -25
- data/bin/docubot.bat +0 -1
data/spec/_all.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
$: << '..'
|
|
3
|
-
require 'spec/global'
|
|
4
|
-
require 'spec/bundle'
|
|
5
|
-
require 'spec/toc'
|
|
6
|
-
require 'spec/converters'
|
|
7
|
-
require 'spec/page'
|
|
8
|
-
require 'spec/glossary'
|
|
9
|
-
require 'spec/index'
|
|
10
|
-
require 'spec/templates'
|
|
11
|
-
require 'spec/command'
|
|
12
|
-
require 'spec/writer/html'
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
$: << '..'
|
|
3
|
+
require 'spec/global'
|
|
4
|
+
require 'spec/bundle'
|
|
5
|
+
require 'spec/toc'
|
|
6
|
+
require 'spec/converters'
|
|
7
|
+
require 'spec/page'
|
|
8
|
+
require 'spec/glossary'
|
|
9
|
+
require 'spec/index'
|
|
10
|
+
require 'spec/templates'
|
|
11
|
+
require 'spec/command'
|
|
12
|
+
require 'spec/writer/html'
|
|
13
13
|
require 'spec/writer/chm'
|
data/spec/_helper.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
$: << File.join( File.dirname(__FILE__), '..' )
|
|
2
|
-
$: << File.join( File.dirname(__FILE__), '..', 'lib' )
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'minitest/spec'
|
|
5
|
-
require 'docubot'
|
|
6
|
-
SAMPLES = File.dirname(__FILE__)/'samples'
|
|
7
|
-
MiniTest::Unit.autorun
|
|
8
|
-
|
|
9
|
-
class MiniTest::Spec
|
|
10
|
-
class << self
|
|
11
|
-
alias_method :__it__, :it
|
|
12
|
-
end
|
|
13
|
-
def self.it desc, &block
|
|
14
|
-
block ||= proc{ skip "(no tests defined)" }
|
|
15
|
-
__it__( desc, &block )
|
|
16
|
-
end
|
|
1
|
+
$: << File.join( File.dirname(__FILE__), '..' )
|
|
2
|
+
$: << File.join( File.dirname(__FILE__), '..', 'lib' )
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'minitest/spec'
|
|
5
|
+
require 'docubot'
|
|
6
|
+
SAMPLES = File.dirname(__FILE__)/'samples'
|
|
7
|
+
MiniTest::Unit.autorun
|
|
8
|
+
|
|
9
|
+
class MiniTest::Spec
|
|
10
|
+
class << self
|
|
11
|
+
alias_method :__it__, :it
|
|
12
|
+
end
|
|
13
|
+
def self.it desc, &block
|
|
14
|
+
block ||= proc{ skip "(no tests defined)" }
|
|
15
|
+
__it__( desc, &block )
|
|
16
|
+
end
|
|
17
17
|
end
|
data/spec/bundle.rb
CHANGED
|
@@ -1,340 +1,340 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
4
|
-
describe "AbusedBundle" do
|
|
5
|
-
it 'requires a valid path' do
|
|
6
|
-
proc{ DocuBot::Bundle.new }.must_raise(ArgumentError)
|
|
7
|
-
proc{ DocuBot::Bundle.new "does not exist" }.must_raise(RuntimeError)
|
|
8
|
-
DocuBot::Bundle.new(SAMPLES/'empty').wont_be_nil
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "Bundle from empty directory" do
|
|
13
|
-
before do
|
|
14
|
-
@out, @err = capture_io do
|
|
15
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'empty'
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should have an empty TOC" do
|
|
20
|
-
@bundle.toc.wont_be_nil
|
|
21
|
-
@bundle.toc.descendants.must_be_empty
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should have an empty index" do
|
|
25
|
-
@bundle.index.wont_be_nil
|
|
26
|
-
@bundle.index.entries.must_be_empty
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should have an empty glossary" do
|
|
30
|
-
@bundle.glossary.wont_be_nil
|
|
31
|
-
@bundle.glossary.entries.must_be_empty
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should have an empty external link list" do
|
|
35
|
-
@bundle.external_links.wont_be_nil
|
|
36
|
-
@bundle.external_links.must_be_empty
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should have an empty internal link list" do
|
|
40
|
-
@bundle.internal_links.wont_be_nil
|
|
41
|
-
@bundle.internal_links.must_be_empty
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should have an empty file link list" do
|
|
45
|
-
@bundle.file_links.wont_be_nil
|
|
46
|
-
@bundle.file_links.must_be_empty
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should have an empty broken link list" do
|
|
50
|
-
@bundle.broken_links.wont_be_nil
|
|
51
|
-
@bundle.broken_links.must_be_empty
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "should produce no warnings" do
|
|
55
|
-
@err.must_be_empty
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
describe "Gathering links" do
|
|
62
|
-
before do
|
|
63
|
-
@out, @err = capture_io do
|
|
64
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'links'
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should have link collections be pages hashed to arrays of strings" do
|
|
69
|
-
%w[ external_links internal_links file_links broken_links ].each do |method|
|
|
70
|
-
collection = @bundle.send(method)
|
|
71
|
-
collection.must_be_kind_of Hash
|
|
72
|
-
collection.keys.each do |key|
|
|
73
|
-
key.must_be_kind_of DocuBot::Page
|
|
74
|
-
end
|
|
75
|
-
collection.values.each do |value|
|
|
76
|
-
value.must_be_kind_of Array
|
|
77
|
-
value.each do |item|
|
|
78
|
-
item.must_be_kind_of String
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should identify (but not validate) external links" do
|
|
85
|
-
known_external = %w[ http://www.google.com/ http://phrogz.net http://phrogz.net/tmp/gkhead.jpg HTTP://NONEXISTENT.SITE ]
|
|
86
|
-
all_external = @bundle.external_links.values.flatten
|
|
87
|
-
known_external.each do |link|
|
|
88
|
-
all_external.must_include link
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "should identify and warn about broken internal links" do
|
|
93
|
-
known_broken = %w[
|
|
94
|
-
fork.html sub1.html root.md sub1/inner1.md
|
|
95
|
-
inner2.html ../sub1 sub1/inner1.md
|
|
96
|
-
../index.html ../sub1 ../index.md
|
|
97
|
-
sub2/GORKBO.bin
|
|
98
|
-
]
|
|
99
|
-
all_broken = @bundle.broken_links.values.flatten
|
|
100
|
-
known_broken.each do |link|
|
|
101
|
-
all_broken.must_include link
|
|
102
|
-
@err.must_include link
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "should identify valid links to pages or sections" do
|
|
107
|
-
known_internal = %w[
|
|
108
|
-
sub1/inner1.html sub2.html sub2/inner2.html sub1/../sub2/inner2.html
|
|
109
|
-
../root.html inner1.html ../sub2.html ../sub2/inner2.html
|
|
110
|
-
../sub1/index.html index.html
|
|
111
|
-
]
|
|
112
|
-
known_internal << "one two three.html"
|
|
113
|
-
all_internal = @bundle.internal_links.values.flatten
|
|
114
|
-
known_internal.each do |link|
|
|
115
|
-
all_internal.must_include link
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should identify valid links to internal files" do
|
|
120
|
-
known_file_links = %w[ ../sub2/bozo.bin bozo.bin sub2/bozo.bin ]
|
|
121
|
-
all_file_links = @bundle.file_links.values.flatten
|
|
122
|
-
known_file_links.each do |link|
|
|
123
|
-
all_file_links.must_include link
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "should identify valid links to internal files at the root" do
|
|
128
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'hierarchy'
|
|
129
|
-
known_file_links = %w[ main.css ../main.css ../../main.css ../../../main.css ]
|
|
130
|
-
all_file_links = @bundle.file_links.values.flatten
|
|
131
|
-
known_file_links.each do |link|
|
|
132
|
-
all_file_links.must_include link
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it "should identify and warn about invalid sub-page anchors" do
|
|
137
|
-
known_broken = %w[ #GORKBO ../root.html#GORKBO ]
|
|
138
|
-
all_broken = @bundle.broken_links.values.flatten
|
|
139
|
-
known_broken.each do |link|
|
|
140
|
-
all_broken.must_include link
|
|
141
|
-
@err.must_include link
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "should identify valid sub-page anchors" do
|
|
146
|
-
known_internal = %w[ #sub-id root.html#sub-id ../root.html#sub-id ]
|
|
147
|
-
all_internal = @bundle.internal_links.values.flatten
|
|
148
|
-
known_internal.each do |link|
|
|
149
|
-
all_internal.must_include link
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
describe "Identifying Conflicts" do
|
|
155
|
-
it "should raise when multiple pages will write to the same html" do
|
|
156
|
-
proc{
|
|
157
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'collisions' )
|
|
158
|
-
}.must_raise(DocuBot::Bundle::PageCollision)
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
it "should include the title and filename of every conflicting page" do
|
|
162
|
-
begin
|
|
163
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'collisions' )
|
|
164
|
-
rescue DocuBot::Bundle::PageCollision => e
|
|
165
|
-
e.message.must_include "page1.md"
|
|
166
|
-
e.message.must_include "page1.textile"
|
|
167
|
-
e.message.must_include "Page 1 (from Markdown)"
|
|
168
|
-
e.message.must_include "Page 1 (from Textile)"
|
|
169
|
-
e.message.must_include "page2.html"
|
|
170
|
-
e.message.must_include "page2.txt"
|
|
171
|
-
e.message.must_include "page2.haml"
|
|
172
|
-
e.message.must_include "Page 2 (from html)"
|
|
173
|
-
e.message.must_include "Page 2 (from text)"
|
|
174
|
-
e.message.must_include "Page 2 (from haml)"
|
|
175
|
-
e.message.wont_include "page3.md"
|
|
176
|
-
e.message.wont_include "page3.bin"
|
|
177
|
-
e.message.wont_include "Page 3"
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
describe "Bundle with Extra Files" do
|
|
184
|
-
before do
|
|
185
|
-
@out, @err = capture_io do
|
|
186
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'files' )
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
it "should keep track of extra files seen" do
|
|
191
|
-
@bundle.extras.wont_be_nil
|
|
192
|
-
static_files = %w[ common.css _static/foo.png section/foo.jpg ]
|
|
193
|
-
static_files << "section/sub section/foo.gif"
|
|
194
|
-
static_files.each do |path|
|
|
195
|
-
@bundle.extras.must_include path
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
it "should not count page sources as extra files" do
|
|
200
|
-
page_files = %w[ index.md another.md first.textile section/page.haml ]
|
|
201
|
-
page_files << "section/sub section/page.txt"
|
|
202
|
-
page_files.each do |path|
|
|
203
|
-
@bundle.extras.wont_include path
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it "should skip files specified by global glob matches" do
|
|
208
|
-
@bundle.global.ignore.as_list.must_equal %w[ **/*.psd **/*.ai **/Thumbs.db BUILDING.txt ]
|
|
209
|
-
bad_files = %w[ _static/foo.ai _static/foo.psd _static/Thumbs.db ]
|
|
210
|
-
bad_files << "section/sub section/Thumbs.db"
|
|
211
|
-
bad_files.each do |path|
|
|
212
|
-
@bundle.extras.wont_include path
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it "should not count ignored files as the source for pages" do
|
|
217
|
-
@bundle.pages.find{ |page| page.file == 'BUILDING.txt' }.must_be_nil
|
|
218
|
-
@bundle.page_by_file_path['BUILDING.txt'].must_be_nil
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
describe "Pages in bundles" do
|
|
223
|
-
before do
|
|
224
|
-
@titles = [ 'First One', 'Second One', 'Third One', 'Fourth One', 'Fifth One', '911' ]
|
|
225
|
-
Dir.chdir SAMPLES/'links' do
|
|
226
|
-
@files = Dir['**/*'] - %w[ index.txt sub2/bozo.bin ]
|
|
227
|
-
@htmls = @files.map{ |path|
|
|
228
|
-
path[/\.[^.]+$/] ? path.gsub(/\.[^.]+$/,'.html') : path/'index.html'
|
|
229
|
-
}
|
|
230
|
-
end
|
|
231
|
-
@out, @err = capture_io do
|
|
232
|
-
@titles_bundle = DocuBot::Bundle.new SAMPLES/'titles'
|
|
233
|
-
@links_bundle = DocuBot::Bundle.new SAMPLES/'links'
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
it "should allow you to find arrays of pages by title" do
|
|
238
|
-
@titles_bundle.pages_by_title.wont_be_nil
|
|
239
|
-
@titles.each do |page_title|
|
|
240
|
-
pages = @titles_bundle.pages_by_title[page_title]
|
|
241
|
-
pages.must_be_kind_of Array
|
|
242
|
-
pages.length.must_equal 1
|
|
243
|
-
pages.first.must_be_kind_of DocuBot::Page
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
it "should return an empty array for a non-existent page" do
|
|
248
|
-
pages = @titles_bundle.pages_by_title['NONE SUCH']
|
|
249
|
-
pages.must_be_kind_of Array
|
|
250
|
-
pages.length.must_equal 0
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
it "should not include the main index file in the titles" do
|
|
254
|
-
pages = @titles_bundle.pages_by_title["Title Changin'"]
|
|
255
|
-
pages.must_be_kind_of Array
|
|
256
|
-
pages.length.must_equal 0
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
it "should give access to pages by source file path" do
|
|
260
|
-
@links_bundle.page_by_file_path.wont_be_nil
|
|
261
|
-
@files.each do |path|
|
|
262
|
-
@links_bundle.page_by_file_path[path].must_be_kind_of DocuBot::Page
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
it "should return nil for an unfound file path" do
|
|
267
|
-
@links_bundle.page_by_file_path['NONE SUCH'].must_be_nil
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
it "should not include raw files in the file paths" do
|
|
271
|
-
@links_bundle.page_by_file_path['sub2/bozo.bin'].must_be_nil
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
it "should give access to pages by html file path" do
|
|
275
|
-
@links_bundle.page_by_html_path.wont_be_nil
|
|
276
|
-
@htmls.each do |path|
|
|
277
|
-
p path unless @links_bundle.page_by_html_path[path]
|
|
278
|
-
@links_bundle.page_by_html_path[path].wont_be_nil
|
|
279
|
-
@links_bundle.page_by_html_path[path].must_be_kind_of DocuBot::Page
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
it "should return nil for an unfound html path" do
|
|
284
|
-
@links_bundle.page_by_html_path['NONE SUCH'].must_be_nil
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
it "should not include raw files in the html paths" do
|
|
288
|
-
@links_bundle.page_by_html_path['sub2/bozo.bin'].must_be_nil
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
describe "Global bundle attributes" do
|
|
293
|
-
before do
|
|
294
|
-
@out, @err = capture_io do
|
|
295
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'attributes'
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
it "should have a global object" do
|
|
300
|
-
@bundle.global.wont_be_nil
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
it "should be indexable by method and return strings" do
|
|
304
|
-
@bundle.global.author.must_equal "Gavin Kistner"
|
|
305
|
-
@bundle.global.default.must_equal "All About Mr. Friggles"
|
|
306
|
-
@bundle.global.quotes.must_equal %q{"It's all about Mr. Benjamin", "I have never seen this cat before in my life!"}
|
|
307
|
-
@bundle.global.awesome.must_equal "true"
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
it "should be indexable by string" do
|
|
311
|
-
@bundle.global['author.email'].must_equal "!@phrogz.net"
|
|
312
|
-
@bundle.global['author website'].must_equal "http://phrogz.net"
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
it "should use utf8 for the strings" do
|
|
316
|
-
if Object.const_defined? :Encoding
|
|
317
|
-
Encoding.compatible?( @bundle.global.title, "UTF-8™")
|
|
318
|
-
end
|
|
319
|
-
@bundle.global.title.must_equal "Friggles® The Cat, ©2009"
|
|
320
|
-
end
|
|
321
|
-
|
|
322
|
-
it "should allow casting values to boolean" do
|
|
323
|
-
@bundle.global.awesome.as_boolean.must_equal true
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
it "should allow casting values to arrays of strings" do
|
|
327
|
-
quotes = @bundle.global.quotes.as_list
|
|
328
|
-
quotes.must_be_kind_of Array
|
|
329
|
-
quotes.must_equal [ "It's all about Mr. Benjamin", "I have never seen this cat before in my life!" ]
|
|
330
|
-
end
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
describe "Page attributes" do
|
|
334
|
-
before do
|
|
335
|
-
@out, @err = capture_io do
|
|
336
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'attributes'
|
|
337
|
-
end
|
|
338
|
-
end
|
|
339
|
-
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
|
4
|
+
describe "AbusedBundle" do
|
|
5
|
+
it 'requires a valid path' do
|
|
6
|
+
proc{ DocuBot::Bundle.new }.must_raise(ArgumentError)
|
|
7
|
+
proc{ DocuBot::Bundle.new "does not exist" }.must_raise(RuntimeError)
|
|
8
|
+
DocuBot::Bundle.new(SAMPLES/'empty').wont_be_nil
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "Bundle from empty directory" do
|
|
13
|
+
before do
|
|
14
|
+
@out, @err = capture_io do
|
|
15
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'empty'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should have an empty TOC" do
|
|
20
|
+
@bundle.toc.wont_be_nil
|
|
21
|
+
@bundle.toc.descendants.must_be_empty
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should have an empty index" do
|
|
25
|
+
@bundle.index.wont_be_nil
|
|
26
|
+
@bundle.index.entries.must_be_empty
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should have an empty glossary" do
|
|
30
|
+
@bundle.glossary.wont_be_nil
|
|
31
|
+
@bundle.glossary.entries.must_be_empty
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should have an empty external link list" do
|
|
35
|
+
@bundle.external_links.wont_be_nil
|
|
36
|
+
@bundle.external_links.must_be_empty
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should have an empty internal link list" do
|
|
40
|
+
@bundle.internal_links.wont_be_nil
|
|
41
|
+
@bundle.internal_links.must_be_empty
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should have an empty file link list" do
|
|
45
|
+
@bundle.file_links.wont_be_nil
|
|
46
|
+
@bundle.file_links.must_be_empty
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should have an empty broken link list" do
|
|
50
|
+
@bundle.broken_links.wont_be_nil
|
|
51
|
+
@bundle.broken_links.must_be_empty
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should produce no warnings" do
|
|
55
|
+
@err.must_be_empty
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
describe "Gathering links" do
|
|
62
|
+
before do
|
|
63
|
+
@out, @err = capture_io do
|
|
64
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'links'
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should have link collections be pages hashed to arrays of strings" do
|
|
69
|
+
%w[ external_links internal_links file_links broken_links ].each do |method|
|
|
70
|
+
collection = @bundle.send(method)
|
|
71
|
+
collection.must_be_kind_of Hash
|
|
72
|
+
collection.keys.each do |key|
|
|
73
|
+
key.must_be_kind_of DocuBot::Page
|
|
74
|
+
end
|
|
75
|
+
collection.values.each do |value|
|
|
76
|
+
value.must_be_kind_of Array
|
|
77
|
+
value.each do |item|
|
|
78
|
+
item.must_be_kind_of String
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should identify (but not validate) external links" do
|
|
85
|
+
known_external = %w[ http://www.google.com/ http://phrogz.net http://phrogz.net/tmp/gkhead.jpg HTTP://NONEXISTENT.SITE ]
|
|
86
|
+
all_external = @bundle.external_links.values.flatten
|
|
87
|
+
known_external.each do |link|
|
|
88
|
+
all_external.must_include link
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should identify and warn about broken internal links" do
|
|
93
|
+
known_broken = %w[
|
|
94
|
+
fork.html sub1.html root.md sub1/inner1.md
|
|
95
|
+
inner2.html ../sub1 sub1/inner1.md
|
|
96
|
+
../index.html ../sub1 ../index.md
|
|
97
|
+
sub2/GORKBO.bin
|
|
98
|
+
]
|
|
99
|
+
all_broken = @bundle.broken_links.values.flatten
|
|
100
|
+
known_broken.each do |link|
|
|
101
|
+
all_broken.must_include link
|
|
102
|
+
@err.must_include link
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should identify valid links to pages or sections" do
|
|
107
|
+
known_internal = %w[
|
|
108
|
+
sub1/inner1.html sub2.html sub2/inner2.html sub1/../sub2/inner2.html
|
|
109
|
+
../root.html inner1.html ../sub2.html ../sub2/inner2.html
|
|
110
|
+
../sub1/index.html index.html
|
|
111
|
+
]
|
|
112
|
+
known_internal << "one two three.html"
|
|
113
|
+
all_internal = @bundle.internal_links.values.flatten
|
|
114
|
+
known_internal.each do |link|
|
|
115
|
+
all_internal.must_include link
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should identify valid links to internal files" do
|
|
120
|
+
known_file_links = %w[ ../sub2/bozo.bin bozo.bin sub2/bozo.bin ]
|
|
121
|
+
all_file_links = @bundle.file_links.values.flatten
|
|
122
|
+
known_file_links.each do |link|
|
|
123
|
+
all_file_links.must_include link
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should identify valid links to internal files at the root" do
|
|
128
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'hierarchy'
|
|
129
|
+
known_file_links = %w[ main.css ../main.css ../../main.css ../../../main.css ]
|
|
130
|
+
all_file_links = @bundle.file_links.values.flatten
|
|
131
|
+
known_file_links.each do |link|
|
|
132
|
+
all_file_links.must_include link
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "should identify and warn about invalid sub-page anchors" do
|
|
137
|
+
known_broken = %w[ #GORKBO ../root.html#GORKBO ]
|
|
138
|
+
all_broken = @bundle.broken_links.values.flatten
|
|
139
|
+
known_broken.each do |link|
|
|
140
|
+
all_broken.must_include link
|
|
141
|
+
@err.must_include link
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should identify valid sub-page anchors" do
|
|
146
|
+
known_internal = %w[ #sub-id root.html#sub-id ../root.html#sub-id ]
|
|
147
|
+
all_internal = @bundle.internal_links.values.flatten
|
|
148
|
+
known_internal.each do |link|
|
|
149
|
+
all_internal.must_include link
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe "Identifying Conflicts" do
|
|
155
|
+
it "should raise when multiple pages will write to the same html" do
|
|
156
|
+
proc{
|
|
157
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'collisions' )
|
|
158
|
+
}.must_raise(DocuBot::Bundle::PageCollision)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it "should include the title and filename of every conflicting page" do
|
|
162
|
+
begin
|
|
163
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'collisions' )
|
|
164
|
+
rescue DocuBot::Bundle::PageCollision => e
|
|
165
|
+
e.message.must_include "page1.md"
|
|
166
|
+
e.message.must_include "page1.textile"
|
|
167
|
+
e.message.must_include "Page 1 (from Markdown)"
|
|
168
|
+
e.message.must_include "Page 1 (from Textile)"
|
|
169
|
+
e.message.must_include "page2.html"
|
|
170
|
+
e.message.must_include "page2.txt"
|
|
171
|
+
e.message.must_include "page2.haml"
|
|
172
|
+
e.message.must_include "Page 2 (from html)"
|
|
173
|
+
e.message.must_include "Page 2 (from text)"
|
|
174
|
+
e.message.must_include "Page 2 (from haml)"
|
|
175
|
+
e.message.wont_include "page3.md"
|
|
176
|
+
e.message.wont_include "page3.bin"
|
|
177
|
+
e.message.wont_include "Page 3"
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe "Bundle with Extra Files" do
|
|
184
|
+
before do
|
|
185
|
+
@out, @err = capture_io do
|
|
186
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'files' )
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should keep track of extra files seen" do
|
|
191
|
+
@bundle.extras.wont_be_nil
|
|
192
|
+
static_files = %w[ common.css _static/foo.png section/foo.jpg ]
|
|
193
|
+
static_files << "section/sub section/foo.gif"
|
|
194
|
+
static_files.each do |path|
|
|
195
|
+
@bundle.extras.must_include path
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "should not count page sources as extra files" do
|
|
200
|
+
page_files = %w[ index.md another.md first.textile section/page.haml ]
|
|
201
|
+
page_files << "section/sub section/page.txt"
|
|
202
|
+
page_files.each do |path|
|
|
203
|
+
@bundle.extras.wont_include path
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "should skip files specified by global glob matches" do
|
|
208
|
+
@bundle.global.ignore.as_list.must_equal %w[ **/*.psd **/*.ai **/Thumbs.db BUILDING.txt ]
|
|
209
|
+
bad_files = %w[ _static/foo.ai _static/foo.psd _static/Thumbs.db ]
|
|
210
|
+
bad_files << "section/sub section/Thumbs.db"
|
|
211
|
+
bad_files.each do |path|
|
|
212
|
+
@bundle.extras.wont_include path
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it "should not count ignored files as the source for pages" do
|
|
217
|
+
@bundle.pages.find{ |page| page.file == 'BUILDING.txt' }.must_be_nil
|
|
218
|
+
@bundle.page_by_file_path['BUILDING.txt'].must_be_nil
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
describe "Pages in bundles" do
|
|
223
|
+
before do
|
|
224
|
+
@titles = [ 'First One', 'Second One', 'Third One', 'Fourth One', 'Fifth One', '911' ]
|
|
225
|
+
Dir.chdir SAMPLES/'links' do
|
|
226
|
+
@files = Dir['**/*'] - %w[ index.txt sub2/bozo.bin ]
|
|
227
|
+
@htmls = @files.map{ |path|
|
|
228
|
+
path[/\.[^.]+$/] ? path.gsub(/\.[^.]+$/,'.html') : path/'index.html'
|
|
229
|
+
}
|
|
230
|
+
end
|
|
231
|
+
@out, @err = capture_io do
|
|
232
|
+
@titles_bundle = DocuBot::Bundle.new SAMPLES/'titles'
|
|
233
|
+
@links_bundle = DocuBot::Bundle.new SAMPLES/'links'
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it "should allow you to find arrays of pages by title" do
|
|
238
|
+
@titles_bundle.pages_by_title.wont_be_nil
|
|
239
|
+
@titles.each do |page_title|
|
|
240
|
+
pages = @titles_bundle.pages_by_title[page_title]
|
|
241
|
+
pages.must_be_kind_of Array
|
|
242
|
+
pages.length.must_equal 1
|
|
243
|
+
pages.first.must_be_kind_of DocuBot::Page
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it "should return an empty array for a non-existent page" do
|
|
248
|
+
pages = @titles_bundle.pages_by_title['NONE SUCH']
|
|
249
|
+
pages.must_be_kind_of Array
|
|
250
|
+
pages.length.must_equal 0
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it "should not include the main index file in the titles" do
|
|
254
|
+
pages = @titles_bundle.pages_by_title["Title Changin'"]
|
|
255
|
+
pages.must_be_kind_of Array
|
|
256
|
+
pages.length.must_equal 0
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it "should give access to pages by source file path" do
|
|
260
|
+
@links_bundle.page_by_file_path.wont_be_nil
|
|
261
|
+
@files.each do |path|
|
|
262
|
+
@links_bundle.page_by_file_path[path].must_be_kind_of DocuBot::Page
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
it "should return nil for an unfound file path" do
|
|
267
|
+
@links_bundle.page_by_file_path['NONE SUCH'].must_be_nil
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it "should not include raw files in the file paths" do
|
|
271
|
+
@links_bundle.page_by_file_path['sub2/bozo.bin'].must_be_nil
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
it "should give access to pages by html file path" do
|
|
275
|
+
@links_bundle.page_by_html_path.wont_be_nil
|
|
276
|
+
@htmls.each do |path|
|
|
277
|
+
p path unless @links_bundle.page_by_html_path[path]
|
|
278
|
+
@links_bundle.page_by_html_path[path].wont_be_nil
|
|
279
|
+
@links_bundle.page_by_html_path[path].must_be_kind_of DocuBot::Page
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
it "should return nil for an unfound html path" do
|
|
284
|
+
@links_bundle.page_by_html_path['NONE SUCH'].must_be_nil
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
it "should not include raw files in the html paths" do
|
|
288
|
+
@links_bundle.page_by_html_path['sub2/bozo.bin'].must_be_nil
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
describe "Global bundle attributes" do
|
|
293
|
+
before do
|
|
294
|
+
@out, @err = capture_io do
|
|
295
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'attributes'
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it "should have a global object" do
|
|
300
|
+
@bundle.global.wont_be_nil
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
it "should be indexable by method and return strings" do
|
|
304
|
+
@bundle.global.author.must_equal "Gavin Kistner"
|
|
305
|
+
@bundle.global.default.must_equal "All About Mr. Friggles"
|
|
306
|
+
@bundle.global.quotes.must_equal %q{"It's all about Mr. Benjamin", "I have never seen this cat before in my life!"}
|
|
307
|
+
@bundle.global.awesome.must_equal "true"
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
it "should be indexable by string" do
|
|
311
|
+
@bundle.global['author.email'].must_equal "!@phrogz.net"
|
|
312
|
+
@bundle.global['author website'].must_equal "http://phrogz.net"
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
it "should use utf8 for the strings" do
|
|
316
|
+
if Object.const_defined? :Encoding
|
|
317
|
+
Encoding.compatible?( @bundle.global.title, "UTF-8™")
|
|
318
|
+
end
|
|
319
|
+
@bundle.global.title.must_equal "Friggles® The Cat, ©2009"
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
it "should allow casting values to boolean" do
|
|
323
|
+
@bundle.global.awesome.as_boolean.must_equal true
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
it "should allow casting values to arrays of strings" do
|
|
327
|
+
quotes = @bundle.global.quotes.as_list
|
|
328
|
+
quotes.must_be_kind_of Array
|
|
329
|
+
quotes.must_equal [ "It's all about Mr. Benjamin", "I have never seen this cat before in my life!" ]
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
describe "Page attributes" do
|
|
334
|
+
before do
|
|
335
|
+
@out, @err = capture_io do
|
|
336
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'attributes'
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
340
|
end
|