docubot 0.3 → 0.3.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.
Files changed (89) hide show
  1. data/bin/docubot +0 -0
  2. data/lib/docubot/bundle.rb +75 -11
  3. data/lib/docubot/glossary.rb +19 -14
  4. data/lib/docubot/page.rb +114 -56
  5. data/lib/docubot/shells/nvphysx/0_License.md +3 -0
  6. data/lib/docubot/shells/nvphysx/1_Getting_Started.haml +51 -0
  7. data/lib/docubot/shells/nvphysx/Appendix/Glossary.md +7 -0
  8. data/lib/docubot/shells/nvphysx/_glossary/APEX.md +1 -0
  9. data/lib/docubot/shells/nvphysx/_glossary/NVIDIA.md +1 -0
  10. data/lib/docubot/shells/nvphysx/_glossary/PhysX.textile +3 -0
  11. data/lib/docubot/shells/nvphysx/_static/NVBadge_3D.png +0 -0
  12. data/lib/docubot/shells/nvphysx/_static/PhysXbyNV_Black.png +0 -0
  13. data/lib/docubot/shells/nvphysx/_templates/_root/bg_green_bar_revised.gif +0 -0
  14. data/lib/docubot/shells/nvphysx/_templates/_root/close.png +0 -0
  15. data/lib/docubot/shells/nvphysx/_templates/_root/common.css +264 -0
  16. data/lib/docubot/shells/nvphysx/_templates/_root/glossary.css +4 -0
  17. data/lib/docubot/shells/nvphysx/_templates/_root/glossary.js +24 -0
  18. data/lib/docubot/shells/nvphysx/_templates/_root/nvdevtools.js +31 -0
  19. data/lib/docubot/shells/nvphysx/_templates/_root/nvidia-logo.gif +0 -0
  20. data/lib/docubot/shells/nvphysx/_templates/_root/right-sidebar.png +0 -0
  21. data/lib/docubot/shells/nvphysx/_templates/top.haml +28 -0
  22. data/lib/docubot/shells/nvphysx/index.txt +5 -0
  23. data/lib/docubot/snippet.rb +1 -0
  24. data/lib/docubot/snippets/glossary.rb +1 -0
  25. data/lib/docubot/templates/_root/glossary.css +4 -0
  26. data/lib/docubot/templates/_root/glossary.js +58 -0
  27. data/lib/docubot/templates/glossary.haml +3 -2
  28. data/lib/docubot/templates/top.haml +4 -0
  29. data/lib/docubot/writers/chm.rb +6 -3
  30. data/lib/docubot/writers/html.rb +1 -1
  31. data/spec/_all.rb +12 -0
  32. data/spec/_helper.rb +6 -0
  33. data/spec/bundle.rb +142 -0
  34. data/spec/command.rb +3 -0
  35. data/spec/converters.rb +2 -0
  36. data/spec/glossary.rb +93 -0
  37. data/spec/index.rb +2 -0
  38. data/spec/page.rb +24 -0
  39. data/spec/samples/glossary/Glossary.txt +5 -0
  40. data/spec/samples/glossary/Some Page.md +3 -0
  41. data/spec/samples/glossary/_glossary/Simple Term.md +3 -0
  42. data/spec/samples/glossary/_glossary/complex.haml +8 -0
  43. data/spec/samples/glossary/_glossary/project_x.md +4 -0
  44. data/spec/samples/link_test/index.txt +11 -0
  45. data/spec/samples/link_test/root.md +14 -0
  46. data/spec/samples/link_test/sub1/inner1.md +11 -0
  47. data/spec/samples/link_test/sub2.md +3 -0
  48. data/{test/site1_html/toc.css → spec/samples/link_test/sub2/bozo.bin} +0 -0
  49. data/spec/samples/link_test/sub2/inner2.md +7 -0
  50. data/spec/samples/simplest/HTML.html +10 -0
  51. data/spec/samples/simplest/Haml.haml +13 -0
  52. data/spec/samples/simplest/Markdown.md +10 -0
  53. data/spec/samples/simplest/Text.txt +10 -0
  54. data/spec/samples/simplest/Textile.textile +10 -0
  55. data/test/site1_html/toc.js b/data/spec/samples/titletest/1 First → One.txt +0 -0
  56. data/spec/samples/titletest/2_Second_One.txt +0 -0
  57. data/spec/samples/titletest/3_renamed.txt +2 -0
  58. data/spec/samples/titletest/4 Fourth_One.txt b/data/spec/samples/titletest/4 → Fourth_One.txt +0 -0
  59. data/spec/samples/titletest/5_Fifth One.txt b/data/spec/samples/titletest/5_Fifth → One.txt +0 -0
  60. data/spec/samples/titletest/index.txt +2 -0
  61. data/spec/templates.rb +2 -0
  62. data/spec/toc.rb +73 -0
  63. data/spec/writer/chm.rb +2 -0
  64. data/spec/writer/html.rb +2 -0
  65. metadata +74 -35
  66. data/test/all.rb +0 -8
  67. data/test/site1/A Slight Change of Heart/1 Ze First Page in Ze Section.md +0 -1
  68. data/test/site1/A Slight Change of Heart/2 Another Page in the Section.md +0 -1
  69. data/test/site1/A Slight Change of Heart/3_more_crap.haml +0 -17
  70. data/test/site1/appendices/gkheadftw.html +0 -2
  71. data/test/site1/appendices/index.md +0 -2
  72. data/test/site1/headers.md +0 -10
  73. data/test/site1/preamble.haml +0 -4
  74. data/test/site1/raw.textile +0 -10
  75. data/test/site1_html/A Slight Change of Heart/1 Ze First Page in Ze Section.html +0 -30
  76. data/test/site1_html/A Slight Change of Heart/2 Another Page in the Section.html +0 -30
  77. data/test/site1_html/A Slight Change of Heart/3_more_crap.html +0 -42
  78. data/test/site1_html/A Slight Change of Heart/3_more_crap.html#frist-post +0 -29
  79. data/test/site1_html/A Slight Change of Heart/3_more_crap.html#moar +0 -29
  80. data/test/site1_html/A Slight Change of Heart/index.html +0 -28
  81. data/test/site1_html/_index.html +0 -17
  82. data/test/site1_html/_toc.html +0 -73
  83. data/test/site1_html/appendices/gkheadftw.html +0 -32
  84. data/test/site1_html/appendices/index.html +0 -28
  85. data/test/site1_html/common.css +0 -108
  86. data/test/site1_html/glossary-terms.js +0 -1
  87. data/test/site1_html/headers.html +0 -42
  88. data/test/site1_html/preamble.html +0 -36
  89. data/test/site1_html/raw.html +0 -33
