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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
pattern = /\$\$(\w[\w: ]*\w)\$\$/
|
|
3
|
-
DocuBot.handle_snippet pattern do |match, page|
|
|
4
|
-
parts = match[ 2..-3 ].split(':',2)
|
|
5
|
-
text, term = parts.first, parts.last
|
|
6
|
-
page.bundle.glossary.term_used( term, page )
|
|
7
|
-
"<span class='glossary' term='#{term}'>#{text}</span>"
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
pattern = /\$\$(\w[\w: ]*\w)\$\$/
|
|
3
|
+
DocuBot.handle_snippet pattern do |match, page|
|
|
4
|
+
parts = match[ 2..-3 ].split(':',2)
|
|
5
|
+
text, term = parts.first, parts.last
|
|
6
|
+
page.bundle.glossary.term_used( term, page )
|
|
7
|
+
"<span class='glossary' term='#{term}'>#{text}</span>"
|
|
8
8
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
pattern = /@@(\w[\w ]*?)@@/
|
|
3
|
-
DocuBot.handle_snippet pattern do |match, page|
|
|
4
|
-
keyword = match[ 2..-3 ]
|
|
5
|
-
page.bundle.index.add( keyword, page )
|
|
6
|
-
keyword
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
pattern = /@@(\w[\w ]*?)@@/
|
|
3
|
+
DocuBot.handle_snippet pattern do |match, page|
|
|
4
|
+
keyword = match[ 2..-3 ]
|
|
5
|
+
page.bundle.index.add( keyword, page )
|
|
6
|
+
keyword
|
|
7
7
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#glossary-box { display:none; position:absolute; width:30%; background:#e0efcc; border:1px solid #82a851; padding:0.5em 0.9em; font-size:9pt; font-family:Calibri, Tahoma; }
|
|
2
|
-
#glossary-box * { margin:0 }
|
|
3
|
-
span.glossary { color:#36401C; border-bottom:1px dotted #6e8e34; cursor:help; }
|
|
1
|
+
#glossary-box { display:none; position:absolute; width:30%; background:#e0efcc; border:1px solid #82a851; padding:0.5em 0.9em; font-size:9pt; font-family:Calibri, Tahoma; }
|
|
2
|
+
#glossary-box * { margin:0 }
|
|
3
|
+
span.glossary { color:#36401C; border-bottom:1px dotted #6e8e34; cursor:help; }
|
|
4
4
|
span.glossary-missing { border-bottom:1px dotted #c00 }
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
function handleEvent(obj,eventName,callback,useCapture){
|
|
2
|
-
return obj.addEventListener ? obj.addEventListener(eventName,callback,useCapture||false) : obj.attachEvent("on"+eventName,callback);
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
cssClass = {
|
|
6
|
-
_killCache : {},
|
|
7
|
-
_findCache : {},
|
|
8
|
-
add : function cssClassAdd(obj,className){
|
|
9
|
-
this.kill(obj,className);
|
|
10
|
-
obj.className+=(obj.className.length?' ':'')+className;
|
|
11
|
-
},
|
|
12
|
-
kill : function cssClassKill(obj,className){
|
|
13
|
-
var re = this._killCache[className] || (this._killCache[className]=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g') );
|
|
14
|
-
obj.className = obj.className.replace(re,'');
|
|
15
|
-
},
|
|
16
|
-
has : function cssClassHas(obj,className){
|
|
17
|
-
var re = this._findCache[className] || (this._findCache[className]=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)') );
|
|
18
|
-
return re.test( obj.className );
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function glossaryClick(evt){
|
|
23
|
-
if (!evt) evt=event;
|
|
24
|
-
var target = evt.target || evt.srcElement;
|
|
25
|
-
var term = target.getAttribute('term') || target.innerHTML;
|
|
26
|
-
var box = document.getElementById('glossary-box');
|
|
27
|
-
box.style.display = 'block';
|
|
28
|
-
var scroll = (document.documentElement.scrollTop || document.body.scrollTop )*1;
|
|
29
|
-
box.style.left = (evt.clientX+5) + 'px';
|
|
30
|
-
box.style.top = (evt.clientY+5) + scroll + 'px';
|
|
31
|
-
|
|
32
|
-
var html = $glossaryTerms[term.toLowerCase()];
|
|
33
|
-
box.innerHTML = html;
|
|
34
|
-
|
|
35
|
-
evt.cancelBubble = true;
|
|
36
|
-
if (evt.stopPropogation) evt.stopPropogation();
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
handleEvent(window,'load',function(){
|
|
41
|
-
for ( var spans=document.getElementsByTagName('span'),i=spans.length-1; i>=0; --i ){
|
|
42
|
-
var span = spans[i];
|
|
43
|
-
if (cssClass.has(span,'glossary')){
|
|
44
|
-
var term = span.getAttribute('term') || span.innerHTML;
|
|
45
|
-
if ($glossaryTerms[term.toLowerCase()]){
|
|
46
|
-
handleEvent(span,'click',glossaryClick);
|
|
47
|
-
}else{
|
|
48
|
-
cssClass.kill(span,'glossary');
|
|
49
|
-
cssClass.add(span,'glossary-missing');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
var box = document.getElementById('glossary-box');
|
|
55
|
-
handleEvent( document.body, 'click', function(){
|
|
56
|
-
box.style.display = 'none';
|
|
57
|
-
});
|
|
1
|
+
function handleEvent(obj,eventName,callback,useCapture){
|
|
2
|
+
return obj.addEventListener ? obj.addEventListener(eventName,callback,useCapture||false) : obj.attachEvent("on"+eventName,callback);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
cssClass = {
|
|
6
|
+
_killCache : {},
|
|
7
|
+
_findCache : {},
|
|
8
|
+
add : function cssClassAdd(obj,className){
|
|
9
|
+
this.kill(obj,className);
|
|
10
|
+
obj.className+=(obj.className.length?' ':'')+className;
|
|
11
|
+
},
|
|
12
|
+
kill : function cssClassKill(obj,className){
|
|
13
|
+
var re = this._killCache[className] || (this._killCache[className]=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g') );
|
|
14
|
+
obj.className = obj.className.replace(re,'');
|
|
15
|
+
},
|
|
16
|
+
has : function cssClassHas(obj,className){
|
|
17
|
+
var re = this._findCache[className] || (this._findCache[className]=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)') );
|
|
18
|
+
return re.test( obj.className );
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function glossaryClick(evt){
|
|
23
|
+
if (!evt) evt=event;
|
|
24
|
+
var target = evt.target || evt.srcElement;
|
|
25
|
+
var term = target.getAttribute('term') || target.innerHTML;
|
|
26
|
+
var box = document.getElementById('glossary-box');
|
|
27
|
+
box.style.display = 'block';
|
|
28
|
+
var scroll = (document.documentElement.scrollTop || document.body.scrollTop )*1;
|
|
29
|
+
box.style.left = (evt.clientX+5) + 'px';
|
|
30
|
+
box.style.top = (evt.clientY+5) + scroll + 'px';
|
|
31
|
+
|
|
32
|
+
var html = $glossaryTerms[term.toLowerCase()];
|
|
33
|
+
box.innerHTML = html;
|
|
34
|
+
|
|
35
|
+
evt.cancelBubble = true;
|
|
36
|
+
if (evt.stopPropogation) evt.stopPropogation();
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
handleEvent(window,'load',function(){
|
|
41
|
+
for ( var spans=document.getElementsByTagName('span'),i=spans.length-1; i>=0; --i ){
|
|
42
|
+
var span = spans[i];
|
|
43
|
+
if (cssClass.has(span,'glossary')){
|
|
44
|
+
var term = span.getAttribute('term') || span.innerHTML;
|
|
45
|
+
if ($glossaryTerms[term.toLowerCase()]){
|
|
46
|
+
handleEvent(span,'click',glossaryClick);
|
|
47
|
+
}else{
|
|
48
|
+
cssClass.kill(span,'glossary');
|
|
49
|
+
cssClass.add(span,'glossary-missing');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
var box = document.getElementById('glossary-box');
|
|
55
|
+
handleEvent( document.body, 'click', function(){
|
|
56
|
+
box.style.display = 'none';
|
|
57
|
+
});
|
|
58
58
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
-# TODO: Breakdown by letter.
|
|
2
|
-
%ul#index
|
|
3
|
-
- global.index.entries.sort_by{ |k,p| k.downcase }.each do |keyword,pages|
|
|
4
|
-
- if pages.length == 1
|
|
5
|
-
%li
|
|
6
|
-
%a{ :href => pages.first.html_path }= keyword
|
|
7
|
-
- else
|
|
8
|
-
%li
|
|
9
|
-
= keyword
|
|
10
|
-
%ul
|
|
11
|
-
- pages.each do |page|
|
|
12
|
-
%li
|
|
13
|
-
%a{ :href => page.html_path }= page.title
|
|
14
|
-
|
|
1
|
+
-# TODO: Breakdown by letter.
|
|
2
|
+
%ul#index
|
|
3
|
+
- global.index.entries.sort_by{ |k,p| k.downcase }.each do |keyword,pages|
|
|
4
|
+
- if pages.length == 1
|
|
5
|
+
%li
|
|
6
|
+
%a{ :href => pages.first.html_path }= keyword
|
|
7
|
+
- else
|
|
8
|
+
%li
|
|
9
|
+
= keyword
|
|
10
|
+
%ul
|
|
11
|
+
- pages.each do |page|
|
|
12
|
+
%li
|
|
13
|
+
%a{ :href => page.html_path }= page.title
|
|
14
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
%ul#toc
|
|
2
|
-
- li_pages_for global.toc
|
|
1
|
+
%ul#toc
|
|
2
|
+
- li_pages_for global.toc
|
|
3
3
|
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
!!! Strict
|
|
2
|
-
%html
|
|
3
|
-
%head
|
|
4
|
-
%meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
|
|
5
|
-
%link{:rel=>'stylesheet', :type=>'text/css', :href=>"#{root}common.css", :media=>'all'}
|
|
6
|
-
%link{:rel=>'stylesheet', :type=>'text/css', :href=>"#{root}glossary.css", :media=>'all'}
|
|
7
|
-
- if custom_css
|
|
8
|
-
%link{:rel=>'stylesheet', :type=>'text/css', :href=>"#{root}#{custom_css}", :media=>'all'}
|
|
9
|
-
%script{:type=>'text/javascript', :src=>"#{root}glossary-terms.js"}
|
|
10
|
-
%script{:type=>'text/javascript', :src=>"#{root}glossary.js"}
|
|
11
|
-
- if custom_js
|
|
12
|
-
%script{:type=>'text/javascript', :src=>"#{root}#{custom_js}"}
|
|
13
|
-
%title= page.title
|
|
14
|
-
%body{ :class=>page.style }
|
|
15
|
-
#content
|
|
16
|
-
#pagetop
|
|
17
|
-
#breadcrumb
|
|
18
|
-
= global.short_title || global.title
|
|
19
|
-
%span.sep >
|
|
20
|
-
- breadcrumb.each do |node|
|
|
21
|
-
%a{ :href=>root/node.link }= node.page.short_title || node.title
|
|
22
|
-
%span.sep >
|
|
23
|
-
= page.title
|
|
24
|
-
%h1#title= page.title
|
|
25
|
-
- if page.author
|
|
26
|
-
#author= page.author
|
|
27
|
-
#pagebody
|
|
28
|
-
#glossary-box
|
|
29
|
-
#mainbody= contents
|
|
30
|
-
#pagefooter
|
|
31
|
-
Copyright ©#{Time.now.year}#{ " #{global.company}" if global.company }.
|
|
32
|
-
All Rights Reserved.
|
|
1
|
+
!!! Strict
|
|
2
|
+
%html
|
|
3
|
+
%head
|
|
4
|
+
%meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
|
|
5
|
+
%link{:rel=>'stylesheet', :type=>'text/css', :href=>"#{root}common.css", :media=>'all'}
|
|
6
|
+
%link{:rel=>'stylesheet', :type=>'text/css', :href=>"#{root}glossary.css", :media=>'all'}
|
|
7
|
+
- if custom_css
|
|
8
|
+
%link{:rel=>'stylesheet', :type=>'text/css', :href=>"#{root}#{custom_css}", :media=>'all'}
|
|
9
|
+
%script{:type=>'text/javascript', :src=>"#{root}glossary-terms.js"}
|
|
10
|
+
%script{:type=>'text/javascript', :src=>"#{root}glossary.js"}
|
|
11
|
+
- if custom_js
|
|
12
|
+
%script{:type=>'text/javascript', :src=>"#{root}#{custom_js}"}
|
|
13
|
+
%title= page.title
|
|
14
|
+
%body{ :class=>page.style }
|
|
15
|
+
#content
|
|
16
|
+
#pagetop
|
|
17
|
+
#breadcrumb
|
|
18
|
+
= global.short_title || global.title
|
|
19
|
+
%span.sep >
|
|
20
|
+
- breadcrumb.each do |node|
|
|
21
|
+
%a{ :href=>root/node.link }= node.page.short_title || node.title
|
|
22
|
+
%span.sep >
|
|
23
|
+
= page.title
|
|
24
|
+
%h1#title= page.title
|
|
25
|
+
- if page.author
|
|
26
|
+
#author= page.author
|
|
27
|
+
#pagebody
|
|
28
|
+
#glossary-box
|
|
29
|
+
#mainbody= contents
|
|
30
|
+
#pagefooter
|
|
31
|
+
Copyright ©#{Time.now.year}#{ " #{global.company}" if global.company }.
|
|
32
|
+
All Rights Reserved.
|
|
@@ -38,7 +38,7 @@ ICON = {
|
|
|
38
38
|
%>
|
|
39
39
|
<LI> <OBJECT type="text/sitemap">
|
|
40
40
|
<param name="Name" value="<%=CGI.escapeHTML child.title%>">
|
|
41
|
-
<param name="Local" value="<%=FileUtils.win_path( @html_path / child.link ).gsub('&','
|
|
41
|
+
<param name="Local" value="<%=FileUtils.win_path( @html_path / child.link ).gsub('&','&')%>">
|
|
42
42
|
<param name="ImageNumber" value="<%=icon%>">
|
|
43
43
|
</OBJECT>
|
|
44
44
|
<%@write_section[child] unless child.children.empty?%>
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
<%@global.index.each do |entry,pages|%>
|
|
12
12
|
<LI> <OBJECT type="text/sitemap">
|
|
13
13
|
<param name="Name" value="<%=entry%>">
|
|
14
|
-
<param name="Local" value="<%=FileUtils.win_path( @html_path/pages.first.html_path )%>">
|
|
14
|
+
<param name="Local" value="<%=FileUtils.win_path( @html_path/pages.first.html_path.gsub('&','&') )%>">
|
|
15
15
|
</OBJECT>
|
|
16
16
|
<%unless pages.length==1%>
|
|
17
17
|
<UL>
|
|
18
18
|
<%pages.each do |page|%>
|
|
19
19
|
<LI> <OBJECT type="text/sitemap">
|
|
20
20
|
<param name="Name" value="<%=page.title%>">
|
|
21
|
-
<param name="Local" value="<%=FileUtils.win_path( @html_path/page.html_path )%>">
|
|
21
|
+
<param name="Local" value="<%=FileUtils.win_path( @html_path/page.html_path.gsub('&','&') )%>">
|
|
22
22
|
</OBJECT>
|
|
23
23
|
<%end%>
|
|
24
24
|
</UL>
|
data/lib/docubot/writers/html.rb
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
class DocuBot::HTMLWriter < DocuBot::Writer
|
|
2
|
-
handles_type :html
|
|
3
|
-
|
|
4
|
-
# Specify nil for destination to place "<source>_html" next to the source.
|
|
5
|
-
def write( destination=nil )
|
|
6
|
-
start = Time.now
|
|
7
|
-
|
|
8
|
-
source = @bundle.source
|
|
9
|
-
@html_path = destination || File.dirname(source)/"#{File.basename source}_html"
|
|
10
|
-
FileUtils.rm_rf(@html_path) if File.exists?(@html_path)
|
|
11
|
-
FileUtils.mkdir(@html_path)
|
|
12
|
-
|
|
13
|
-
master_templates = DocuBot::TEMPLATE_DIR
|
|
14
|
-
source_templates = source/'_templates'
|
|
15
|
-
master_root = master_templates/'_root'
|
|
16
|
-
source_root = source_templates/'_root'
|
|
17
|
-
|
|
18
|
-
# Copy any files found in the source directory that weren't made into pages
|
|
19
|
-
@bundle.extras.each do |file|
|
|
20
|
-
FileUtils.mkdir_p( @html_path / File.dirname( file ) )
|
|
21
|
-
FileUtils.cp( source / file, @html_path / file )
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Copy files from template to root of destination
|
|
25
|
-
# Record these as extras so that the CHMWriter can access them
|
|
26
|
-
Dir.chdir @html_path do
|
|
27
|
-
existing_files = Dir[ '*' ]
|
|
28
|
-
FileUtils.copy( Dir[ master_templates/'_root'/'*' ], '.' )
|
|
29
|
-
FileUtils.copy( Dir[ source_templates/'_root'/'*' ], '.' )
|
|
30
|
-
new_files = Dir[ '*' ] - existing_files
|
|
31
|
-
@bundle.extras.concat( new_files )
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
Dir.chdir @html_path do
|
|
35
|
-
o = Object.new
|
|
36
|
-
|
|
37
|
-
# Write out every page
|
|
38
|
-
top = File.exists?( source_templates/'top.haml' ) ? source_templates/'top.haml' : master_templates/'top.haml'
|
|
39
|
-
top = Haml::Engine.new( IO.read( top ), HAML_OPTIONS )
|
|
40
|
-
@bundle.toc.descendants.each do |node|
|
|
41
|
-
next if node.anchor
|
|
42
|
-
|
|
43
|
-
contents = node.page.to_html
|
|
44
|
-
template = node.page.template # Call page.to_html first to ensure page.template is set
|
|
45
|
-
|
|
46
|
-
custom_js = "#{template}.js"
|
|
47
|
-
custom_js = nil unless File.exists?( source_root/custom_js ) || File.exists?( master_root/custom_js )
|
|
48
|
-
|
|
49
|
-
custom_css = "#{template}.css"
|
|
50
|
-
custom_css = nil unless File.exists?( source_root/custom_css ) || File.exists?( master_root/custom_css )
|
|
51
|
-
|
|
52
|
-
variables = {
|
|
53
|
-
:page => node.page,
|
|
54
|
-
:contents => contents,
|
|
55
|
-
:global => @bundle.global,
|
|
56
|
-
:root => node.page.root,
|
|
57
|
-
:breadcrumb => node.ancestors,
|
|
58
|
-
:custom_js => custom_js,
|
|
59
|
-
:custom_css => custom_css
|
|
60
|
-
}
|
|
61
|
-
html = top.render( o, variables )
|
|
62
|
-
FileUtils.mkdir_p( File.dirname( node.file ) )
|
|
63
|
-
File.open( node.file, 'w' ){ |f| f << html }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
File.open( 'glossary-terms.js', 'w' ){ |f| f << @bundle.glossary.to_js }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
puts "...%.2fs to write the HTML" % (Time.now - start)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
module Haml::Helpers
|
|
74
|
-
def li_pages_for( node )
|
|
75
|
-
node.children.each do |child|
|
|
76
|
-
haml_tag :li, :class=>(child.anchor ? 'sublink' : child.children.empty? ? 'section' : 'page' ) do
|
|
77
|
-
haml_tag :a, :href=>child.link do
|
|
78
|
-
haml_concat child.title
|
|
79
|
-
end
|
|
80
|
-
unless child.children.empty?
|
|
81
|
-
haml_tag :ul do
|
|
82
|
-
li_pages_for child
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
1
|
+
class DocuBot::HTMLWriter < DocuBot::Writer
|
|
2
|
+
handles_type :html
|
|
3
|
+
|
|
4
|
+
# Specify nil for destination to place "<source>_html" next to the source.
|
|
5
|
+
def write( destination=nil )
|
|
6
|
+
start = Time.now
|
|
7
|
+
|
|
8
|
+
source = @bundle.source
|
|
9
|
+
@html_path = destination || File.dirname(source)/"#{File.basename source}_html"
|
|
10
|
+
FileUtils.rm_rf(@html_path) if File.exists?(@html_path)
|
|
11
|
+
FileUtils.mkdir(@html_path)
|
|
12
|
+
|
|
13
|
+
master_templates = DocuBot::TEMPLATE_DIR
|
|
14
|
+
source_templates = source/'_templates'
|
|
15
|
+
master_root = master_templates/'_root'
|
|
16
|
+
source_root = source_templates/'_root'
|
|
17
|
+
|
|
18
|
+
# Copy any files found in the source directory that weren't made into pages
|
|
19
|
+
@bundle.extras.each do |file|
|
|
20
|
+
FileUtils.mkdir_p( @html_path / File.dirname( file ) )
|
|
21
|
+
FileUtils.cp( source / file, @html_path / file )
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Copy files from template to root of destination
|
|
25
|
+
# Record these as extras so that the CHMWriter can access them
|
|
26
|
+
Dir.chdir @html_path do
|
|
27
|
+
existing_files = Dir[ '*' ]
|
|
28
|
+
FileUtils.copy( Dir[ master_templates/'_root'/'*' ], '.' )
|
|
29
|
+
FileUtils.copy( Dir[ source_templates/'_root'/'*' ], '.' )
|
|
30
|
+
new_files = Dir[ '*' ] - existing_files
|
|
31
|
+
@bundle.extras.concat( new_files )
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Dir.chdir @html_path do
|
|
35
|
+
o = Object.new
|
|
36
|
+
|
|
37
|
+
# Write out every page
|
|
38
|
+
top = File.exists?( source_templates/'top.haml' ) ? source_templates/'top.haml' : master_templates/'top.haml'
|
|
39
|
+
top = Haml::Engine.new( IO.read( top ), HAML_OPTIONS )
|
|
40
|
+
@bundle.toc.descendants.each do |node|
|
|
41
|
+
next if node.anchor
|
|
42
|
+
|
|
43
|
+
contents = node.page.to_html
|
|
44
|
+
template = node.page.template # Call page.to_html first to ensure page.template is set
|
|
45
|
+
|
|
46
|
+
custom_js = "#{template}.js"
|
|
47
|
+
custom_js = nil unless File.exists?( source_root/custom_js ) || File.exists?( master_root/custom_js )
|
|
48
|
+
|
|
49
|
+
custom_css = "#{template}.css"
|
|
50
|
+
custom_css = nil unless File.exists?( source_root/custom_css ) || File.exists?( master_root/custom_css )
|
|
51
|
+
|
|
52
|
+
variables = {
|
|
53
|
+
:page => node.page,
|
|
54
|
+
:contents => contents,
|
|
55
|
+
:global => @bundle.global,
|
|
56
|
+
:root => node.page.root,
|
|
57
|
+
:breadcrumb => node.ancestors,
|
|
58
|
+
:custom_js => custom_js,
|
|
59
|
+
:custom_css => custom_css
|
|
60
|
+
}
|
|
61
|
+
html = top.render( o, variables )
|
|
62
|
+
FileUtils.mkdir_p( File.dirname( node.file ) )
|
|
63
|
+
File.open( node.file, 'w' ){ |f| f << html }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
File.open( 'glossary-terms.js', 'w' ){ |f| f << @bundle.glossary.to_js }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
puts "...%.2fs to write the HTML" % (Time.now - start)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
module Haml::Helpers
|
|
74
|
+
def li_pages_for( node )
|
|
75
|
+
node.children.each do |child|
|
|
76
|
+
haml_tag :li, :class=>(child.anchor ? 'sublink' : child.children.empty? ? 'section' : 'page' ) do
|
|
77
|
+
haml_tag :a, :href=>child.link do
|
|
78
|
+
haml_concat child.title
|
|
79
|
+
end
|
|
80
|
+
unless child.children.empty?
|
|
81
|
+
haml_tag :ul do
|
|
82
|
+
li_pages_for child
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
88
|
end
|