bitclust-core 1.0.0 → 1.1.0

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/data/bitclust/template.lillia/class +4 -1
  3. data/data/bitclust/template.lillia/class-index +4 -1
  4. data/data/bitclust/template.lillia/doc +4 -1
  5. data/data/bitclust/template.lillia/layout +2 -0
  6. data/data/bitclust/template.lillia/library +4 -1
  7. data/data/bitclust/template.lillia/library-index +4 -1
  8. data/data/bitclust/template.lillia/method +2 -1
  9. data/data/bitclust/template.offline/class +4 -1
  10. data/data/bitclust/template.offline/class-index +4 -1
  11. data/data/bitclust/template.offline/doc +4 -1
  12. data/data/bitclust/template.offline/function +1 -0
  13. data/data/bitclust/template.offline/function-index +4 -1
  14. data/data/bitclust/template.offline/layout +3 -0
  15. data/data/bitclust/template.offline/library +4 -1
  16. data/data/bitclust/template.offline/library-index +4 -1
  17. data/data/bitclust/template.offline/method +1 -0
  18. data/data/bitclust/template/class +4 -1
  19. data/data/bitclust/template/class-index +4 -1
  20. data/data/bitclust/template/doc +4 -1
  21. data/data/bitclust/template/function +4 -1
  22. data/data/bitclust/template/layout +3 -0
  23. data/data/bitclust/template/library +4 -1
  24. data/data/bitclust/template/library-index +4 -1
  25. data/data/bitclust/template/method +1 -0
  26. data/lib/bitclust/classentry.rb +4 -0
  27. data/lib/bitclust/docentry.rb +4 -1
  28. data/lib/bitclust/functionentry.rb +3 -1
  29. data/lib/bitclust/libraryentry.rb +5 -3
  30. data/lib/bitclust/methodentry.rb +3 -1
  31. data/lib/bitclust/preprocessor.rb +74 -14
  32. data/lib/bitclust/rdcompiler.rb +35 -15
  33. data/lib/bitclust/screen.rb +12 -1
  34. data/lib/bitclust/subcommands/preproc_command.rb +1 -1
  35. data/lib/bitclust/subcommands/statichtml_command.rb +12 -1
  36. data/lib/bitclust/syntax_highlighter.rb +318 -0
  37. data/lib/bitclust/version.rb +1 -1
  38. data/test/test_preprocessor.rb +209 -1
  39. data/test/test_rdcompiler.rb +79 -0
  40. data/theme/default/style.css +12 -0
  41. data/theme/default/syntax-highlight.css +209 -0
  42. metadata +5 -3
@@ -1,3 +1,3 @@
1
1
  module BitClust
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -80,5 +80,213 @@ HERE
80
80
  ret = Preprocessor.wrap(StringIO.new(src), params).to_a
81
81
  assert_equal(expected, ret.join)
82
82
  end
83
- end
84
83
 