@@ -0,0 +1,7 @@
1
+ template: glossary
2
+ +++
3
+ This page uses the glossary template, which has the smarts to generate HTML
4
+ from the glossary terms defined in the `_glossary` directory.
5
+
6
+ The Glossary template doesn't actually use the `contents` of this page, so
7
+ it doesn't matter what I put here.
@@ -0,0 +1 @@
1
+ A multi-platform, scalable dynamics framework.
@@ -0,0 +1 @@
1
+ NVIDIA (Nasdaq: NVDA) is the world leader in visual computing technologies and the inventor of the GPU, a high-performance processor which generates breathtaking, interactive graphics on workstations, personal computers, game consoles, and mobile devices.
@@ -0,0 +1,3 @@
1
+ note: Due to a bug in the Markdown converter with unicode characters, textile must be used for pages with unicode.
2
+ +++
3
+ NVIDIA® PhysX® is a powerful physics engine enabling real-time physics in leading edge PC games. PhysX software is widely adopted by over 150 games and is used by more than 10,000 developers. PhysX is optimized for hardware acceleration by massively parallel processors. GeForce GPUs with PhysX provide an exponential increase in physics processing power taking gaming physics to the next level.
@@ -0,0 +1,264 @@
1
+ html, body
2
+ {
3
+ margin:0;
4
+ padding:0;
5
+ font-family: Verdana, Arial, Helvetica, sans-serif;
6
+ font-size: 1.1em;
7
+ font-style: normal;
8
+ font-weight: normal;
9
+ color: black;
10
+ }
11
+ body{
12
+ background:white url(right-sidebar.png) repeat-y top right;
13
+ }
14
+
15
+ body.nosidebar{
16
+ background-image:none;
17
+ }
18
+
19
+ #breadcrumb
20
+ {
21
+ margin:0;
22
+ background:black url(nvidia-logo.gif) no-repeat left center;
23
+ padding-left:56px;
24
+ font-family: 'Arial', sans-serif;
25
+ font-size:14px; font-weight:bold;
26
+ white-space:nowrap;
27
+ height:40px; line-height:40px; color:white; overflow:hidden;
28
+ color:#fff;
29
+ }
30
+
31
+ #breadcrumb a
32
+ {
33
+ color:#fff; text-decoration:none
34
+ }
35
+
36
+ #breadcrumb a:hover
37
+ {
38
+ color:#74b71b
39
+ }
40
+ #breadcrumb .sep
41
+ {
42
+ color:#999; font-weight:normal; padding:0 0.2em
43
+ }
44
+
45
+ div#mainbody
46
+ {
47
+ font-size:90%;
48
+ margin: 0 350px 0 10px;
49
+ padding: 0;
50
+ }
51
+
52
+ body.nosidebar div#mainbody
53
+ {
54
+ margin-right:0px;
55
+ }
56
+
57
+ div#mainbody
58
+ {
59
+ padding-bottom:2em;
60
+ }
61
+
62
+ div.section
63
+ {
64
+ margin-left:2em
65
+ }
66
+
67
+ a:link, a:visited { white-space:nowrap; color:#6e8e34 }
68
+ a:hover { color:#74b71b }
69
+
70
+ a.hsglossaryreference {
71
+ color:#000; cursor:help; border-color:#666 ! important
72
+ }
73
+ a.hsglossaryreference:hover { border-color:#74b71b ! important }
74
+
75
+ ul { margin-left:2em; clear:left }
76
+
77
+ strong { white-space:nowrap }
78
+
79
+ h1 {
80
+ margin:0;
81
+ padding-left:14px;
82
+ padding-right:50px;
83
+ font-family: 'Arial', sans-serif;
84
+ white-space:nowrap;
85
+ font-size:18px;
86
+ background:#6eb103 url(bg_green_bar_revised.gif) repeat-x;
87
+ height:30px; line-height:30px; color:white; overflow:hidden;
88
+ border-bottom:1px solid #999
89
+ }
90
+
91
+ h2
92
+ {
93
+ clear:both;
94
+ margin-top:4em;
95
+ }
96
+ h2, h3, h4
97
+ {
98
+ border-bottom:1px solid #dddddd;
99
+ font-size:100%;
100
+ margin-bottom:0.5em;
101
+ }
102
+ h2.first-child, h3.first-child, h4.first-child
103
+ {
104
+ margin-top:0
105
+ }
106
+ h3, h4
107
+ {
108
+ margin-top:2em;
109
+ color:#666;
110
+ }
111
+
112
+ p, li, fieldset, dl
113
+ {
114
+ margin:0;
115
+ padding:0;
116
+ padding-right:1em;
117
+ margin-bottom:1em
118
+ }
119
+
120
+ .TODO
121
+ {
122
+ font-family: courier new;
123
+ color: #ff80ff;
124
+ font-size: 9pt;
125
+ font-weight: bold
126
+ }
127
+
128
+ .sidebar
129
+ {
130
+ text-align: center;
131
+ width: 350px;
132
+ font-family: tahoma,sans-serif;
133
+ float: right;
134
+ clear: right;
135
+ color: #665555;
136
+ margin:0;
137
+ padding:0;
138
+ margin-right: -350px;
139
+ margin-left: 1em;
140
+ font-size: 7pt;
141
+ font-weight: bold;
142
+ }
143
+ .sidebar img
144
+ {
145
+ display:block;
146
+ margin:0 auto;
147
+ margin-bottom:0.5em;
148
+ }
149
+
150
+ img.floatcap
151
+ {
152
+ float:left;
153
+ margin-right:1em;
154
+ margin-bottom:1em;
155
+ margin-top:2px;
156
+ }
157
+
158
+ .moreinfo
159
+ {
160
+ font-style:italic;
161
+ color:#666;
162
+ }
163
+
164
+ .moreinfo a
165
+ {
166
+ color: #6e8e34
167
+ }
168
+ .moreinfo a:hover
169
+ {
170
+ color: #76b900
171
+ }
172
+
173
+ p.aside
174
+ {
175
+ margin-left:4em
176
+ }
177
+
178
+ div#nonscrollingpagefooter
179
+ {
180
+ background:white;
181
+ margin-bottom:0;
182
+ margin-top:4em;
183
+ clear:both;
184
+ }
185
+
186
+ div.tryit
187
+ {
188
+ border:1px solid #76b900;
189
+ background:#eef6df;
190
+ margin:2em 50px;
191
+ padding:0;
192
+ }
193
+ div.tryit h3
194
+ {
195
+ background:#76b900;
196
+ color:white;
197
+ font-style:normal;
198
+ padding:2px 0.5em;
199
+ margin:0;
200
+ margin-bottom:1em
201
+ }
202
+ div.tryit img.preview
203
+ {
204
+ float:right;
205
+ width:180px;
206
+ margin:-1em 0 1em 1em;
207
+ }
208
+ div.tryit ol
209
+ {
210
+ margin:1em;
211
+ padding:0;
212
+ }
213
+ div.tryit li
214
+ {
215
+ margin:0;
216
+ margin-left:3em;
217
+ margin-bottom:1em
218
+ }
219
+ div.tryit .results
220
+ {
221
+ font-style:italic;
222
+ color:#666
223
+ }
224
+
225
+ sup
226
+ {
227
+ font-size:85%
228
+ }
229
+
230
+ #known-issues h3 { font-style:normal; margin-bottom:0.2em; margin-top:3em; margin-right:1em }
231
+ #known-issues h3 span.issue_num { margin-left:1.5em; font-weight:normal; font-size:85%; color:#666; line-height:1.2em; float:right; margin-top:-1.2em; margin-right:1em }
232
+ #known-issues div.description { margin-bottom:2em }
233
+ #known-issues p.workaround { margin-left:2em }
234
+ #known-issues p.workaround strong { color:#666 }
235
+
236
+ #pagebody
237
+ {
238
+ font-size: 70%;
239
+ margin-bottom: 0;
240
+ margin-top: 1em;
241
+ }
242
+
243
+ #pagebody h1 {
244
+ background:#666; color:#ccc; border:1px solid #333; font-size:100%; padding:0.2em 1em; line-height:1em ! important;
245
+ height:auto ! important; margin-top:1.5em
246
+ }
247
+
248
+ fieldset { margin-bottom:1.5em; margin-left:1em; padding:0.5em; border-right:none; }
249
+ legend { font-weight:bold; color:#666 }
250
+ fieldset dl { margin:0 2em }
251
+ fieldset p { margin:1em 2em }
252
+ dl.section { margin-left:2em }
253
+ dt { font-weight:bold; font-style:normal; margin-top:0.8em }
254
+ dd { margin-bottom:0.8em }
255
+
256
+ div#pagefooter {
257
+ margin-top:10em ! important; margin-bottom:1em ! important; width:25em; overflow:hidden; white-space:nowrap;
258
+ background:#eee; border:1px solid #ccc; border-left:none; color:#999; font-size:7pt ! important; padding:0.1em 1em
259
+ }
260
+
261
+ ul.compact li { margin-bottom:0 }
262
+ body.release-notes h3 { margin-left:2em }
263
+ body.release-notes ul { margin-left:4em; margin-top:0; }
264
+ body.release-notes li { margin-bottom:0; margin-top:0; padding:0 ! important; margin-left:1em; line-height:105%; }
@@ -0,0 +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-close { width:24px; height:24px; background:url(close.png) no-repeat; position:absolute; right:-12px; top:-12px; cursor:pointer; }
3
+ #glossary-box * { margin:0 }
4
+ span.glossary { color:#36401C; border-bottom:1px dashed #6e8e34; cursor:help; }
@@ -0,0 +1,24 @@
1
+ function glossaryClick(evt){
2
+ if (!evt) evt=event;
3
+ var target = evt.target || evt.srcElement;
4
+ var term = target.getAttribute('term') || target.innerHTML;
5
+ var box = document.getElementById('glossary-box');
6
+ box.style.display = 'block';
7
+ var scroll = (document.documentElement.scrollTop || document.body.scrollTop )*1;
8
+ box.style.left = (evt.clientX+5) + 'px';
9
+ box.style.top = (evt.clientY+5) + scroll + 'px';
10
+
11
+ var html = $glossaryTerms[term.toLowerCase()];
12
+ document.getElementById('glossary-defn').innerHTML = html;
13
+ }
14
+
15
+ handleEvent(window,'load',function(){
16
+ for ( var spans=document.getElementsByTagName('span'),i=spans.length-1; i>=0; --i ){
17
+ if (cssClass.has(spans[i],'glossary')) handleEvent(spans[i],'click',glossaryClick);
18
+ }
19
+ var box = document.getElementById('glossary-box');
20
+ var close = document.getElementById('glossary-close');
21
+ handleEvent( close, 'click', function(){
22
+ box.style.display = 'none';
23
+ });
24
+ });
@@ -0,0 +1,31 @@
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
+ function isFirstChild(node){
22
+ return node.parentNode.firstChild==node;
23
+ }
24
+ handleEvent(window,'load',function(){
25
+ // Add first-child CSS class since :first-child pseudo-class doesn't work for old IE
26
+ for ( var tags=['h2','h3','p','ul','dl','ol'],i=tags.length-1; i>=0; --i ){
27
+ for ( var all=document.getElementsByTagName(tags[i]),j=all.length-1; j>=0; --j ){
28
+ if (isFirstChild(all[j])) cssClass.add(all[j],'first-child');
29
+ }
30
+ }
31
+ });
@@ -0,0 +1,28 @@
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
+ %script{:type=>'text/javascript', :src=>"#{root}nvdevtools.js"}
8
+ %script{:type=>'text/javascript', :src=>"#{root}glossary-terms.js"}
9
+ %script{:type=>'text/javascript', :src=>"#{root}glossary.js"}
10
+ %title= page.title
11
+ %body{ :class=>page.style }
12
+ #pagetop
13
+ #breadcrumb
14
+ - toc = page.ancestors.first # The TOC has no page to link to
15
+ = toc.short_title || toc.title
16
+ %span.sep >
17
+ - page.ancestors[1..-1].each do |dad|
18
+ %a{ :href=>root/dad.html_path }= dad.short_title || dad.title
19
+ %span.sep >
20
+ = page.title
21
+ %h1#title= page.title
22
+ #pagebody
23
+ #glossary-box
24
+ #glossary-close
25
+ #glossary-defn
26
+ #mainbody= contents
27
+ #pagefooter
28
+ Copyright ©#{Time.now.year}#{ " #{global.company}" if global.company? }.
@@ -0,0 +1,5 @@
1
+ company : NVIDIA Corporation
2
+ title : NVIDIA Reference Manual
3
+ short_title: NVIDIA Reference
4
+ default : Getting Started
5
+ +++
@@ -7,6 +7,7 @@ module DocuBot
7
7
  end
8
8
 
9
9
  def self.process_snippets( page, html )
10
+ # TODO: Don't process snippets on the 'raw' file types
10
11
  @snippets.inject(html){ |h,(regexp,handler)| h.gsub( regexp ){ |str| handler[ str, page ] } }
11
12
  end
12
13
 
@@ -3,5 +3,6 @@ pattern = /\$\$(\w[\w: ]*\w)\$\$/
3
3
  DocuBot.handle_snippet pattern do |match, page|
4
4
  parts = match[ 2..-3 ].split(':',2)
5
5
  text, term = parts.first, parts.last
6
+ page.bundle.glossary.term_used( term, page )
6
7
  "<span class='glossary' term='#{term}'>#{text}</span>"
7
8
  end
@@ -0,0 +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; }
4
+ span.glossary-missing { border-bottom:1px dotted #c00 }
@@ -0,0 +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
+ });
58
+ });