codnar 0.1.67 → 0.1.68

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.
@@ -3,6 +3,6 @@ module Codnar
3
3
 
4
4
  # This version number. The third number is automatically updated to track the
5
5
  # number of Git commits by running <tt>rake version</tt>.
6
- VERSION = "0.1.67"
6
+ VERSION = "0.1.68"
7
7
 
8
8
  end
@@ -0,0 +1,25 @@
1
+ require "codnar"
2
+ require "test/spec"
3
+
4
+ # Test highlighting syntax using CodeRay.
5
+ class TestCodeRayHighlightSyntax < Test::Unit::TestCase
6
+
7
+ def test_coderay_lines
8
+ Codnar::CodeRay.lines_to_html([
9
+ { "kind" => "ruby_code", "number" => 1, "indentation" => "", "payload" => "def foo" },
10
+ { "kind" => "ruby_code", "number" => 2, "indentation" => " ", "payload" => "return 1" },
11
+ { "kind" => "ruby_code", "number" => 3, "indentation" => "", "payload" => "end" },
12
+ ], "ruby").should == [
13
+ { "kind" => "html", "number" => 1,
14
+ "payload" => <<-EOF.unindent.chomp
15
+ <div class="CodeRay">
16
+ <div class="code"><pre><span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">foo</span>
17
+ <span style="color:#080;font-weight:bold">return</span> <span style="color:#00D">1</span>
18
+ <span style="color:#080;font-weight:bold">end</span></pre></div>
19
+ </div>
20
+ EOF
21
+ },
22
+ ]
23
+ end
24
+
25
+ end
@@ -5,23 +5,23 @@ require "test/spec"
5
5
  class TestExpandMarkdown < Test::Unit::TestCase
6
6
 
7
7
  def test_emphasis_text
8
- Markdown.to_html("*text*").should == "<p>\n<em>text</em>\n</p>\n"
8
+ Codnar::Markdown.to_html("*text*").should == "<p>\n<em>text</em>\n</p>\n"
9
9
  end
10
10
 
11
11
  def test_strong_text
12
- Markdown.to_html("**text**").should == "<p>\n<strong>text</strong>\n</p>\n"
12
+ Codnar::Markdown.to_html("**text**").should == "<p>\n<strong>text</strong>\n</p>\n"
13
13
  end
14
14
 
15
15
  def test_embed_chunk
16
- Markdown.to_html("[[Chunk|template]]").should == "<p>\n<embed src='chunk' type='x-codnar/template'/>\n</p>\n"
16
+ Codnar::Markdown.to_html("[[Chunk|template]]").should == "<p>\n<embed src='chunk' type='x-codnar/template'/>\n</p>\n"
17
17
  end
18
18
 
19
19
  def test_embed_anchor
20
- Markdown.to_html("[[#Name]]").should == "<p>\n<a id='name'/>\n</p>\n"
20
+ Codnar::Markdown.to_html("[[#Name]]").should == "<p>\n<a id='name'/>\n</p>\n"
21
21
  end
22
22
 
23
23
  def test_embed_link
24
- Markdown.to_html("[Label](#Name)").should == "<p>\n<a href=\"#name\">Label</a>\n</p>\n"
24
+ Codnar::Markdown.to_html("[Label](#Name)").should == "<p>\n<a href=\"#name\">Label</a>\n</p>\n"
25
25
  end
26
26
 
27
27
  end
data/test/expand_rdoc.rb CHANGED
@@ -5,16 +5,16 @@ require "test/spec"
5
5
  class TestExpandRDoc < Test::Unit::TestCase
6
6
 
7
7
  def test_emphasis_text
8
- RDoc.to_html("_text_").should == "<p>\n<em>text</em>\n</p>\n"
8
+ Codnar::RDoc.to_html("_text_").should == "<p>\n<em>text</em>\n</p>\n"
9
9
  end
10
10
 
11
11
  def test_strong_text
12
- RDoc.to_html("*text*").should == "<p>\n<b>text</b>\n</p>\n"
12
+ Codnar::RDoc.to_html("*text*").should == "<p>\n<b>text</b>\n</p>\n"
13
13
  end
14
14
 
15
15
  def test_indented_pre
16
- RDoc.to_html("base\n indented\n more\nback\n").should \
17
- == "<p>\nbase\n</p>\n<pre>\nindented\n more\n</pre>\n<p>\nback\n</p>\n"
16
+ Codnar::RDoc.to_html("base\n indented\n more\nback\n").should \
17
+ == "<p>\nbase\n</p>\n<pre>\nindented\n more\n</pre>\n<p>\nback\n</p>\n"
18
18
  end
19
19
 
20
20
  end
