codnar 0.1.68 → 0.1.73

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.
@@ -13,10 +13,11 @@ class String
13
13
  # empty lines for no apparent reason. Cleaning it up seems to be safe enough,
14
14
  # and eliminates the ugly additional vertical space in the final HTML.
15
15
  def clean_markup_html
16
- return gsub(/\n*<p>\n*/, "\n<p>\n") \
16
+ return gsub("\r\n", "\n") \
17
+ .gsub(/\n*<p>\n*/, "\n<p>\n") \
17
18
  .gsub(/\n*<\/p>\n*/, "\n</p>\n") \
18
- .gsub(/\n*<pre>\n*/, "\n<pre>\n") \
19
- .gsub(/\n*<\/pre>\n*/, "\n</pre>\n") \
19
+ .gsub(/\n*<pre>\n+/, "\n<pre>\n") \
20
+ .gsub(/\n+<\/pre>\n*/, "\n</pre>\n") \
20
21
  .sub(/^\n*/, "")
21
22
  end
22
23
 
@@ -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.68"
6
+ VERSION = "0.1.73"
7
7
 
8
8
  end
@@ -0,0 +1,23 @@
1
+ require "codnar"
2
+ require "test/spec"
3
+
4
+ # Test expanding Haddock text.
5
+ class TestExpandHaddock < Test::Unit::TestCase
6
+
7
+ def test_normal_text
8
+ Codnar::Haddock.to_html("normal").should == "<p>normal\n</p>\n"
9
+ end
10
+
11
+ def test_identifier_text
12
+ Codnar::Haddock.to_html("'Int'").should == "<p><code>Int</code>\n</p>\n"
13
+ end
14
+
15
+ def test_emphasis_text
16
+ Codnar::Haddock.to_html("/emphasis/").should == "<p><em>emphasis</em>\n</p>\n"
17
+ end
18
+
19
+ def test_code_text
20
+ Codnar::Haddock.to_html("@code@").should == "<pre>code</pre>\n"
21
+ end
22
+
23
+ end
data/test/expand_rdoc.rb CHANGED
@@ -9,12 +9,12 @@ class TestExpandRDoc < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_strong_text
12
- Codnar::RDoc.to_html("*text*").should == "<p>\n<b>text</b>\n</p>\n"
12
+ Codnar::RDoc.to_html("*text*").should == "<p>\n<strong>text</strong>\n</p>\n"
13
13
  end
14
14
 
15
15
  def test_indented_pre
16
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"
17
+ == "<p>\nbase\n</p>\n<pre>indented\n more</pre>\n<p>\nback\n</p>\n"
18
18
  end
19
19
 
20
20
  end
@@ -33,7 +33,7 @@ class TestFormatCommentsConfigurations < Test::Unit::TestCase
33
33
  <td class='html'>
34
34
  <div class='rdoc comment markup'>
35
35
  <p>
36
- Comment <b>text</b>.
36
+ Comment <strong>text</strong>.
37
37
  </p>
38
38
  </div>
39
39
  </td>
data/test/run_weave.rb CHANGED
@@ -54,10 +54,9 @@ class TestRunWeave < Test::Unit::TestCase
54
54
  def test_run_weave_missing_file
55
55
  write_fake_file("root", FILE_CHUNKS.to_yaml)
56
56
  Codnar::Application.with_argv(%w(-e stderr -o stdout root)) { Codnar::Weave.new(true).run }.should == 1
57
- double_message = "No such file or directory - " * 2 # Something weird in Ruby Exception.to_s
58
- File.read("stdout").should == "Root\nFILE: included.file EXCEPTION: #{double_message}\n"
57
+ File.read("stdout").should == "Root\nFILE: included.file EXCEPTION: No such file or directory - included.file\n"
59
58
  File.read("stderr").should \
60
- == "#{$0}: Reading file: included.file exception: #{double_message} in file: root at line: 1\n"
59
+ == "#{$0}: Reading file: included.file exception: No such file or directory - included.file in file: root at line: 1\n"
61
60
  end
62
61
 
63
62
  def test_run_weave_existing_file
data/test/split_code.rb CHANGED
@@ -79,7 +79,7 @@ protected
79
79
  <td class='html'>
80
80
  <div class='rdoc rdoc markup'>
81
81
  <p>
82
- This is <b>rdoc</b>.
82
+ This is <strong>rdoc</strong>.
83
83
  </p>
84
84
  </div>
85
85
  </td>
@@ -77,7 +77,7 @@ class TestSplitCombinedConfigurations < Test::Unit::TestCase
77
77
  <td class='html'>
78
78
  <div class='rdoc comment markup'>
79
79
  <p>
80
- Hello, <b>world</b>!
80
+ Hello, <strong>world</strong>!
81
81
  </p>
82
82
  </div>
83
83
  </td>