84
+ def test_complex_condition
85
+ params = { 'version' => '2.4.0' }
86
+ src = <<HERE
87
+ \#@until 1.9.2
88
+ before 1.9.2
89
+ \#@until 1.8.6
90
+ before 1.8.6
91
+ \#@end
92
+ \#@until 1.9.1
93
+ before 1.9.1
94
+ \#@end
95
+ \#@until 1.9.1
96
+ before 1.9.1
97
+ \#@end
98
+ \#@since 1.9.1
99
+ after 1.9.1
100
+ \#@end
101
+ \#@else
102
+ Display here!
103
+ \#@end
104
+ HERE
105
+ expected = <<HERE
106
+ Display here!
107
+ HERE
108
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
109
+ assert_equal(expected, ret.join)
110
+ end
111
+
112
+ def test_samplecode
113
+ params = { 'version' => '1.9.2' }
114
+ src = <<HERE
115
+ --- puts(str) -> String
116
+
117
+ xxx
118
+
119
+ \#@samplecode description
120
+ puts("xxx")
121
+ puts("yyy")
122
+ \#@end
123
+ HERE
124
+
125
+ expected = <<HERE
126
+ --- puts(str) -> String
127
+
128
+ xxx
129
+
130
+ //emlist[description][ruby]{
131
+ puts("xxx")
132
+ puts("yyy")
133
+ //}
134
+ HERE
135
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
136
+ assert_equal(expected, ret.join)
137
+ end
138
+
139
+ def test_samplecode_without_description
140
+ params = { 'version' => '1.9.2' }
141
+ src = <<HERE
142
+ --- puts(str) -> String
143
+
144
+ xxx
145
+
146
+ \#@samplecode
147
+ puts("xxx")
148
+ puts("yyy")
149
+ \#@end
150
+ HERE
151
+
152
+ expected = <<HERE
153
+ --- puts(str) -> String
154
+
155
+ xxx
156
+
157
+ //emlist[][ruby]{
158
+ puts("xxx")
159
+ puts("yyy")
160
+ //}
161
+ HERE
162
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
163
+ assert_equal(expected, ret.join)
164
+ end
165
+
166
+ def test_samplecode_with_condition1
167
+ params = { 'version' => '1.9.2' }
168
+ src = <<HERE
169
+ --- puts(str) -> String
170
+
171
+ xxx
172
+
173
+ \#@since 1.9.2
174
+ \#@samplecode description1
175
+ puts("xxx1")
176
+ puts("yyy1")
177
+ \#@end
178
+ \#@else
179
+ \#@samplecode description2
180
+ puts("xxx2")
181
+ puts("yyy2")
182
+ \#@end
183
+ \#@end
184
+ HERE
185
+
186
+ expected = <<HERE
187
+ --- puts(str) -> String
188
+
189
+ xxx
190
+
191
+ //emlist[description1][ruby]{
192
+ puts("xxx1")
193
+ puts("yyy1")
194
+ //}
195
+ HERE
196
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
197
+ assert_equal(expected, ret.join)
198
+ end
199
+
200
+ def test_samplecode_with_condition2
201
+ params = { 'version' => '1.9.2' }
202
+ src = <<HERE
203
+ --- puts(str) -> String
204
+
205
+ xxx
206
+
207
+ \#@samplecode description
208
+ \#@since 1.9.2
209
+ puts("xxx")
210
+ \#@else
211
+ puts("yyy")
212
+ \#@end
213
+ \#@end
214
+ HERE
215
+
216
+ expected = <<HERE
217
+ --- puts(str) -> String
218
+
219
+ xxx
220
+
221
+ //emlist[description][ruby]{
222
+ puts("xxx")
223
+ //}
224
+ HERE
225
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
226
+ assert_equal(expected, ret.join)
227
+ end
228
+
229
+ def test_samplecode_with_condition3
230
+ params = { 'version' => '1.9.2' }
231
+ src = <<HERE
232
+ --- puts(str) -> String
233
+
234
+ xxx
235
+
236
+ \#@since 1.9.1
237
+ \#@samplecode description
238
+ \#@since 1.9.2
239
+ puts("xxx")
240
+ \#@else
241
+ puts("yyy")
242
+ \#@end
243
+ \#@end
244
+ \#@else
245
+ zzz
246
+ \#@end
247
+ HERE
248
+
249
+ expected = <<HERE
250
+ --- puts(str) -> String
251
+
252
+ xxx
253
+
254
+ //emlist[description][ruby]{
255
+ puts("xxx")
256
+ //}
257
+ HERE
258
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
259
+ assert_equal(expected, ret.join)
260
+ end
261
+
262
+ def test_samplecode_with_condition4
263
+ params = { 'version' => '1.9.2' }
264
+ src = <<HERE
265
+ --- puts(str) -> String
266
+
267
+ xxx
268
+
269
+ \#@samplecode description
270
+ puts("xxx")
271
+ puts("yyy")
272
+ \#@since 1.9.2
273
+ puts("zzz")
274
+ \#@end
275
+ \#@end
276
+ HERE
277
+
278
+ expected = <<HERE
279
+ --- puts(str) -> String
280
+
281
+ xxx
282
+
283
+ //emlist[description][ruby]{
284
+ puts("xxx")
285
+ puts("yyy")
286
+ puts("zzz")
287
+ //}
288
+ HERE
289
+ ret = Preprocessor.wrap(StringIO.new(src), params).to_a
290
+ assert_equal(expected, ret.join)
291
+ end
292
+ end
@@ -341,6 +341,85 @@ HERE
341
341
  assert_compiled_method_source(expected, src)
342
342
  end
343
343
 