@@ -0,0 +1,71 @@
1
+ require "codnar"
2
+ require "olag/test"
3
+ require "test/spec"
4
+ require "test_with_configurations"
5
+
6
+ # Test built-in split code formatting configurations.
7
+ class TestFormatCodeConfigurations < Test::Unit::TestCase
8
+
9
+ include Test::WithConfigurations
10
+ include Test::WithErrors
11
+ include Test::WithTempfile
12
+
13
+ def test_gvim_html_code
14
+ check_any_code(<<-EOF.unindent.chomp, Codnar::Configuration::FORMAT_CODE_GVIM_HTML.call("c"))
15
+ <div class='c code syntax' bgcolor=\"#ffffff\" text=\"#000000\">
16
+ <font face=\"monospace\">
17
+ <font color=\"#00ff00\">int</font>&nbsp;x;<br />
18
+ </font>
19
+ </div>
20
+ EOF
21
+ end
22
+
23
+ def test_gvim_css_code
24
+ check_any_code(<<-EOF.unindent.chomp, Codnar::Configuration::FORMAT_CODE_GVIM_CSS.call("c"))
25
+ <pre class='c code syntax'>
26
+ <span class=\"Type\">int</span> x;
27
+ </pre>
28
+ EOF
29
+ end
30
+
31
+ def test_coderay_html_code
32
+ check_any_code(<<-EOF.unindent.chomp, Codnar::Configuration::FORMAT_CODE_CODERAY_HTML.call("c"))
33
+ <div class="CodeRay">
34
+ <div class="code"><pre><span style="color:#0a5;font-weight:bold">int</span> x;</pre></div>
35
+ </div>
36
+ EOF
37
+ end
38
+
39
+ def test_coderay_css_code
40
+ check_any_code(<<-EOF.unindent.chomp, Codnar::Configuration::FORMAT_CODE_CODERAY_CSS.call("c"))
41
+ <div class="CodeRay">
42
+ <div class="code"><pre><span class="predefined-type">int</span> x;</pre></div>
43
+ </div>
44
+ EOF
45
+ end
46
+
47
+ def test_sunlight_code
48
+ check_any_code(<<-EOF.unindent.chomp, Codnar::Configuration::FORMAT_CODE_SUNLIGHT.call("c"))
49
+ <pre class='sunlight-highlight-c'>
50
+ int x;
51
+ </pre>
52
+ EOF
53
+ end
54
+
55
+ protected
56
+
57
+ def check_any_code(html, configuration)
58
+ check_split_file("int x;\n",
59
+ Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("c"),
60
+ configuration) do |path|
61
+ [ {
62
+ "name" => path,
63
+ "locations" => [ { "file" => path, "line" => 1 } ],
64
+ "containers" => [],
65
+ "contained" => [],
66
+ "html" => html,
67
+ } ]
68
+ end
69
+ end
70
+
71
+ end
data/test/split_code.rb CHANGED
@@ -38,7 +38,7 @@ protected
38
38
  "code" => "Formatter.cast_lines(lines, 'ruby')",
39
39
  "comment" => "Formatter.cast_lines(lines, 'rdoc')",
40
40
  "ruby" => "GVim.lines_to_html(lines, 'ruby')",
41
- "rdoc" => "Formatter.markup_lines_to_html(lines, 'RDoc')",
41
+ "rdoc" => "Formatter.markup_lines_to_html(lines, Codnar::RDoc, 'rdoc')",
42
42
  "begin_chunk" => "[]",
43
43
  "end_chunk" => "[]",
44
44
  "nested_chunk" => "Formatter.nested_chunk_lines_to_html(lines)",
@@ -71,7 +71,7 @@ protected
71
71
  "formatters" => {
72
72
  "markdown" => "Formatter.markup_lines_to_html(lines, Markdown, 'markdown')",
73
73
  "unindented_html" => "Formatter.unindented_lines_to_html(lines)",
74
- "rdoc" => "Formatter.markup_lines_to_html(lines, 'RDoc')",
74
+ "rdoc" => "Formatter.markup_lines_to_html(lines, Codnar::RDoc, 'rdoc')",
75
75
  },