@@ -3,8 +3,8 @@ require "olag/test"
3
3
  require "test/spec"
4
4
  require "test_with_configurations"
5
5
 
6
- # Test built-in split complex comment configurations.
7
- class TestSplitComplexCommentsConfigurations < Test::Unit::TestCase
6
+ # Test built-in split delimited comment configurations.
7
+ class TestSplitDelimitedCommentsConfigurations < Test::Unit::TestCase
8
8
 
9
9
  include Test::WithConfigurations
10
10
  include Test::WithErrors
@@ -13,7 +13,7 @@ class TestSplitComplexCommentsConfigurations < Test::Unit::TestCase
13
13
  def test_custom_comments
14
14
  # Since the prefix/inner/suffix passed to the configuration are regexps,
15
15
  # we need to escape special characters such as "{" and "|".
16
- check_any_comment([ "@{", " |", " }@" ], Codnar::Configuration::CLASSIFY_COMPLEX_COMMENTS.call("@\\{", " \\|", " \\}@"))
16
+ check_any_comment([ "@{", " |", " }@" ], Codnar::Configuration::CLASSIFY_DELIMITED_COMMENTS.call("@\\{", " \\|", " \\}@"))
17
17
  end
18
18
 
19
19
  def test_c_comments
@@ -26,16 +26,16 @@ class TestSplitComplexCommentsConfigurations < Test::Unit::TestCase
26
26
 
27
27
  protected
28
28
 
29
- # The "<<<" will be replaced by the complex comment prefix,
29
+ # The "<<<" will be replaced by the start comment prefix,
30
30
  # the "<>" will be replaced by the inner line comment prefix,
31
- # and the ">>>" will be replaced by the complex comment suffix.
31
+ # and the ">>>" will be replaced by the end comment suffix.
32
32
  ANY_COMMENT_CODE = <<-EOF.unindent
33
- /-- One-line comment --/
33
+ <<< One-line comment >>>
34
34
  Code
35
- /--
36
- - Multi-line
37
- - comment.
38
- --/
35
+ <<<
36
+ <> Multi-line
37
+ <> comment.
38
+ >>>
39
39
  EOF
40
40
 
41
41
  ANY_COMMENT_HTML = <<-EOF.unindent.chomp # ((( html
@@ -56,7 +56,7 @@ protected
56
56
 
57
57
  def check_any_comment(patterns, configuration)
58
58
  prefix, inner, suffix = patterns
59
- check_split_file(ANY_COMMENT_CODE.gsub("/--", prefix).gsub("--/", suffix).gsub(" -", inner),
59
+ check_split_file(ANY_COMMENT_CODE.gsub("<<<", prefix).gsub(">>>", suffix).gsub("<>", inner),
60
60
  Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("any"),
61
61
  Codnar::Configuration::FORMAT_PRE_COMMENTS,
62
62
  configuration) do |path|
@@ -0,0 +1,62 @@
1
+ require "codnar"
2
+ require "olag/test"
3
+ require "test/spec"
4
+ require "test_with_configurations"
5
+
6
+ # Test built-in split denoted comment configurations.
7
+ class TestSplitDenotedCommentsConfigurations < Test::Unit::TestCase
8
+
9
+ include Test::WithConfigurations
10
+ include Test::WithErrors
11
+ include Test::WithTempfile
12
+
13
+ def test_custom_comments
14
+ check_any_comment("// @", "//", Codnar::Configuration::CLASSIFY_DENOTED_COMMENTS.call("// @", "//"))
15
+ end
16
+
17
+ def test_haddoc_comments
18
+ check_any_comment("-- |", "--", Codnar::Configuration::CLASSIFY_HADDOCK_COMMENTS.call)
19
+ end
20
+
21
+ protected
22
+
23
+ # The "<<<" will be replaced by the start comment prefix,
24
+ # and the ">>>" will be replaced by the continue comment prefix.
25
+ ANY_COMMENT_CODE = <<-EOF.unindent
26
+ >>> Not start comment
27
+ <<< Start comment
28
+ >>> Continue comment
29
+ Not a comment
30
+ EOF
31
+
32
+ # The ">>>" will be replaced by the continue comment prefix.
33
+ ANY_COMMENT_HTML = <<-EOF.unindent.chomp # ((( html
34
+ <pre class='code'>
35
+ >>> Not start comment
36
+ </pre>
37
+ <pre class='comment'>
38
+ Start comment
39
+ Continue comment
40
+ </pre>
41
+ <pre class='code'>
42
+ Not a comment
43
+ </pre>
44
+ EOF
45
+ # )))
46
+
47
+ def check_any_comment(start_prefix, continue_prefix, configuration)
48
+ check_split_file(ANY_COMMENT_CODE.gsub("<<<", start_prefix).gsub(">>>", continue_prefix),
49
+ Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("any"),
50
+ Codnar::Configuration::FORMAT_PRE_COMMENTS,
51
+ configuration) do |path|
52
+ [ {
53
+ "name" => path,
54
+ "locations" => [ { "file" => path, "line" => 1 } ],
55
+ "containers" => [],
56
+ "contained" => [],
57
+ "html" => ANY_COMMENT_HTML.gsub(">>>", continue_prefix),
58
+ } ]
59
+ end
60
+ end
61
+
62
+ end
@@ -46,7 +46,7 @@ class TestSplitDocumentation < Test::Unit::TestCase
46
46
  "containers" => [],
47
47
  "contained" => [],
48
48
  "locations" => [ { "file" => "rdoc.rdoc", "line" => 1 } ],
49
- "html" => "<div class='rdoc rdoc markup'>\n<p>\n<b>foo</b> bar\n</p>\n</div>"
49
+ "html" => "<div class='rdoc rdoc markup'>\n<p>\n<strong>foo</strong> bar\n</p>\n</div>"
50
50
  } ]
