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/samples/links/root.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[External](http://www.google.com/)
|
|
2
|
-
[Internal](#sub-id)
|
|
3
|
-
[Internal](root.html#sub-id)
|
|
4
|
-
[Internal](sub1/inner1.html)
|
|
5
|
-
[Internal](sub2.html)
|
|
6
|
-
[Internal](sub2/inner2.html)
|
|
7
|
-
[Internal](sub1/../sub2/inner2.html)
|
|
8
|
-
[BROKEN](fork.html)
|
|
9
|
-
[BROKEN](sub1.html)
|
|
10
|
-
[BROKEN](root.md)
|
|
11
|
-
[BROKEN](sub1/inner1.md)
|
|
12
|
-
[BROKEN](#GORKBO)
|
|
13
|
-
|
|
1
|
+
[External](http://www.google.com/)
|
|
2
|
+
[Internal](#sub-id)
|
|
3
|
+
[Internal](root.html#sub-id)
|
|
4
|
+
[Internal](sub1/inner1.html)
|
|
5
|
+
[Internal](sub2.html)
|
|
6
|
+
[Internal](sub2/inner2.html)
|
|
7
|
+
[Internal](sub1/../sub2/inner2.html)
|
|
8
|
+
[BROKEN](fork.html)
|
|
9
|
+
[BROKEN](sub1.html)
|
|
10
|
+
[BROKEN](root.md)
|
|
11
|
+
[BROKEN](sub1/inner1.md)
|
|
12
|
+
[BROKEN](#GORKBO)
|
|
13
|
+
|
|
14
14
|
<div id="sub-id">Just in case</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[External](http://phrogz.net)
|
|
2
|
-
[Internal](../root.html)
|
|
3
|
-
[Internal](../root.html#sub-id)
|
|
4
|
-
[Internal](inner1.html)
|
|
5
|
-
[Internal](../sub2.html)
|
|
6
|
-
[Internal](../sub2/inner2.html)
|
|
7
|
-
[File](../sub2/bozo.bin)
|
|
8
|
-
[BROKEN](inner2.html)
|
|
9
|
-
[BROKEN](../sub1)
|
|
10
|
-
[BROKEN](sub1/inner1.md)
|
|
11
|
-
[BROKEN](../root.html#GORKBO)
|
|
1
|
+
[External](http://phrogz.net)
|
|
2
|
+
[Internal](../root.html)
|
|
3
|
+
[Internal](../root.html#sub-id)
|
|
4
|
+
[Internal](inner1.html)
|
|
5
|
+
[Internal](../sub2.html)
|
|
6
|
+
[Internal](../sub2/inner2.html)
|
|
7
|
+
[File](../sub2/bozo.bin)
|
|
8
|
+
[BROKEN](inner2.html)
|
|
9
|
+
[BROKEN](../sub1)
|
|
10
|
+
[BROKEN](sub1/inner1.md)
|
|
11
|
+
[BROKEN](../root.html#GORKBO)
|
data/spec/samples/links/sub2.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[External](HTTP://NONEXISTENT.SITE)
|
|
2
|
-
[File](sub2/bozo.bin)
|
|
3
|
-
[BROKEN](sub2/GORKBO.bin)
|
|
4
|
-
[SPACES](one%20two%20three.html)
|
|
1
|
+
[External](HTTP://NONEXISTENT.SITE)
|
|
2
|
+
[File](sub2/bozo.bin)
|
|
3
|
+
[BROKEN](sub2/GORKBO.bin)
|
|
4
|
+
[SPACES](one%20two%20three.html)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
[External](http://phrogz.net/tmp/gkhead.jpg)
|
|
2
|
-
[Internal](../sub1/index.html) Even though there isn't an index.md file.
|
|
3
|
-
[Internal](index.html) Even though there isn't an index.md file.
|
|
4
|
-
[File](bozo.bin)
|
|
5
|
-
[BROKEN](../index.html) Because the global root is not a valid link.
|
|
6
|
-
[BROKEN](../sub1)
|
|
7
|
-
[BROKEN](../index.md)
|
|
1
|
+
[External](http://phrogz.net/tmp/gkhead.jpg)
|
|
2
|
+
[Internal](../sub1/index.html) Even though there isn't an index.md file.
|
|
3
|
+
[Internal](index.html) Even though there isn't an index.md file.
|
|
4
|
+
[File](bozo.bin)
|
|
5
|
+
[BROKEN](../index.html) Because the global root is not a valid link.
|
|
6
|
+
[BROKEN](../sub1)
|
|
7
|
+
[BROKEN](../index.md)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<h2>Hello World</h2>
|
|
2
|
-
|
|
3
|
-
<p>It's the end of the world as we know it, and I feel fine. Because:</p>
|
|
4
|
-
|
|
5
|
-
<ul>
|
|
6
|
-
<li>I'm on my medication. Which is delicious.<ul>
|
|
7
|
-
<li>I buy it from a store. A candy store.</li>
|
|
8
|
-
</ul></li>
|
|
9
|
-
<li>In the end, we're all going to go.</li>
|
|
1
|
+
<h2>Hello World</h2>
|
|
2
|
+
|
|
3
|
+
<p>It's the end of the world as we know it, and I feel fine. Because:</p>
|
|
4
|
+
|
|
5
|
+
<ul>
|
|
6
|
+
<li>I'm on my medication. Which is delicious.<ul>
|
|
7
|
+
<li>I buy it from a store. A candy store.</li>
|
|
8
|
+
</ul></li>
|
|
9
|
+
<li>In the end, we're all going to go.</li>
|
|
10
10
|
</ul>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
%h2 Hello World
|
|
2
|
-
|
|
3
|
-
%p
|
|
4
|
-
It's the end of the world as we know it,
|
|
5
|
-
and I feel fine. Because:
|
|
6
|
-
|
|
7
|
-
%ul
|
|
8
|
-
%li
|
|
9
|
-
I'm on my medication.
|
|
10
|
-
Which is delicious.
|
|
11
|
-
%ul
|
|
12
|
-
%li I buy it from a store. A candy store.
|
|
1
|
+
%h2 Hello World
|
|
2
|
+
|
|
3
|
+
%p
|
|
4
|
+
It's the end of the world as we know it,
|
|
5
|
+
and I feel fine. Because:
|
|
6
|
+
|
|
7
|
+
%ul
|
|
8
|
+
%li
|
|
9
|
+
I'm on my medication.
|
|
10
|
+
Which is delicious.
|
|
11
|
+
%ul
|
|
12
|
+
%li I buy it from a store. A candy store.
|
|
13
13
|
%li In the end, we're all going to go.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Hello World
|
|
2
|
-
-----------
|
|
3
|
-
It's the end of the world as we know it,
|
|
4
|
-
and I feel fine. Because:
|
|
5
|
-
|
|
6
|
-
* I'm on my medication.
|
|
7
|
-
Which is delicious.
|
|
8
|
-
* I buy it from a store.
|
|
9
|
-
A candy store.
|
|
1
|
+
Hello World
|
|
2
|
+
-----------
|
|
3
|
+
It's the end of the world as we know it,
|
|
4
|
+
and I feel fine. Because:
|
|
5
|
+
|
|
6
|
+
* I'm on my medication.
|
|
7
|
+
Which is delicious.
|
|
8
|
+
* I buy it from a store.
|
|
9
|
+
A candy store.
|
|
10
10
|
* In the end, we're all going to go.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Hello World
|
|
2
|
-
-----------
|
|
3
|
-
It's the end of the world as we know it,
|
|
4
|
-
and I feel fine. Because:
|
|
5
|
-
|
|
6
|
-
* I'm on my medication.
|
|
7
|
-
Which is delicious.
|
|
8
|
-
* I buy it from a store.
|
|
9
|
-
A candy store.
|
|
1
|
+
Hello World
|
|
2
|
+
-----------
|
|
3
|
+
It's the end of the world as we know it,
|
|
4
|
+
and I feel fine. Because:
|
|
5
|
+
|
|
6
|
+
* I'm on my medication.
|
|
7
|
+
Which is delicious.
|
|
8
|
+
* I buy it from a store.
|
|
9
|
+
A candy store.
|
|
10
10
|
* In the end, we're all going to go.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
h2. Hello World
|
|
2
|
-
|
|
3
|
-
It's the end of the world as we know it,
|
|
4
|
-
and I feel fine. Because:
|
|
5
|
-
|
|
6
|
-
* I'm on my medication.
|
|
7
|
-
Which is delicious.
|
|
8
|
-
** I buy it from a store.
|
|
9
|
-
A candy store.
|
|
1
|
+
h2. Hello World
|
|
2
|
+
|
|
3
|
+
It's the end of the world as we know it,
|
|
4
|
+
and I feel fine. Because:
|
|
5
|
+
|
|
6
|
+
* I'm on my medication.
|
|
7
|
+
Which is delicious.
|
|
8
|
+
** I buy it from a store.
|
|
9
|
+
A candy store.
|
|
10
10
|
* In the end, we're all going to go.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#doubler
|
|
2
|
-
- if page.multiplier
|
|
3
|
-
- page.multiplier.to_i.times do
|
|
4
|
-
= contents
|
|
5
|
-
- else
|
|
6
|
-
= contents
|
|
1
|
+
#doubler
|
|
2
|
+
- if page.multiplier
|
|
3
|
+
- page.multiplier.to_i.times do
|
|
4
|
+
= contents
|
|
5
|
+
- else
|
|
6
|
+
= contents
|
|
7
7
|
= contents
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#pager
|
|
1
|
+
#pager
|
|
2
2
|
= contents
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
template: 404
|
|
2
|
-
+++
|
|
1
|
+
template: 404
|
|
2
|
+
+++
|
|
3
3
|
I DO NOT LIKE YOU
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
title: 1*1
|
|
2
|
-
+++
|
|
1
|
+
title: 1*1
|
|
2
|
+
+++
|
|
3
3
|
<p>Para1</p>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
title : 1*2
|
|
2
|
-
template : doubler
|
|
3
|
-
multiplier : 3
|
|
4
|
-
+++
|
|
1
|
+
title : 1*2
|
|
2
|
+
template : doubler
|
|
3
|
+
multiplier : 3
|
|
4
|
+
+++
|
|
5
5
|
Para1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
title : 2*1
|
|
2
|
-
template: page
|
|
3
|
-
+++
|
|
4
|
-
%p
|
|
5
|
-
Para1
|
|
6
|
-
%p
|
|
1
|
+
title : 2*1
|
|
2
|
+
template: page
|
|
3
|
+
+++
|
|
4
|
+
%p
|
|
5
|
+
Para1
|
|
6
|
+
%p
|
|
7
7
|
Para2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
title: 2*2
|
|
2
|
-
template: doubler
|
|
3
|
-
+++
|
|
4
|
-
p. Para1
|
|
5
|
-
|
|
1
|
+
title: 2*2
|
|
2
|
+
template: doubler
|
|
3
|
+
+++
|
|
4
|
+
p. Para1
|
|
5
|
+
|
|
6
6
|
p. Para2
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
title: Third One
|
|
1
|
+
title: Third One
|
|
2
2
|
+++
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
title : Title Changin'
|
|
1
|
+
title : Title Changin'
|
|
2
2
|
+++
|
data/spec/templates.rb
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
4
|
-
describe "Variety Hour" do
|
|
5
|
-
before do
|
|
6
|
-
@bundle = DocuBot::Bundle.new( SAMPLES/'templates' )
|
|
7
|
-
@page_by_title = Hash[ *@bundle.pages.map{ |p| [p.title,p] }.flatten ]
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "uses the 'page' template if not specified" do
|
|
11
|
-
@page_by_title.must_include '1*1'
|
|
12
|
-
html = @page_by_title['1*1'].to_html
|
|
13
|
-
html.must_include 'pager'
|
|
14
|
-
html.scan(/<p>/).length.must_equal 1
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "passes the page for use by another specified template" do
|
|
18
|
-
@page_by_title.must_include '1*2'
|
|
19
|
-
html = @page_by_title['1*2'].to_html
|
|
20
|
-
html.must_include 'doubler'
|
|
21
|
-
html.scan(/<p>/).length.must_equal 3
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "can use the 'page' template explicitly" do
|
|
25
|
-
@page_by_title.must_include '2*1'
|
|
26
|
-
html = @page_by_title['2*1'].to_html
|
|
27
|
-
html.must_include 'page'
|
|
28
|
-
html.scan(/<p>/).length.must_equal 2
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should have templates handle missing attributes" do
|
|
32
|
-
@page_by_title.must_include '2*2'
|
|
33
|
-
html = @page_by_title['2*2'].to_html
|
|
34
|
-
html.must_include 'doubler'
|
|
35
|
-
html.scan(/<p>/).length.must_equal 4
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "can have templates that do not include contents" do
|
|
39
|
-
@page_by_title.must_include 'goaway'
|
|
40
|
-
html = @page_by_title['goaway'].to_html
|
|
41
|
-
html.must_include 'Oops!'
|
|
42
|
-
html.wont_include 'I DO NOT LIKE YOU'
|
|
43
|
-
end
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
|
4
|
+
describe "Variety Hour" do
|
|
5
|
+
before do
|
|
6
|
+
@bundle = DocuBot::Bundle.new( SAMPLES/'templates' )
|
|
7
|
+
@page_by_title = Hash[ *@bundle.pages.map{ |p| [p.title,p] }.flatten ]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "uses the 'page' template if not specified" do
|
|
11
|
+
@page_by_title.must_include '1*1'
|
|
12
|
+
html = @page_by_title['1*1'].to_html
|
|
13
|
+
html.must_include 'pager'
|
|
14
|
+
html.scan(/<p>/).length.must_equal 1
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "passes the page for use by another specified template" do
|
|
18
|
+
@page_by_title.must_include '1*2'
|
|
19
|
+
html = @page_by_title['1*2'].to_html
|
|
20
|
+
html.must_include 'doubler'
|
|
21
|
+
html.scan(/<p>/).length.must_equal 3
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "can use the 'page' template explicitly" do
|
|
25
|
+
@page_by_title.must_include '2*1'
|
|
26
|
+
html = @page_by_title['2*1'].to_html
|
|
27
|
+
html.must_include 'page'
|
|
28
|
+
html.scan(/<p>/).length.must_equal 2
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should have templates handle missing attributes" do
|
|
32
|
+
@page_by_title.must_include '2*2'
|
|
33
|
+
html = @page_by_title['2*2'].to_html
|
|
34
|
+
html.must_include 'doubler'
|
|
35
|
+
html.scan(/<p>/).length.must_equal 4
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "can have templates that do not include contents" do
|
|
39
|
+
@page_by_title.must_include 'goaway'
|
|
40
|
+
html = @page_by_title['goaway'].to_html
|
|
41
|
+
html.must_include 'Oops!'
|
|
42
|
+
html.wont_include 'I DO NOT LIKE YOU'
|
|
43
|
+
end
|
|
44
44
|
end
|
data/spec/toc.rb
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
-
|
|
4
|
-
describe "Simplest Table of Contents" do
|
|
5
|
-
before do
|
|
6
|
-
Dir.chdir SAMPLES/'simplest' do
|
|
7
|
-
@bundle = DocuBot::Bundle.new( '.' )
|
|
8
|
-
@toc = @bundle.toc
|
|
9
|
-
@files = Dir['*']
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "knows who its bundle is" do
|
|
14
|
-
@toc.bundle.must_equal @bundle
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "preserves simple names as titles" do
|
|
18
|
-
@toc.children.length.must_equal @files.length
|
|
19
|
-
@files.each do |source_file|
|
|
20
|
-
filename_without_extension = source_file.sub( /\.[^.]+$/, '' )
|
|
21
|
-
@toc.children.find{ |node| node.title==filename_without_extension }.wont_be_nil
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "preserves file system ordering" do
|
|
26
|
-
@files.each_with_index do |source_file,i|
|
|
27
|
-
filename_without_extension = source_file.sub( /\.[^.]+$/, '' )
|
|
28
|
-
@toc.children[i].title.must_equal filename_without_extension
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "has no parent or ancestors" do
|
|
33
|
-
@toc.parent.must_be_nil
|
|
34
|
-
@toc.ancestors.must_be_empty
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "is not the parent of any top-level links" do
|
|
38
|
-
@toc.children.each{ |node| node.parent.wont_equal @toc }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "is at depth 0 with no root" do
|
|
42
|
-
@toc.depth.must_equal 0
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe "Renamed Table of Contents" do
|
|
47
|
-
it "honors the title of the root index file" do
|
|
48
|
-
DocuBot::Bundle.new(SAMPLES/'titles').global.title.must_equal "Title Changin'"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
describe "Sub-page Links in the Table of Contents" do
|
|
53
|
-
before do
|
|
54
|
-
@out, @err = capture_io do
|
|
55
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'attributes'
|
|
56
|
-
@toc = @bundle.toc
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should find pages by html link" do
|
|
61
|
-
e1 = @toc.find('explicit1.html')
|
|
62
|
-
e1.wont_be_nil
|
|
63
|
-
e1.page.wont_be_nil
|
|
64
|
-
e1.page.file == 'explicit1.haml'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should not have entries for hidden pages" do
|
|
68
|
-
@bundle.pages_by_title['hidden'].wont_be_empty
|
|
69
|
-
hidden = @bundle.page_by_html_path['hidden.html']
|
|
70
|
-
hidden.wont_be_nil
|
|
71
|
-
@toc.find('hidden.html').must_be_nil
|
|
72
|
-
@toc.descendants.select{ |node| node.link['hidden.html'] }.must_be_empty
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should warn about failed TOC requests" do
|
|
76
|
-
# explicit2.haml has an existing ID on the element for "Heading 1",
|
|
77
|
-
# so it can't update the HTML id or the TOC request to match.
|
|
78
|
-
@err.must_include "Heading 1"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should have sub-entries" do
|
|
82
|
-
e2 = @toc.find('explicit2.html')
|
|
83
|
-
|
|
84
|
-
e2.children.length.must_equal 3
|
|
85
|
-
|
|
86
|
-
# The first sub-link is not "Heading 1" because explicit2.haml has an existing ID on that element
|
|
87
|
-
# and so cannot (at this time) change either the HTML id or the TOC request to match.
|
|
88
|
-
# It is ignored.
|
|
89
|
-
kid = e2.children[0]
|
|
90
|
-
kid.title.must_equal "Heading 1.1"
|
|
91
|
-
kid.link.must_equal 'explicit2.html#h1-1'
|
|
92
|
-
kid.page.must_equal e2.page
|
|
93
|
-
|
|
94
|
-
kid = e2.children[1]
|
|
95
|
-
kid.title.must_equal "Giggity"
|
|
96
|
-
kid.file.must_equal 'explicit2.html'
|
|
97
|
-
# No assumptions are made about the generated id.
|
|
98
|
-
kid.page.must_equal e2.page
|
|
99
|
-
|
|
100
|
-
kid = e2.children[2]
|
|
101
|
-
kid.title.must_equal "Heading 0"
|
|
102
|
-
kid.file.must_equal 'explicit2.html'
|
|
103
|
-
kid.anchor.must_equal 'h0'
|
|
104
|
-
kid.link.must_equal 'explicit2.html#h0'
|
|
105
|
-
kid.page.must_equal e2.page
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
describe "ToC with Deep Hierarchy" do
|
|
110
|
-
before do
|
|
111
|
-
@bundle = DocuBot::Bundle.new SAMPLES/'hierarchy'
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "should match the expected hierarchy" do
|
|
115
|
-
@bundle.toc[0].page.title.must_equal '1'
|
|
116
|
-
@bundle.toc[0][0].page.title.must_equal '1.1'
|
|
117
|
-
@bundle.toc[0][0][0].page.title.must_equal '1.1.1'
|
|
118
|
-
@bundle.toc[0][0][0][0].page.title.must_equal '1.1.1p'
|
|
119
|
-
@bundle.toc[0][0][1].page.title.must_equal '1.1p'
|
|
120
|
-
@bundle.toc[0][1].page.title.must_equal '1p'
|
|
121
|
-
@bundle.toc[1].page.title.must_equal '2'
|
|
122
|
-
@bundle.toc[1][0].page.title.must_equal '2.1'
|
|
123
|
-
@bundle.toc[1][0][0].page.title.must_equal '2.1.1'
|
|
124
|
-
@bundle.toc[1][0][0][0].page.title.must_equal '2.1.1p'
|
|
125
|
-
@bundle.toc[1][0][1].page.title.must_equal '2.1p'
|
|
126
|
-
@bundle.toc[1][1].page.title.must_equal '2p'
|
|
127
|
-
@bundle.toc[2].page.title.must_equal 'main'
|
|
128
|
-
end
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "_helper")
|
|
3
|
+
|
|
4
|
+
describe "Simplest Table of Contents" do
|
|
5
|
+
before do
|
|
6
|
+
Dir.chdir SAMPLES/'simplest' do
|
|
7
|
+
@bundle = DocuBot::Bundle.new( '.' )
|
|
8
|
+
@toc = @bundle.toc
|
|
9
|
+
@files = Dir['*']
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "knows who its bundle is" do
|
|
14
|
+
@toc.bundle.must_equal @bundle
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "preserves simple names as titles" do
|
|
18
|
+
@toc.children.length.must_equal @files.length
|
|
19
|
+
@files.each do |source_file|
|
|
20
|
+
filename_without_extension = source_file.sub( /\.[^.]+$/, '' )
|
|
21
|
+
@toc.children.find{ |node| node.title==filename_without_extension }.wont_be_nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "preserves file system ordering" do
|
|
26
|
+
@files.each_with_index do |source_file,i|
|
|
27
|
+
filename_without_extension = source_file.sub( /\.[^.]+$/, '' )
|
|
28
|
+
@toc.children[i].title.must_equal filename_without_extension
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "has no parent or ancestors" do
|
|
33
|
+
@toc.parent.must_be_nil
|
|
34
|
+
@toc.ancestors.must_be_empty
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "is not the parent of any top-level links" do
|
|
38
|
+
@toc.children.each{ |node| node.parent.wont_equal @toc }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "is at depth 0 with no root" do
|
|
42
|
+
@toc.depth.must_equal 0
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "Renamed Table of Contents" do
|
|
47
|
+
it "honors the title of the root index file" do
|
|
48
|
+
DocuBot::Bundle.new(SAMPLES/'titles').global.title.must_equal "Title Changin'"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "Sub-page Links in the Table of Contents" do
|
|
53
|
+
before do
|
|
54
|
+
@out, @err = capture_io do
|
|
55
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'attributes'
|
|
56
|
+
@toc = @bundle.toc
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should find pages by html link" do
|
|
61
|
+
e1 = @toc.find('explicit1.html')
|
|
62
|
+
e1.wont_be_nil
|
|
63
|
+
e1.page.wont_be_nil
|
|
64
|
+
e1.page.file == 'explicit1.haml'
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should not have entries for hidden pages" do
|
|
68
|
+
@bundle.pages_by_title['hidden'].wont_be_empty
|
|
69
|
+
hidden = @bundle.page_by_html_path['hidden.html']
|
|
70
|
+
hidden.wont_be_nil
|
|
71
|
+
@toc.find('hidden.html').must_be_nil
|
|
72
|
+
@toc.descendants.select{ |node| node.link['hidden.html'] }.must_be_empty
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should warn about failed TOC requests" do
|
|
76
|
+
# explicit2.haml has an existing ID on the element for "Heading 1",
|
|
77
|
+
# so it can't update the HTML id or the TOC request to match.
|
|
78
|
+
@err.must_include "Heading 1"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should have sub-entries" do
|
|
82
|
+
e2 = @toc.find('explicit2.html')
|
|
83
|
+
|
|
84
|
+
e2.children.length.must_equal 3
|
|
85
|
+
|
|
86
|
+
# The first sub-link is not "Heading 1" because explicit2.haml has an existing ID on that element
|
|
87
|
+
# and so cannot (at this time) change either the HTML id or the TOC request to match.
|
|
88
|
+
# It is ignored.
|
|
89
|
+
kid = e2.children[0]
|
|
90
|
+
kid.title.must_equal "Heading 1.1"
|
|
91
|
+
kid.link.must_equal 'explicit2.html#h1-1'
|
|
92
|
+
kid.page.must_equal e2.page
|
|
93
|
+
|
|
94
|
+
kid = e2.children[1]
|
|
95
|
+
kid.title.must_equal "Giggity"
|
|
96
|
+
kid.file.must_equal 'explicit2.html'
|
|
97
|
+
# No assumptions are made about the generated id.
|
|
98
|
+
kid.page.must_equal e2.page
|
|
99
|
+
|
|
100
|
+
kid = e2.children[2]
|
|
101
|
+
kid.title.must_equal "Heading 0"
|
|
102
|
+
kid.file.must_equal 'explicit2.html'
|
|
103
|
+
kid.anchor.must_equal 'h0'
|
|
104
|
+
kid.link.must_equal 'explicit2.html#h0'
|
|
105
|
+
kid.page.must_equal e2.page
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe "ToC with Deep Hierarchy" do
|
|
110
|
+
before do
|
|
111
|
+
@bundle = DocuBot::Bundle.new SAMPLES/'hierarchy'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should match the expected hierarchy" do
|
|
115
|
+
@bundle.toc[0].page.title.must_equal '1'
|
|
116
|
+
@bundle.toc[0][0].page.title.must_equal '1.1'
|
|
117
|
+
@bundle.toc[0][0][0].page.title.must_equal '1.1.1'
|
|
118
|
+
@bundle.toc[0][0][0][0].page.title.must_equal '1.1.1p'
|
|
119
|
+
@bundle.toc[0][0][1].page.title.must_equal '1.1p'
|
|
120
|
+
@bundle.toc[0][1].page.title.must_equal '1p'
|
|
121
|
+
@bundle.toc[1].page.title.must_equal '2'
|
|
122
|
+
@bundle.toc[1][0].page.title.must_equal '2.1'
|
|
123
|
+
@bundle.toc[1][0][0].page.title.must_equal '2.1.1'
|
|
124
|
+
@bundle.toc[1][0][0][0].page.title.must_equal '2.1.1p'
|
|
125
|
+
@bundle.toc[1][0][1].page.title.must_equal '2.1p'
|
|
126
|
+
@bundle.toc[1][1].page.title.must_equal '2p'
|
|
127
|
+
@bundle.toc[2].page.title.must_equal 'main'
|
|
128
|
+
end
|
|
129
129
|
end
|