344
+ def test_method_with_param_and_emlist_with_caption_and_lang
345
+ src = <<'HERE'
346
+ --- method
347
+
348
+ @param arg dsc1
349
+ //emlist[This is caption][ruby]{
350
+ dsc2
351
+ dsc3
352
+ //}
353
+ HERE
354
+ expected = <<'HERE'
355
+ <dt class="method-heading" id="dummy"><code>method</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
356
+ <dd class="method-description">
357
+ <dl>
358
+ <dt class='method-param'>[PARAM] arg:</dt>
359
+ <dd>
360
+ dsc1
361
+ <pre class="highlight ruby">
362
+ <span class="caption">This is caption</span>
363
+ <code>
364
+ dsc2
365
+ dsc3
366
+ </code></pre>
367
+ </dd>
368
+ </dl>
369
+ </dd>
370
+ HERE
371
+ assert_compiled_method_source(expected, src)
372
+ end
373
+
374
+ def test_method_with_samplecode
375
+ src = <<'HERE'
376
+ --- <=>
377
+
378
+ abs
379
+ //emlist[description][ruby]{
380
+ puts "text"
381
+ //}
382
+ HERE
383
+ expected = <<'HERE'
384
+ <dt class="method-heading" id="dummy"><code>self &lt;=&gt; </code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
385
+ <dd class="method-description">
386
+ <p>
387
+ abs
388
+ </p>
389
+ <pre class="highlight ruby">
390
+ <span class="caption">description</span>
391
+ <code>
392
+ <span class="nb">puts</span> <span class="s2">"</span><span class="s2">text</span><span class="s2">"</span>
393
+ </code></pre>
394
+ </dd>
395
+ HERE
396
+ assert_compiled_method_source(expected, src)
397
+ end
398
+
399
+ def test_method_with_samplecode_no_caption
400
+ src = <<'HERE'
401
+ --- <=>
402
+
403
+ abs
404
+ //emlist[][ruby]{
405
+ puts "text"
406
+ //}
407
+ HERE
408
+ expected = <<'HERE'
409
+ <dt class="method-heading" id="dummy"><code>self &lt;=&gt; </code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
410
+ <dd class="method-description">
411
+ <p>
412
+ abs
413
+ </p>
414
+ <pre class="highlight ruby">
415
+ <code>
416
+ <span class="nb">puts</span> <span class="s2">"</span><span class="s2">text</span><span class="s2">"</span>
417
+ </code></pre>
418
+ </dd>
419
+ HERE
420
+ assert_compiled_method_source(expected, src)
421
+ end
422
+
344
423
  def test_method2
345
424
  @c = BitClust::RDCompiler.new(@u, 1, {:database => @db, :force => true})
346
425
  src = <<'HERE'
@@ -118,6 +118,16 @@ pre {
118
118
  background-color: #eee;
119
119
  padding: 10px;
120
120
  font-weight: normal;
121
+ position: relative;
122
+ }
123
+
124
+ pre .caption {
125
+ position: absolute;
126
+ top: 0;
127
+ left: 0;
128
+ padding: 0.2em;
129
+ background: #ddd;
130
+ border-width: 0 1px 1px 0;
121
131
  }
122
132
 