51
51
  end
52
52
 
@@ -54,7 +54,7 @@ class TestSplitDocumentationConfigurations < Test::Unit::TestCase
54
54
  RDOC_HTML = <<-EOF.unindent.chomp #! ((( html
55
55
  <div class='rdoc doc markup'>
56
56
  <p>
57
- This is a <b>marked-up</b> file.
57
+ This is a <strong>marked-up</strong> file.
58
58
  </p>
59
59
  </div>
60
60
  EOF
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: 147
4
+ hash: 137
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 68
10
- version: 0.1.68
9
+ - 73
10
+ version: 0.1.73
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-23 00:00:00 Z
18
+ date: 2012-03-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: andand
@@ -228,6 +228,10 @@ files:
228
228
  - lib/codnar/application.rb
229
229
  - lib/codnar/cache.rb
230
230
  - lib/codnar/coderay.rb
231
+ - lib/codnar/configuration/code.rb
232
+ - lib/codnar/configuration/comments.rb
233
+ - lib/codnar/configuration/documentation.rb
234
+ - lib/codnar/configuration/highlighting.rb
231
235
  - lib/codnar/data/coderay.css
232
236
  - lib/codnar/data/contents.js
233
237
  - lib/codnar/data/control_chunks.js
@@ -246,6 +250,7 @@ files:
246
250
  - lib/codnar/graphviz.rb
247
251
  - lib/codnar/grouper.rb
248
252
  - lib/codnar/gvim.rb
253
+ - lib/codnar/haddock.rb
249
254
  - lib/codnar/hash_extensions.rb
250
255
  - lib/codnar/markdown.rb
251
256
  - lib/codnar/merger.rb
@@ -277,6 +282,7 @@ files:
277
282
  - test/coderay_highlight_syntax.rb
278
283
  - test/deep_merge.rb
279
284
  - test/embed_images.rb
285
+ - test/expand_haddock.rb
280
286
  - test/expand_markdown.rb
281
287
  - test/expand_rdoc.rb
282
288
  - test/format_code_configurations.rb
@@ -298,7 +304,8 @@ files:
298
304
  - test/split_code.rb
299
305
  - test/split_code_configurations.rb
300
306
  - test/split_combined_configurations.rb
301
- - test/split_complex_comment_configurations.rb
307
+ - test/split_delimited_comment_configurations.rb
308
+ - test/split_denoted_comment_configurations.rb
302
309
  - test/split_documentation.rb
303
310
  - test/split_documentation_configurations.rb
304
311
  - test/split_simple_comment_configurations.rb
@@ -316,7 +323,7 @@ licenses: []
316
323
  post_install_message:
317
324
  rdoc_options:
318
325
  - --title
319
- - Code Narrator 0.1.68
326
+ - Code Narrator 0.1.73
320
327
  - --main
321
328
  - README.rdoc
322
329
  - --line-numbers
@@ -354,6 +361,7 @@ test_files:
354
361
  - test/coderay_highlight_syntax.rb
355
362
  - test/deep_merge.rb
356
363
  - test/embed_images.rb
364
+ - test/expand_haddock.rb
357
365
  - test/expand_markdown.rb
358
366
  - test/expand_rdoc.rb
359
367
  - test/format_code_configurations.rb
@@ -375,7 +383,8 @@ test_files:
375
383
  - test/split_code.rb
376
384
  - test/split_code_configurations.rb
377
385
  - test/split_combined_configurations.rb
378
- - test/split_complex_comment_configurations.rb
386
+ - test/split_delimited_comment_configurations.rb
387
+ - test/split_denoted_comment_configurations.rb
379
388
  - test/split_documentation.rb
380
389
  - test/split_documentation_configurations.rb
381
390
  - test/split_simple_comment_configurations.rb