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.
- data/ChangeLog +17 -0
- data/codnar.html +1368 -527
- data/doc/system.markdown +56 -15
- data/lib/codnar.rb +6 -0
- data/lib/codnar/configuration/code.rb +87 -0
- data/lib/codnar/configuration/comments.rb +234 -0
- data/lib/codnar/configuration/documentation.rb +65 -0
- data/lib/codnar/configuration/highlighting.rb +107 -0
- data/lib/codnar/data/contents.js +2 -1
- data/lib/codnar/haddock.rb +72 -0
- data/lib/codnar/rake/split_task.rb +6 -0
- data/lib/codnar/scanner.rb +34 -11
- data/lib/codnar/split_configurations.rb +4 -382
- data/lib/codnar/string_extensions.rb +4 -3
- data/lib/codnar/version.rb +1 -1
- data/test/expand_haddock.rb +23 -0
- data/test/expand_rdoc.rb +2 -2
- data/test/format_comment_configurations.rb +1 -1
- data/test/run_weave.rb +2 -3
- data/test/split_code.rb +1 -1
- data/test/split_combined_configurations.rb +1 -1
- data/test/{split_complex_comment_configurations.rb → split_delimited_comment_configurations.rb} +11 -11
- data/test/split_denoted_comment_configurations.rb +62 -0
- data/test/split_documentation.rb +1 -1
- data/test/split_documentation_configurations.rb +1 -1
- metadata +16 -7
@@ -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(
|
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
|
19
|
-
.gsub(/\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
|
|
data/lib/codnar/version.rb
CHANGED
@@ -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<
|
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
|
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
|
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
|
-
|
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:
|
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
data/test/{split_complex_comment_configurations.rb → split_delimited_comment_configurations.rb}
RENAMED
@@ -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
|
7
|
-
class
|
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::
|
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
|
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
|
31
|
+
# and the ">>>" will be replaced by the end comment suffix.
|
32
32
|
ANY_COMMENT_CODE = <<-EOF.unindent
|
33
|
-
|
33
|
+
<<< One-line comment >>>
|
34
34
|
Code
|
35
|
-
|
36
|
-
|
37
|
-
|
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("
|
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
|
data/test/split_documentation.rb
CHANGED
@@ -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<
|
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 <
|
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:
|
4
|
+
hash: 137
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
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:
|
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/
|
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.
|
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/
|
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
|