123
133
  blockquote {
@@ -176,6 +186,7 @@ td {
176
186
 
177
187
  table.entries {
178
188
  width: 100%;
189
+ height: 100%;
179
190
  }
180
191
 
181
192
  table.entries tr {
@@ -196,6 +207,7 @@ td.signature {
196
207
  td.signature a {
197
208
  display: block;
198
209
  padding: 0.3em;
210
+ height: 100%;
199
211
  }
200
212
 
201
213
  td.description {
@@ -0,0 +1,209 @@
1
+ .highlight table td { padding: 5px; }
2
+ .highlight table pre { margin: 0; }
3
+ .highlight .cm {
4
+ color: #999988;
5
+ font-style: italic;
6
+ }
7
+ .highlight .cp {
8
+ color: #999999;
9
+ font-weight: bold;
10
+ }
11
+ .highlight .c1 {
12
+ color: #999988;
13
+ font-style: italic;
14
+ }
15
+ .highlight .cs {
16
+ color: #999999;
17
+ font-weight: bold;
18
+ font-style: italic;
19
+ }
20
+ .highlight .c, .highlight .cd {
21
+ color: #999988;
22
+ font-style: italic;
23
+ }
24
+ .highlight .err {
25
+ color: #a61717;
26
+ background-color: #e3d2d2;
27
+ }
28
+ .highlight .gd {
29
+ color: #000000;
30
+ background-color: #ffdddd;
31
+ }
32
+ .highlight .ge {
33
+ color: #000000;
34
+ font-style: italic;
35
+ }
36
+ .highlight .gr {
37
+ color: #aa0000;
38
+ }
39
+ .highlight .gh {
40
+ color: #999999;
41
+ }
42
+ .highlight .gi {
43
+ color: #000000;
44
+ background-color: #ddffdd;
45
+ }
46
+ .highlight .go {
47
+ color: #888888;
48
+ }
49
+ .highlight .gp {
50
+ color: #555555;
51
+ }
52
+ .highlight .gs {
53
+ font-weight: bold;
54
+ }
55
+ .highlight .gu {
56
+ color: #aaaaaa;
57
+ }
58
+ .highlight .gt {
59
+ color: #aa0000;
60
+ }
61
+ .highlight .kc {
62
+ color: #000000;
63
+ font-weight: bold;
64
+ }
65
+ .highlight .kd {
66
+ color: #000000;
67
+ font-weight: bold;
68
+ }
69
+ .highlight .kn {
70
+ color: #000000;
71
+ font-weight: bold;
72
+ }
73
+ .highlight .kp {
74
+ color: #000000;
75
+ font-weight: bold;
76
+ }
77
+ .highlight .kr {
78
+ color: #000000;
79
+ font-weight: bold;
80
+ }
81
+ .highlight .kt {
82
+ color: #445588;
83
+ font-weight: bold;
84
+ }
85
+ .highlight .k, .highlight .kv {
86
+ color: #000000;
87
+ font-weight: bold;
88
+ }
89
+ .highlight .mf {
90
+ color: #009999;
91
+ }
92
+ .highlight .mh {
93
+ color: #009999;
94
+ }
95
+ .highlight .il {
96
+ color: #009999;
97
+ }
98
+ .highlight .mi {
99
+ color: #009999;
100
+ }
101
+ .highlight .mo {
102
+ color: #009999;
103
+ }
104
+ .highlight .m, .highlight .mb, .highlight .mx {
105
+ color: #009999;
106
+ }
107
+ .highlight .sb {
108
+ color: #d14;
109
+ }
110
+ .highlight .sc {
111
+ color: #d14;
112
+ }
113
+ .highlight .sd {
114
+ color: #d14;
115
+ }
116
+ .highlight .s2 {
117
+ color: #d14;
118
+ }
119
+ .highlight .se {
120
+ color: #d14;
121
+ }
122
+ .highlight .sh {
123
+ color: #d14;
124
+ }
125
+ .highlight .si {
126
+ color: #d14;
127
+ }
128
+ .highlight .sx {
129
+ color: #d14;
130
+ }
131
+ .highlight .sr {
132
+ color: #009926;
133
+ }
134
+ .highlight .s1 {
135
+ color: #d14;
136
+ }
137
+ .highlight .ss {
138
+ color: #990073;
139
+ }
140
+ .highlight .s {
141
+ color: #d14;
142
+ }
143
+ .highlight .na {
144
+ color: #008080;
145
+ }
146
+ .highlight .bp {
147
+ color: #999999;
148
+ }
149
+ .highlight .nb {
150
+ color: #0086B3;
151
+ }
152
+ .highlight .nc {
153
+ color: #445588;
154
+ font-weight: bold;
155
+ }
156
+ .highlight .no {
157
+ color: #008080;
158
+ }
159
+ .highlight .nd {
160
+ color: #3c5d5d;
161
+ font-weight: bold;
162
+ }
163
+ .highlight .ni {
164
+ color: #800080;
165
+ }
166
+ .highlight .ne {
167
+ color: #990000;
168
+ font-weight: bold;
169
+ }
170
+ .highlight .nf {
171
+ color: #990000;
172
+ font-weight: bold;
173
+ }
174
+ .highlight .nl {
175
+ color: #990000;
176
+ font-weight: bold;
177
+ }
178
+ .highlight .nn {
179
+ color: #555555;
180
+ }
181
+ .highlight .nt {
182
+ color: #000080;
183
+ }
184
+ .highlight .vc {
185
+ color: #008080;
186
+ }
187
+ .highlight .vg {
188
+ color: #008080;
189
+ }
190
+ .highlight .vi {
191
+ color: #008080;
192
+ }
193
+ .highlight .nv {
194
+ color: #008080;
195
+ }
196
+ .highlight .ow {
197
+ color: #000000;
198
+ font-weight: bold;
199
+ }
200
+ .highlight .o {
201
+ color: #000000;
202
+ font-weight: bold;
203
+ }
204
+ .highlight .w {
205
+ color: #bbbbbb;
206
+ }
207
+ .highlight {
208
+ background-color: #f8f8f8;
209
+ }