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/command.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
data/spec/converters.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
data/spec/global.rb
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
4
|
-
# http://www.w3.org/TR/html4/types.html#type-id
|
|
5
|
-
# We disallow colons or periods in the ID because they mess up CSS selectors
|
|
6
|
-
# We require an octothorpe at the front because it makes life easier
|
|
7
|
-
VALID_ID = /#[a-z][\w-]*/i
|
|
8
|
-
|
|
9
|
-
describe "Generating IDs from Text" do
|
|
10
|
-
it "must create a valid identifier from a variety of input" do
|
|
11
|
-
DocuBot.id_from_text("foo").must_match VALID_ID
|
|
12
|
-
DocuBot.id_from_text("foo-bar").must_match VALID_ID
|
|
13
|
-
DocuBot.id_from_text("Foo-Bar").must_match VALID_ID
|
|
14
|
-
DocuBot.id_from_text("foo bar").must_match VALID_ID
|
|
15
|
-
DocuBot.id_from_text(" foo").must_match VALID_ID
|
|
16
|
-
DocuBot.id_from_text("foo ").must_match VALID_ID
|
|
17
|
-
DocuBot.id_from_text(" foo ").must_match VALID_ID
|
|
18
|
-
DocuBot.id_from_text("foo:bar").must_match VALID_ID
|
|
19
|
-
DocuBot.id_from_text("foo.bar").must_match VALID_ID
|
|
20
|
-
DocuBot.id_from_text("foo!bar").must_match VALID_ID
|
|
21
|
-
DocuBot.id_from_text("foo?!bar").must_match VALID_ID
|
|
22
|
-
DocuBot.id_from_text("foo(bar)").must_match VALID_ID
|
|
23
|
-
DocuBot.id_from_text("(foo)bar").must_match VALID_ID
|
|
24
|
-
DocuBot.id_from_text("!foo bar").must_match VALID_ID
|
|
25
|
-
DocuBot.id_from_text("foo: bar").must_match VALID_ID
|
|
26
|
-
DocuBot.id_from_text("!!!").wont_match VALID_ID
|
|
27
|
-
end
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
|
4
|
+
# http://www.w3.org/TR/html4/types.html#type-id
|
|
5
|
+
# We disallow colons or periods in the ID because they mess up CSS selectors
|
|
6
|
+
# We require an octothorpe at the front because it makes life easier
|
|
7
|
+
VALID_ID = /#[a-z][\w-]*/i
|
|
8
|
+
|
|
9
|
+
describe "Generating IDs from Text" do
|
|
10
|
+
it "must create a valid identifier from a variety of input" do
|
|
11
|
+
DocuBot.id_from_text("foo").must_match VALID_ID
|
|
12
|
+
DocuBot.id_from_text("foo-bar").must_match VALID_ID
|
|
13
|
+
DocuBot.id_from_text("Foo-Bar").must_match VALID_ID
|
|
14
|
+
DocuBot.id_from_text("foo bar").must_match VALID_ID
|
|
15
|
+
DocuBot.id_from_text(" foo").must_match VALID_ID
|
|
16
|
+
DocuBot.id_from_text("foo ").must_match VALID_ID
|
|
17
|
+
DocuBot.id_from_text(" foo ").must_match VALID_ID
|
|
18
|
+
DocuBot.id_from_text("foo:bar").must_match VALID_ID
|
|
19
|
+
DocuBot.id_from_text("foo.bar").must_match VALID_ID
|
|
20
|
+
DocuBot.id_from_text("foo!bar").must_match VALID_ID
|
|
21
|
+
DocuBot.id_from_text("foo?!bar").must_match VALID_ID
|
|
22
|
+
DocuBot.id_from_text("foo(bar)").must_match VALID_ID
|
|
23
|
+
DocuBot.id_from_text("(foo)bar").must_match VALID_ID
|
|
24
|
+
DocuBot.id_from_text("!foo bar").must_match VALID_ID
|
|
25
|
+
DocuBot.id_from_text("foo: bar").must_match VALID_ID
|
|
26
|
+
DocuBot.id_from_text("!!!").wont_match VALID_ID
|
|
27
|
+
end
|
|
28
28
|
end
|
data/spec/glossary.rb
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
4
|
-
describe "Glossary Scanner" do
|
|
5
|
-
before do
|
|
6
|
-
@public_terms = [ "Simple Term", "Complex Term" ]
|
|
7
|
-
@hidden_terms = [ "Secret Term"]
|
|
8
|
-
@all_terms = @public_terms + @hidden_terms
|
|
9
|
-
@expected_paragraphs = {
|
|
10
|
-
"Simple Term" => 2,
|
|
11
|
-
"Complex Term" => 3
|
|
12
|
-
}
|
|
13
|
-
@out, @err = capture_io do
|
|
14
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'glossary'
|
|
15
|
-
@glossary = @bundle.glossary
|
|
16
|
-
@page = @bundle.pages_by_title['Glossary'].first
|
|
17
|
-
@fulldoc = Nokogiri::HTML::DocumentFragment.parse( @page.to_html )
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# No _glossary folder handled in the Bundle spec for empty site
|
|
22
|
-
|
|
23
|
-
it "should have one internal entry for each term defined in _glossary" do
|
|
24
|
-
@glossary.entries.size.must_equal @all_terms.length
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should honor page titles as terms" do
|
|
28
|
-
@all_terms.each do |term|
|
|
29
|
-
@glossary.entries[term].wont_be_nil
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "uses DocuBot::Page instances for the definitions" do
|
|
34
|
-
@glossary.entries.values.each do |defn|
|
|
35
|
-
defn.must_be_kind_of DocuBot::Page
|
|
36
|
-
end
|
|
37
|
-
@glossary.entries["Secret Term"].hide.as_boolean.must_equal true
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "supports iterating over the entries with each" do
|
|
41
|
-
count = 0
|
|
42
|
-
@glossary.each do |page,defn|
|
|
43
|
-
page.must_be_kind_of String
|
|
44
|
-
defn.must_be_kind_of DocuBot::Page
|
|
45
|
-
count += 1
|
|
46
|
-
end
|
|
47
|
-
count.must_equal @all_terms.length
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "uses converters for page content" do
|
|
51
|
-
@expected_paragraphs.each do |term,paras|
|
|
52
|
-
@glossary.entries[term].nokodoc.xpath('.//p').length.must_equal paras
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "supports a glossary template that generates HTML for terms" do
|
|
57
|
-
definitions = @fulldoc.xpath('.//dt')
|
|
58
|
-
@expected_paragraphs.each do |term,paras|
|
|
59
|
-
dt = definitions.find{ |node| node.inner_text==term }
|
|
60
|
-
dt.wont_be_nil
|
|
61
|
-
if dt.next_element.xpath('.//p').length != paras
|
|
62
|
-
puts dt.next_element.to_html
|
|
63
|
-
end
|
|
64
|
-
dt.next_element.xpath('.//p').length.must_equal paras
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "does not include hidden pages in the output" do
|
|
69
|
-
definitions = @fulldoc.xpath('.//dt')
|
|
70
|
-
@hidden_terms.each do |term|
|
|
71
|
-
@fulldoc.at_xpath(".//dt[text()='#{term}']").must_be_nil
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe "Glossary Snippet" do
|
|
77
|
-
before do
|
|
78
|
-
@out, @err = capture_io do
|
|
79
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'glossary'
|
|
80
|
-
@glossary = @bundle.glossary
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should know about missing terms" do
|
|
85
|
-
@glossary.missing_terms.must_include "crazy term"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it "should not mistake alternate text for a missing term" do
|
|
89
|
-
@glossary.missing_terms.wont_include "more complex term"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "should warn about missing terms" do
|
|
93
|
-
@err.must_include "crazy term"
|
|
94
|
-
end
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
|
4
|
+
describe "Glossary Scanner" do
|
|
5
|
+
before do
|
|
6
|
+
@public_terms = [ "Simple Term", "Complex Term" ]
|
|
7
|
+
@hidden_terms = [ "Secret Term"]
|
|
8
|
+
@all_terms = @public_terms + @hidden_terms
|
|
9
|
+
@expected_paragraphs = {
|
|
10
|
+
"Simple Term" => 2,
|
|
11
|
+
"Complex Term" => 3
|
|
12
|
+
}
|
|
13
|
+
@out, @err = capture_io do
|
|
14
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'glossary'
|
|
15
|
+
@glossary = @bundle.glossary
|
|
16
|
+
@page = @bundle.pages_by_title['Glossary'].first
|
|
17
|
+
@fulldoc = Nokogiri::HTML::DocumentFragment.parse( @page.to_html )
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# No _glossary folder handled in the Bundle spec for empty site
|
|
22
|
+
|
|
23
|
+
it "should have one internal entry for each term defined in _glossary" do
|
|
24
|
+
@glossary.entries.size.must_equal @all_terms.length
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should honor page titles as terms" do
|
|
28
|
+
@all_terms.each do |term|
|
|
29
|
+
@glossary.entries[term].wont_be_nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "uses DocuBot::Page instances for the definitions" do
|
|
34
|
+
@glossary.entries.values.each do |defn|
|
|
35
|
+
defn.must_be_kind_of DocuBot::Page
|
|
36
|
+
end
|
|
37
|
+
@glossary.entries["Secret Term"].hide.as_boolean.must_equal true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "supports iterating over the entries with each" do
|
|
41
|
+
count = 0
|
|
42
|
+
@glossary.each do |page,defn|
|
|
43
|
+
page.must_be_kind_of String
|
|
44
|
+
defn.must_be_kind_of DocuBot::Page
|
|
45
|
+
count += 1
|
|
46
|
+
end
|
|
47
|
+
count.must_equal @all_terms.length
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "uses converters for page content" do
|
|
51
|
+
@expected_paragraphs.each do |term,paras|
|
|
52
|
+
@glossary.entries[term].nokodoc.xpath('.//p').length.must_equal paras
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "supports a glossary template that generates HTML for terms" do
|
|
57
|
+
definitions = @fulldoc.xpath('.//dt')
|
|
58
|
+
@expected_paragraphs.each do |term,paras|
|
|
59
|
+
dt = definitions.find{ |node| node.inner_text==term }
|
|
60
|
+
dt.wont_be_nil
|
|
61
|
+
if dt.next_element.xpath('.//p').length != paras
|
|
62
|
+
puts dt.next_element.to_html
|
|
63
|
+
end
|
|
64
|
+
dt.next_element.xpath('.//p').length.must_equal paras
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "does not include hidden pages in the output" do
|
|
69
|
+
definitions = @fulldoc.xpath('.//dt')
|
|
70
|
+
@hidden_terms.each do |term|
|
|
71
|
+
@fulldoc.at_xpath(".//dt[text()='#{term}']").must_be_nil
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "Glossary Snippet" do
|
|
77
|
+
before do
|
|
78
|
+
@out, @err = capture_io do
|
|
79
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'glossary'
|
|
80
|
+
@glossary = @bundle.glossary
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should know about missing terms" do
|
|
85
|
+
@glossary.missing_terms.must_include "crazy term"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should not mistake alternate text for a missing term" do
|
|
89
|
+
@glossary.missing_terms.wont_include "more complex term"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should warn about missing terms" do
|
|
93
|
+
@err.must_include "crazy term"
|
|
94
|
+
end
|
|
95
95
|
end
|
data/spec/index.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
data/spec/page.rb
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
4
|
-
describe "Validating page titles" do
|
|
5
|
-
before do
|
|
6
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'titles' )
|
|
7
|
-
@toc = @bundle.toc
|
|
8
|
-
end
|
|
9
|
-
it "knows who its bundle is" do
|
|
10
|
-
@toc.children.each{ |node| node.page.bundle.must_equal @bundle }
|
|
11
|
-
end
|
|
12
|
-
it "ignores leading numbers for the titles (unless all numbers)" do
|
|
13
|
-
@toc.children.each{ |node| node.page.title.must_match /(?:^\D|^\d+$|^\d+(?:.\d+)+.*$)/ }
|
|
14
|
-
end
|
|
15
|
-
it "honors pages specifying their title" do
|
|
16
|
-
@toc.children.find{ |page| page.title =~ /renamed/i }.must_be_nil
|
|
17
|
-
@toc.children.find{ |page| page.title == 'Third One' }.wont_be_nil
|
|
18
|
-
end
|
|
19
|
-
it "replaces underscores with spaces in the title" do
|
|
20
|
-
%w[ First Second Third Fourth Fifth ].each_with_index do |name,i|
|
|
21
|
-
@toc.children[i].page.title.must_equal "#{name} One"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
it "doesn't change names of files that are all numbers" do
|
|
25
|
-
@toc.children.find{ |node| node.page.title == '911' }.wont_be_nil
|
|
26
|
-
end
|
|
27
|
-
it "doesn't change names of files that lead with dotted numerics" do
|
|
28
|
-
@toc.children.find{ |node| node.page.title == '6.1 More' }.wont_be_nil
|
|
29
|
-
@toc.children.find{ |node| node.page.title == '6.2 Even More' }.wont_be_nil
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe "Traversing page hierarchy" do
|
|
34
|
-
before do
|
|
35
|
-
@out, @err = capture_io do
|
|
36
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'links' )
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
it "should have #pages returning an array" do
|
|
40
|
-
@bundle.pages.must_be_kind_of Array
|
|
41
|
-
@bundle.pages.length.must_equal 7
|
|
42
|
-
end
|
|
43
|
-
it "every item should be a Page" do
|
|
44
|
-
@bundle.pages.each do |page|
|
|
45
|
-
page.must_be_kind_of DocuBot::Page
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "Page Roots" do
|
|
51
|
-
before do
|
|
52
|
-
@out, @err = capture_io do
|
|
53
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'hierarchy' )
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "should not find any missing links creating the bundle" do
|
|
58
|
-
# The bundle uses root in the page templates extensively
|
|
59
|
-
@err.must_be_empty
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should have an empty root for pages at the root" do
|
|
63
|
-
@bundle.page_by_html_path['main.html'].root.must_equal ""
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "should have a root appropriate to the HTML depth" do
|
|
67
|
-
@bundle.page_by_html_path['1/page.html'].root.must_equal "../"
|
|
68
|
-
@bundle.page_by_html_path['1/index.html'].root.must_equal "../"
|
|
69
|
-
@bundle.page_by_html_path['1/1.1/page.html'].root.must_equal "../../"
|
|
70
|
-
@bundle.page_by_html_path['1/1.1/index.html'].root.must_equal "../../"
|
|
71
|
-
@bundle.page_by_html_path['1/1.1/1.1.1/page.html'].root.must_equal "../../../"
|
|
72
|
-
@bundle.page_by_html_path['1/1.1/1.1.1/index.html'].root.must_equal "../../../"
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe "Testing user variables" do
|
|
77
|
-
it "should identify if a variable has been defined"
|
|
78
|
-
it "should inherit variables from the global"
|
|
79
|
-
it "should override variables from the global"
|
|
80
|
-
end
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
|
4
|
+
describe "Validating page titles" do
|
|
5
|
+
before do
|
|
6
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'titles' )
|
|
7
|
+
@toc = @bundle.toc
|
|
8
|
+
end
|
|
9
|
+
it "knows who its bundle is" do
|
|
10
|
+
@toc.children.each{ |node| node.page.bundle.must_equal @bundle }
|
|
11
|
+
end
|
|
12
|
+
it "ignores leading numbers for the titles (unless all numbers)" do
|
|
13
|
+
@toc.children.each{ |node| node.page.title.must_match /(?:^\D|^\d+$|^\d+(?:.\d+)+.*$)/ }
|
|
14
|
+
end
|
|
15
|
+
it "honors pages specifying their title" do
|
|
16
|
+
@toc.children.find{ |page| page.title =~ /renamed/i }.must_be_nil
|
|
17
|
+
@toc.children.find{ |page| page.title == 'Third One' }.wont_be_nil
|
|
18
|
+
end
|
|
19
|
+
it "replaces underscores with spaces in the title" do
|
|
20
|
+
%w[ First Second Third Fourth Fifth ].each_with_index do |name,i|
|
|
21
|
+
@toc.children[i].page.title.must_equal "#{name} One"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
it "doesn't change names of files that are all numbers" do
|
|
25
|
+
@toc.children.find{ |node| node.page.title == '911' }.wont_be_nil
|
|
26
|
+
end
|
|
27
|
+
it "doesn't change names of files that lead with dotted numerics" do
|
|
28
|
+
@toc.children.find{ |node| node.page.title == '6.1 More' }.wont_be_nil
|
|
29
|
+
@toc.children.find{ |node| node.page.title == '6.2 Even More' }.wont_be_nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "Traversing page hierarchy" do
|
|
34
|
+
before do
|
|
35
|
+
@out, @err = capture_io do
|
|
36
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'links' )
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
it "should have #pages returning an array" do
|
|
40
|
+
@bundle.pages.must_be_kind_of Array
|
|
41
|
+
@bundle.pages.length.must_equal 7
|
|
42
|
+
end
|
|
43
|
+
it "every item should be a Page" do
|
|
44
|
+
@bundle.pages.each do |page|
|
|
45
|
+
page.must_be_kind_of DocuBot::Page
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "Page Roots" do
|
|
51
|
+
before do
|
|
52
|
+
@out, @err = capture_io do
|
|
53
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'hierarchy' )
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should not find any missing links creating the bundle" do
|
|
58
|
+
# The bundle uses root in the page templates extensively
|
|
59
|
+
@err.must_be_empty
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should have an empty root for pages at the root" do
|
|
63
|
+
@bundle.page_by_html_path['main.html'].root.must_equal ""
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should have a root appropriate to the HTML depth" do
|
|
67
|
+
@bundle.page_by_html_path['1/page.html'].root.must_equal "../"
|
|
68
|
+
@bundle.page_by_html_path['1/index.html'].root.must_equal "../"
|
|
69
|
+
@bundle.page_by_html_path['1/1.1/page.html'].root.must_equal "../../"
|
|
70
|
+
@bundle.page_by_html_path['1/1.1/index.html'].root.must_equal "../../"
|
|
71
|
+
@bundle.page_by_html_path['1/1.1/1.1.1/page.html'].root.must_equal "../../../"
|
|
72
|
+
@bundle.page_by_html_path['1/1.1/1.1.1/index.html'].root.must_equal "../../../"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "Testing user variables" do
|
|
77
|
+
it "should identify if a variable has been defined"
|
|
78
|
+
it "should inherit variables from the global"
|
|
79
|
+
it "should override variables from the global"
|
|
80
|
+
end
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
This page specifies no attributes; what defaults will it get?
|
|
2
|
-
|
|
3
|
-
%h2#h1 Heading 1
|
|
4
|
-
%p#p1-1 Paragraph Number 1.1
|
|
5
|
-
%p#p1-2 Paragraph Number 1.2
|
|
6
|
-
%ul
|
|
7
|
-
%li A list of items
|
|
8
|
-
%li A list of items
|
|
9
|
-
%li A list of items
|
|
10
|
-
|
|
11
|
-
%h3#h1-1 Heading 1.1
|
|
12
|
-
%p#p1-1-1 Paragraph Number 1.1.1
|
|
13
|
-
|
|
14
|
-
%h2#h2 Heading 2
|
|
15
|
-
%h3#h2-1 Heading 2.1
|
|
16
|
-
%h4#h2-1-1 Heading 2.1.1
|
|
17
|
-
%h5#h2-1-1-1 Heading 2.1.1.1
|
|
18
|
-
%p#p2-1-1-1-1 Paragraph Number 2.1.1.1.1
|
|
19
|
-
|
|
20
|
-
%h3#h2-2 Heading 2.2
|
|
21
|
-
%p#p2-2-1 Paragraph Number 2.2.1
|
|
22
|
-
%dl
|
|
23
|
-
%dt#dt1 Giggity
|
|
24
|
-
%dd#dd1 Quagmire
|
|
25
|
-
%dt#dt2 Zanzibar
|
|
26
|
-
%dd#dd2 The Best
|
|
27
|
-
|
|
28
|
-
%p#p2-2-2 Paragraph Number 2.2.2
|
|
29
|
-
|
|
30
|
-
%h1#h0 Heading 0
|
|
31
|
-
%p#p0-1
|
|
32
|
-
Paragraph 0.1
|
|
33
|
-
Whoa, this heading is larger than any other before it!
|
|
34
|
-
|
|
1
|
+
This page specifies no attributes; what defaults will it get?
|
|
2
|
+
|
|
3
|
+
%h2#h1 Heading 1
|
|
4
|
+
%p#p1-1 Paragraph Number 1.1
|
|
5
|
+
%p#p1-2 Paragraph Number 1.2
|
|
6
|
+
%ul
|
|
7
|
+
%li A list of items
|
|
8
|
+
%li A list of items
|
|
9
|
+
%li A list of items
|
|
10
|
+
|
|
11
|
+
%h3#h1-1 Heading 1.1
|
|
12
|
+
%p#p1-1-1 Paragraph Number 1.1.1
|
|
13
|
+
|
|
14
|
+
%h2#h2 Heading 2
|
|
15
|
+
%h3#h2-1 Heading 2.1
|
|
16
|
+
%h4#h2-1-1 Heading 2.1.1
|
|
17
|
+
%h5#h2-1-1-1 Heading 2.1.1.1
|
|
18
|
+
%p#p2-1-1-1-1 Paragraph Number 2.1.1.1.1
|
|
19
|
+
|
|
20
|
+
%h3#h2-2 Heading 2.2
|
|
21
|
+
%p#p2-2-1 Paragraph Number 2.2.1
|
|
22
|
+
%dl
|
|
23
|
+
%dt#dt1 Giggity
|
|
24
|
+
%dd#dd1 Quagmire
|
|
25
|
+
%dt#dt2 Zanzibar
|
|
26
|
+
%dd#dd2 The Best
|
|
27
|
+
|
|
28
|
+
%p#p2-2-2 Paragraph Number 2.2.2
|
|
29
|
+
|
|
30
|
+
%h1#h0 Heading 0
|
|
31
|
+
%p#p0-1
|
|
32
|
+
Paragraph 0.1
|
|
33
|
+
Whoa, this heading is larger than any other before it!
|
|
34
|
+
|