76
76
  "syntax" => {
77
77
  "start_state" => kind,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codnar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 157
4
+ hash: 147
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 67
10
- version: 0.1.67
9
+ - 68
10
+ version: 0.1.68
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oren Ben-Kiki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-13 00:00:00 Z
18
+ date: 2011-09-23 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: andand
@@ -32,7 +32,7 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: rdiscount
35
+ name: coderay
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: olag
49
+ name: rdiscount
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
@@ -60,7 +60,7 @@ dependencies:
60
60
  type: :runtime
61
61
  version_requirements: *id003
62
62
  - !ruby/object:Gem::Dependency
63
- name: Saikuro
63
+ name: olag
64
64
  prerelease: false
65
65
  requirement: &id004 !ruby/object:Gem::Requirement
66
66
  none: false
@@ -71,10 +71,10 @@ dependencies:
71
71
  segments:
72
72
  - 0
73
73
  version: "0"
74
- type: :development
74
+ type: :runtime
75
75
  version_requirements: *id004
76
76
  - !ruby/object:Gem::Dependency
77
- name: codnar
77
+ name: Saikuro
78
78
  prerelease: false
79
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
80
  none: false
@@ -88,7 +88,7 @@ dependencies:
88
88
  type: :development
89
89
  version_requirements: *id005
90
90
  - !ruby/object:Gem::Dependency
91
- name: fakefs
91
+ name: codnar
92
92
  prerelease: false
93
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
@@ -102,7 +102,7 @@ dependencies:
102
102
  type: :development
103
103
  version_requirements: *id006
104
104
  - !ruby/object:Gem::Dependency
105
- name: flay
105
+ name: fakefs
106
106
  prerelease: false
107
107
  requirement: &id007 !ruby/object:Gem::Requirement
108
108
  none: false
@@ -116,7 +116,7 @@ dependencies:
116
116
  type: :development
117
117
  version_requirements: *id007
118
118
  - !ruby/object:Gem::Dependency
119
- name: rake
119
+ name: flay
120
120
  prerelease: false
121
121
  requirement: &id008 !ruby/object:Gem::Requirement
122
122
  none: false
@@ -130,7 +130,7 @@ dependencies:
130
130
  type: :development
131
131
  version_requirements: *id008
132
132
  - !ruby/object:Gem::Dependency
133
- name: rcov
133
+ name: rake
134
134
  prerelease: false
135
135
  requirement: &id009 !ruby/object:Gem::Requirement
136
136
  none: false
@@ -144,7 +144,7 @@ dependencies:
144
144
  type: :development
145
145
  version_requirements: *id009
146
146
  - !ruby/object:Gem::Dependency
147
- name: rdoc
147
+ name: rcov
148
148
  prerelease: false
149
149
  requirement: &id010 !ruby/object:Gem::Requirement
150
150
  none: false
@@ -158,7 +158,7 @@ dependencies:
158
158
  type: :development
159
159
  version_requirements: *id010
160
160
  - !ruby/object:Gem::Dependency
161
- name: reek
161
+ name: rdoc
162
162
  prerelease: false
163
163
  requirement: &id011 !ruby/object:Gem::Requirement
164
164
  none: false
@@ -172,7 +172,7 @@ dependencies:
172
172
  type: :development
173
173
  version_requirements: *id011
174
174
  - !ruby/object:Gem::Dependency
175
- name: roodi
175
+ name: reek
176
176
  prerelease: false
177
177
  requirement: &id012 !ruby/object:Gem::Requirement
178
178
  none: false
@@ -186,7 +186,7 @@ dependencies:
186
186
  type: :development
187
187
  version_requirements: *id012
188
188
  - !ruby/object:Gem::Dependency
189
- name: test-spec
189
+ name: roodi
190
190
  prerelease: false
191
191
  requirement: &id013 !ruby/object:Gem::Requirement
192
192
  none: false
@@ -199,6 +199,20 @@ dependencies:
199
199
  version: "0"
200
200
  type: :development
201
201
  version_requirements: *id013
202
+ - !ruby/object:Gem::Dependency
203
+ name: test-spec
204
+ prerelease: false
205
+ requirement: &id014 !ruby/object:Gem::Requirement
206
+ none: false
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ hash: 3
211
+ segments:
212
+ - 0
213
+ version: "0"
214
+ type: :development
215
+ version_requirements: *id014
202
216
  description: Code Narrator (Codnar) is an inverse literate programming tool. It splits the source files into "chunks" (including structured comments) and weaves them back into a narrative that describes the overall system.
203
217
  email: rubygems-oren@ben-kiki.org
204
218
  executables:
@@ -213,8 +227,11 @@ extra_rdoc_files:
213
227
  files:
214
228
  - lib/codnar/application.rb
215
229
  - lib/codnar/cache.rb
230
+ - lib/codnar/coderay.rb
231
+ - lib/codnar/data/coderay.css
216
232
  - lib/codnar/data/contents.js
217
233
  - lib/codnar/data/control_chunks.js
234
+ - lib/codnar/data/gvim.css
218
235
  - lib/codnar/data/style.css
219
236
  - lib/codnar/data/sunlight/css-min.js
220
237
  - lib/codnar/data/sunlight/default.css
@@ -257,12 +274,12 @@ files:
257
274
  - Rakefile
258
275
  - codnar.html
259
276
  - test/cache_computations.rb
277
+ - test/coderay_highlight_syntax.rb
260
278
  - test/deep_merge.rb
261
279
  - test/embed_images.rb
262
280
  - test/expand_markdown.rb
263
281
  - test/expand_rdoc.rb
264
- - test/format_code_gvim_configurations.rb
265
- - test/format_code_sunlight_configurations.rb
282
+ - test/format_code_configurations.rb
266
283
  - test/format_comment_configurations.rb
267
284
  - test/format_lines.rb
268
285
  - test/graphviz_diagrams.rb
@@ -299,7 +316,7 @@ licenses: []
299
316
  post_install_message:
300
317
  rdoc_options:
301
318
  - --title
302
- - Code Narrator 0.1.67
319
+ - Code Narrator 0.1.68
303
320
  - --main
304
321
  - README.rdoc
305
322
  - --line-numbers
@@ -334,12 +351,12 @@ specification_version: 3
334
351
  summary: Code narrator - an inverse literate programming tool.
335
352
  test_files:
336
353
  - test/cache_computations.rb
354
+ - test/coderay_highlight_syntax.rb
337
355
  - test/deep_merge.rb
338
356
  - test/embed_images.rb
339
357
  - test/expand_markdown.rb
340
358
  - test/expand_rdoc.rb
341
- - test/format_code_gvim_configurations.rb
342
- - test/format_code_sunlight_configurations.rb
359
+ - test/format_code_configurations.rb
343
360
  - test/format_comment_configurations.rb
344
361
  - test/format_lines.rb
345
362
  - test/graphviz_diagrams.rb
@@ -1,55 +0,0 @@
1
- require "codnar"
2
- require "olag/test"
3
- require "test/spec"
4
- require "test_with_configurations"
5
-
6
- # Test built-in split code formatting configurations using GVim.
7
- class TestGVimFormatCodeConfigurations < Test::Unit::TestCase
8
-
9
- include Test::WithConfigurations
10
- include Test::WithErrors
11
- include Test::WithTempfile
12
-
13
- CODE_TEXT = <<-EOF.unindent
14
- int x;
15
- EOF
16
-
17
- GVIM_HTML = <<-EOF.unindent.chomp
18
- <div class='c code syntax' bgcolor=\"#ffffff\" text=\"#000000\">
19
- <font face=\"monospace\">
20
- <font color=\"#00ff00\">int</font>&nbsp;x;<br />
21
- </font>
22
- </div>
23
- EOF
24
-
25
- def test_html_code
26
- check_any_code(GVIM_HTML, Codnar::Configuration::FORMAT_CODE_GVIM_HTML.call("c"))
27
- end
28
-
29
- GVIM_CSS = <<-EOF.unindent.chomp
30
- <pre class='c code syntax'>
31
- <span class=\"Type\">int</span> x;
32
- </pre>
33
- EOF
34
-
35
- def test_css_code
36
- check_any_code(GVIM_CSS, Codnar::Configuration::FORMAT_CODE_GVIM_CSS.call("c"))
37
- end
38
-
39
- protected
40
-
41
- def check_any_code(html, configuration)
42
- check_split_file(CODE_TEXT,
43
- Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("c"),
44
- configuration) do |path|
45
- [ {
46
- "name" => path,
47
- "locations" => [ { "file" => path, "line" => 1 } ],
48
- "containers" => [],
49
- "contained" => [],
50
- "html" => html,
51
- } ]
52
- end
53
- end
54
-
55
- end
@@ -1,37 +0,0 @@
1
- require "codnar"
2
- require "olag/test"
3
- require "test/spec"
4
- require "test_with_configurations"
5
-
6
- # Test built-in split code formatting configurations using Sunlight.
7
- class TestSunlightFormatCodeConfigurations < Test::Unit::TestCase
8
-
9
- include Test::WithConfigurations
10
- include Test::WithErrors
11
- include Test::WithTempfile
12
-
13
- CODE_TEXT = <<-EOF.unindent
14
- local = $global;
15
- EOF
16
-
17
- SUNLIGHT_HTML = <<-EOF.unindent.chomp
18
- <pre class='sunlight-highlight-ruby'>
19
- local = $global;
20
- </pre>
21
- EOF
22
-
23
- def test_sunlight_code
24
- check_split_file(CODE_TEXT,
25
- Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("ruby"),
26
- Codnar::Configuration::FORMAT_CODE_SUNLIGHT.call("ruby")) do |path|
27
- [ {
28
- "name" => path,
29
- "locations" => [ { "file" => path, "line" => 1 } ],
30
- "containers" => [],
31
- "contained" => [],
32
- "html" => SUNLIGHT_HTML,
33
- } ]
34
- end
35
- end
36
-
37
- end