codnar 0.1.76 → 0.1.77
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1 -0
- data/codnar.html +99 -28
- data/lib/codnar.rb +1 -1
- data/lib/codnar/configuration/comments.rb +14 -8
- data/lib/codnar/gvim.rb +3 -2
- data/lib/codnar/haddock.rb +16 -1
- data/lib/codnar/version.rb +1 -1
- data/test/split_delimited_comment_configurations.rb +6 -2
- metadata +5 -5
data/ChangeLog
CHANGED
data/codnar.html
CHANGED
@@ -683,7 +683,7 @@ number of Git commits by running <code>rake version</code>.
|
|
683
683
|
</tr>
|
684
684
|
</table>
|
685
685
|
<pre class='ruby code syntax'>
|
686
|
-
<span class="Type">VERSION</span> = <span class="Special">"</span><span class="Constant">0.1.
|
686
|
+
<span class="Type">VERSION</span> = <span class="Special">"</span><span class="Constant">0.1.77</span><span class="Special">"</span>
|
687
687
|
|
688
688
|
end
|
689
689
|
</pre>
|
@@ -3377,6 +3377,27 @@ Convert Haddoc to HTML.
|
|
3377
3377
|
<pre class='ruby code syntax'>
|
3378
3378
|
<span class="PreProc">class</span> <span class="Type">Haddock</span>
|
3379
3379
|
|
3380
|
+
</pre>
|
3381
|
+
<table class='layout'>
|
3382
|
+
<tr>
|
3383
|
+
<td class='indentation'>
|
3384
|
+
<pre> </pre>
|
3385
|
+
</td>
|
3386
|
+
<td class='html'>
|
3387
|
+
<div class='rdoc comment markup'>
|
3388
|
+
<p>
|
3389
|
+
The cache used for speeding up recomputing the same syntax highlighting
|
3390
|
+
HTML.
|
3391
|
+
</p>
|
3392
|
+
</div>
|
3393
|
+
</td>
|
3394
|
+
</tr>
|
3395
|
+
</table>
|
3396
|
+
<pre class='ruby code syntax'>
|
3397
|
+
<span class="Identifier">@cache</span> = <span class="Type">Cache</span>.new(<span class="Special">"</span><span class="Constant">.codnar-cache</span><span class="Special">"</span>) <span class="Statement">do</span> |<span class="Identifier">data</span>|
|
3398
|
+
<span class="Type">Haddock</span>.uncached_to_html(data.haddock)
|
3399
|
+
<span class="Statement">end</span>
|
3400
|
+
|
3380
3401
|
</pre>
|
3381
3402
|
<table class='layout'>
|
3382
3403
|
<tr>
|
@@ -3393,7 +3414,7 @@ Process a Haddock String and return the resulting HTML.
|
|
3393
3414
|
</tr>
|
3394
3415
|
</table>
|
3395
3416
|
<pre class='ruby code syntax'>
|
3396
|
-
<span class="PreProc">def</span> <span class="Constant">self</span>.<span class="Identifier">
|
3417
|
+
<span class="PreProc">def</span> <span class="Constant">self</span>.<span class="Identifier">uncached_to_html</span>(haddock)
|
3397
3418
|
with_temporary_directory <span class="Statement">do</span> |<span class="Identifier">path</span>|
|
3398
3419
|
write_temporary_file(path, haddock)
|
3399
3420
|
run_haddock(path)
|
@@ -3402,6 +3423,30 @@ Process a Haddock String and return the resulting HTML.
|
|
3402
3423
|
<span class="Statement">end</span>
|
3403
3424
|
<span class="PreProc">end</span>
|
3404
3425
|
|
3426
|
+
</pre>
|
3427
|
+
<table class='layout'>
|
3428
|
+
<tr>
|
3429
|
+
<td class='indentation'>
|
3430
|
+
<pre> </pre>
|
3431
|
+
</td>
|
3432
|
+
<td class='html'>
|
3433
|
+
<div class='rdoc comment markup'>
|
3434
|
+
<p>
|
3435
|
+
Since Haddock is as slow as molasses to start up, we cache the results of
|
3436
|
+
highlighting the syntax of each code fragment in a directory called
|
3437
|
+
<code>.codnar-cache</code>, which can appear at the current working
|
3438
|
+
directory or in any of its parents.
|
3439
|
+
</p>
|
3440
|
+
</div>
|
3441
|
+
</td>
|
3442
|
+
</tr>
|
3443
|
+
</table>
|
3444
|
+
<pre class='ruby code syntax'>
|
3445
|
+
<span class="PreProc">def</span> <span class="Constant">self</span>.<span class="Identifier">to_html</span>(haddock)
|
3446
|
+
data = { <span class="Special">"</span><span class="Constant">haddock</span><span class="Special">"</span> => haddock }
|
3447
|
+
<span class="Statement">return</span> <span class="Identifier">@cache</span>[data]
|
3448
|
+
<span class="PreProc">end</span>
|
3449
|
+
|
3405
3450
|
<span class="Statement">protected</span>
|
3406
3451
|
|
3407
3452
|
</pre>
|
@@ -4055,7 +4100,7 @@ HTML.
|
|
4055
4100
|
</tr>
|
4056
4101
|
</table>
|
4057
4102
|
<pre class='ruby code syntax'>
|
4058
|
-
<span class="Identifier">@cache</span> = <span class="Type">Cache</span>.new(<span class="Special">"</span><span class="Constant">.
|
4103
|
+
<span class="Identifier">@cache</span> = <span class="Type">Cache</span>.new(<span class="Special">"</span><span class="Constant">.codnar-cache</span><span class="Special">"</span>) <span class="Statement">do</span> |<span class="Identifier">data</span>|
|
4059
4104
|
<span class="Type">GVim</span>.uncached_syntax_to_html(data.text, data.syntax, data.commands)
|
4060
4105
|
<span class="Statement">end</span>
|
4061
4106
|
|
@@ -4115,8 +4160,8 @@ environment so there is no theoretical limit to what can be done here.
|
|
4115
4160
|
<p>
|
4116
4161
|
Since GVim is as slow as molasses to start up, we cache the results of
|
4117
4162
|
highlighting the syntax of each code fragment in a directory called
|
4118
|
-
<code>.
|
4119
|
-
or in any of its parents.
|
4163
|
+
<code>.codnar-cache</code>, which can appear at the current working
|
4164
|
+
directory or in any of its parents.
|
4120
4165
|
</p>
|
4121
4166
|
</div>
|
4122
4167
|
</td>
|
@@ -4203,6 +4248,7 @@ only command-line arguments.
|
|
4203
4248
|
<span class="Identifier">ENV</span>[<span class="Special">"</span><span class="Constant">DISPLAY</span><span class="Special">"</span>] = <span class="Special">"</span><span class="Constant">none</span><span class="Special">"</span> <span class="Comment"># Otherwise the X11 server *does* affect the result.</span>
|
4204
4249
|
command = [
|
4205
4250
|
<span class="Special">"</span><span class="Constant">gvim</span><span class="Special">"</span>,
|
4251
|
+
<span class="Special">"</span><span class="Constant">-s</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant">/dev/null</span><span class="Special">"</span>, <span class="Comment"># Magic: avoids a sleep of 2 seconds in VIM startup!</span>
|
4206
4252
|
<span class="Special">"</span><span class="Constant">-f</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant">-X</span><span class="Special">"</span>,
|
4207
4253
|
<span class="Special">"</span><span class="Constant">-u</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant">none</span><span class="Special">"</span>,
|
4208
4254
|
<span class="Special">"</span><span class="Constant">-U</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant">none</span><span class="Special">"</span>,
|
@@ -6352,7 +6398,7 @@ comments).
|
|
6352
6398
|
<span class="Statement">return</span> {
|
6353
6399
|
<span class="Special">"</span><span class="Constant">syntax</span><span class="Special">"</span> => {
|
6354
6400
|
<span class="Special">"</span><span class="Constant">patterns</span><span class="Special">"</span> => {
|
6355
|
-
<span class="Special">"</span><span class="Constant">comment_</span><span class="Special">#{</span>prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special"
|
6401
|
+
<span class="Special">"</span><span class="Constant">comment_</span><span class="Special">#{</span>prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + prefix + <span class="Special">'</span><span class="Constant">(?!!)</span><span class="Special">\\</span><span class="Constant">s?(.*)$</span><span class="Special">'</span> },
|
6356
6402
|
},
|
6357
6403
|
<span class="Special">"</span><span class="Constant">states</span><span class="Special">"</span> => {
|
6358
6404
|
<span class="Special">"</span><span class="Constant">start</span><span class="Special">"</span> => {
|
@@ -6585,8 +6631,8 @@ Ruby coverage somehow barfs if we inline this. Go figure.
|
|
6585
6631
|
<span class="Statement">return</span> {
|
6586
6632
|
<span class="Special">"</span><span class="Constant">syntax</span><span class="Special">"</span> => {
|
6587
6633
|
<span class="Special">"</span><span class="Constant">patterns</span><span class="Special">"</span> => {
|
6588
|
-
<span class="Special">"</span><span class="Constant">comment_start_</span><span class="Special">#{</span>start_prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special"
|
6589
|
-
<span class="Special">"</span><span class="Constant">comment_continue_</span><span class="Special">#{</span>continue_prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special"
|
6634
|
+
<span class="Special">"</span><span class="Constant">comment_start_</span><span class="Special">#{</span>start_prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + start_prefix+ <span class="Special">'</span><span class="Constant">\s?(.*)$</span><span class="Special">'</span> },
|
6635
|
+
<span class="Special">"</span><span class="Constant">comment_continue_</span><span class="Special">#{</span>continue_prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + continue_prefix + <span class="Special">'</span><span class="Constant">\s?(.*)$</span><span class="Special">'</span> },
|
6590
6636
|
},
|
6591
6637
|
<span class="Special">"</span><span class="Constant">states</span><span class="Special">"</span> => {
|
6592
6638
|
<span class="Special">"</span><span class="Constant">start</span><span class="Special">"</span> => {
|
@@ -6830,7 +6876,7 @@ need to escape special characters such as “*”.
|
|
6830
6876
|
</tr>
|
6831
6877
|
</table>
|
6832
6878
|
<pre class='ruby code syntax'>
|
6833
|
-
<span class="Statement">return</span> <span class="Type">Comments</span>.delimited_comments(<span class="Special"
|
6879
|
+
<span class="Statement">return</span> <span class="Type">Comments</span>.delimited_comments(<span class="Special">'</span><span class="Constant">/\*</span><span class="Special">'</span>, <span class="Special">'</span><span class="Constant"> \*</span><span class="Special">'</span>, <span class="Special">'</span><span class="Constant"> \*/</span><span class="Special">'</span>)
|
6834
6880
|
end
|
6835
6881
|
|
6836
6882
|
</pre>
|
@@ -6854,6 +6900,27 @@ comments.
|
|
6854
6900
|
<span class="Statement">return</span> <span class="Type">Comments</span>.delimited_comments(<span class="Special">"</span><span class="Constant"><!--</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant"> -</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant">--></span><span class="Special">"</span>)
|
6855
6901
|
<span class="Statement">end</span>
|
6856
6902
|
|
6903
|
+
</pre>
|
6904
|
+
<table class='layout'>
|
6905
|
+
<tr>
|
6906
|
+
<td class='indentation'>
|
6907
|
+
<pre></pre>
|
6908
|
+
</td>
|
6909
|
+
<td class='html'>
|
6910
|
+
<div class='rdoc comment markup'>
|
6911
|
+
<p>
|
6912
|
+
Classify delimited Elixir style comments. These start with `@doc
|
6913
|
+
“”“`, end with `”“”`, and have no prefix for the inner lines.
|
6914
|
+
</p>
|
6915
|
+
</div>
|
6916
|
+
</td>
|
6917
|
+
</tr>
|
6918
|
+
</table>
|
6919
|
+
<pre class='ruby code syntax'>
|
6920
|
+
<span class="Type">CLASSIFY_ELIXIR_COMMENTS</span> = <span class="Statement">lambda</span> <span class="Statement">do</span>
|
6921
|
+
<span class="Statement">return</span> <span class="Type">Comments</span>.delimited_comments(<span class="Special">'</span><span class="Constant">@[a-z]*doc\s+"""</span><span class="Special">'</span>, <span class="Constant">nil</span>, <span class="Special">'</span><span class="Constant">"""</span><span class="Special">'</span>)
|
6922
|
+
<span class="Statement">end</span>
|
6923
|
+
|
6857
6924
|
</pre>
|
6858
6925
|
<table class='layout'>
|
6859
6926
|
<tr>
|
@@ -6877,10 +6944,10 @@ delimited start prefix, inner line prefix and final suffix (e.g., “/*”,
|
|
6877
6944
|
<span class="Statement">return</span> {
|
6878
6945
|
<span class="Special">"</span><span class="Constant">syntax</span><span class="Special">"</span> => {
|
6879
6946
|
<span class="Special">"</span><span class="Constant">patterns</span><span class="Special">"</span> => {
|
6880
|
-
<span class="Special">"</span><span class="Constant">comment_prefix_</span><span class="Special">#{</span>prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special"
|
6881
|
-
<span class="Special">"</span><span class="Constant">comment_inner_</span><span class="Special">#{</span>inner<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">"</span><span class="Constant">^(
|
6882
|
-
<span class="Special">"</span><span class="Constant">comment_suffix_</span><span class="Special">#{</span>suffix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special"
|
6883
|
-
<span class="Special">"</span><span class="Constant">comment_line_</span><span class="Special">#{</span>prefix<span class="Special">}</span><span class="Constant">_</span><span class="Special">#{</span>suffix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special"
|
6947
|
+
<span class="Special">"</span><span class="Constant">comment_prefix_</span><span class="Special">#{</span>prefix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + prefix + <span class="Special">'</span><span class="Constant">(?!!)\s?(.*)$</span><span class="Special">'</span> },
|
6948
|
+
<span class="Special">"</span><span class="Constant">comment_inner_</span><span class="Special">#{</span>inner<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => inner.nil? ? <span class="Special">"</span><span class="Constant">^()(.*)$</span><span class="Special">"</span> : <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + inner + <span class="Special">'</span><span class="Constant">\s?(.*)$</span><span class="Special">'</span> },
|
6949
|
+
<span class="Special">"</span><span class="Constant">comment_suffix_</span><span class="Special">#{</span>suffix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + suffix + <span class="Special">'</span><span class="Constant">\s*$</span><span class="Special">'</span> },
|
6950
|
+
<span class="Special">"</span><span class="Constant">comment_line_</span><span class="Special">#{</span>prefix<span class="Special">}</span><span class="Constant">_</span><span class="Special">#{</span>suffix<span class="Special">}</span><span class="Special">"</span> => { <span class="Special">"</span><span class="Constant">regexp</span><span class="Special">"</span> => <span class="Special">'</span><span class="Constant">^(\s*)</span><span class="Special">'</span> + prefix + <span class="Special">'</span><span class="Constant">(?!!)\s?(.*?)\s*</span><span class="Special">'</span> + suffix + <span class="Special">'</span><span class="Constant">\s*$</span><span class="Special">'</span> },
|
6884
6951
|
},
|
6885
6952
|
<span class="Special">"</span><span class="Constant">states</span><span class="Special">"</span> => {
|
6886
6953
|
<span class="Special">"</span><span class="Constant">start</span><span class="Special">"</span> => {
|
@@ -6987,6 +7054,10 @@ need to escape special characters such as “{” and “|”.
|
|
6987
7054
|
check_any_comment([ <span class="Special">"</span><span class="Constant"><!--</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant"> -</span><span class="Special">"</span>, <span class="Special">"</span><span class="Constant">--></span><span class="Special">"</span> ], <span class="Type">Codnar</span>::<span class="Type">Configuration</span>::<span class="Type">CLASSIFY_HTML_COMMENTS</span>.call)
|
6988
7055
|
<span class="PreProc">end</span>
|
6989
7056
|
|
7057
|
+
<span class="PreProc">def</span> <span class="Identifier">test_delimited_comments</span>
|
7058
|
+
check_any_comment([ <span class="Special">'</span><span class="Constant">@doc """</span><span class="Special">'</span>, <span class="Constant">nil</span>, <span class="Special">'</span><span class="Constant">"""</span><span class="Special">'</span> ], <span class="Type">Codnar</span>::<span class="Type">Configuration</span>::<span class="Type">CLASSIFY_ELIXIR_COMMENTS</span>.call)
|
7059
|
+
<span class="PreProc">end</span>
|
7060
|
+
|
6990
7061
|
<span class="Statement">protected</span>
|
6991
7062
|
|
6992
7063
|
</pre>
|
@@ -7036,21 +7107,21 @@ The “<<<” will be replaced by the start comment prefix, the
|
|
7036
7107
|
|
7037
7108
|
def check_any_comment(patterns, configuration)
|
7038
7109
|
prefix, inner, suffix = patterns
|
7039
|
-
check_split_file(ANY_COMMENT_CODE.gsub("<span class="Identifier"><</span><span class="Error"><</span><span class="Identifier"><</span><span class="Constant">", prefix).gsub("</span><span class="Identifier">></span><span class="Error">>></span>", suffix).gsub("<span class="Identifier"><></span><span class="Constant">", inner)
|
7040
|
-
|
7041
|
-
|
7042
|
-
|
7043
|
-
|
7044
|
-
|
7045
|
-
|
7046
|
-
|
7047
|
-
|
7048
|
-
|
7049
|
-
|
7050
|
-
|
7051
|
-
|
7110
|
+
check_split_file(ANY_COMMENT_CODE.gsub("<span class="Identifier"><</span><span class="Error"><</span><span class="Identifier"><</span><span class="Constant">", prefix).gsub("</span><span class="Identifier">></span><span class="Error">>></span>", suffix).gsub(inner ? "<span class="Identifier"><></span><span class="Constant">" : "</span><span class="Identifier"><></span> ", inner || ""),
|
7111
|
+
Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("any"),
|
7112
|
+
Codnar::Configuration::FORMAT_PRE_COMMENTS,
|
7113
|
+
configuration) do |path|
|
7114
|
+
[ {
|
7115
|
+
"name" =<span class="Error">></span> path,
|
7116
|
+
"locations" =<span class="Error">></span> [ { "file" =<span class="Error">></span> path, "line" =<span class="Error">></span> 1 } ],
|
7117
|
+
"containers" =<span class="Error">></span> [],
|
7118
|
+
"contained" =<span class="Error">></span> [],
|
7119
|
+
"html" =<span class="Error">></span> ANY_COMMENT_HTML,
|
7120
|
+
} ]
|
7121
|
+
end
|
7122
|
+
end
|
7052
7123
|
|
7053
|
-
|
7124
|
+
end
|
7054
7125
|
</pre>
|
7055
7126
|
</div>
|
7056
7127
|
</div>
|
@@ -9927,7 +9998,6 @@ convenient list of all of Codnar's parts and dependencies:
|
|
9927
9998
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/version</span><span class="Special">"</span>
|
9928
9999
|
|
9929
10000
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/coderay</span><span class="Special">"</span>
|
9930
|
-
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/haddock</span><span class="Special">"</span>
|
9931
10001
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/hash_extensions</span><span class="Special">"</span>
|
9932
10002
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/markdown</span><span class="Special">"</span>
|
9933
10003
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/rdoc</span><span class="Special">"</span>
|
@@ -9939,6 +10009,7 @@ convenient list of all of Codnar's parts and dependencies:
|
|
9939
10009
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/graphviz</span><span class="Special">"</span>
|
9940
10010
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/grouper</span><span class="Special">"</span>
|
9941
10011
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/gvim</span><span class="Special">"</span>
|
10012
|
+
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/haddock</span><span class="Special">"</span>
|
9942
10013
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/merger</span><span class="Special">"</span>
|
9943
10014
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/split</span><span class="Special">"</span>
|
9944
10015
|
<span class="PreProc">require</span> <span class="Special">"</span><span class="Constant">codnar/reader</span><span class="Special">"</span>
|
data/lib/codnar.rb
CHANGED
@@ -22,7 +22,6 @@ require "olag/string_unindent"
|
|
22
22
|
require "codnar/version"
|
23
23
|
|
24
24
|
require "codnar/coderay"
|
25
|
-
require "codnar/haddock"
|
26
25
|
require "codnar/hash_extensions"
|
27
26
|
require "codnar/markdown"
|
28
27
|
require "codnar/rdoc"
|
@@ -34,6 +33,7 @@ require "codnar/formatter"
|
|
34
33
|
require "codnar/graphviz"
|
35
34
|
require "codnar/grouper"
|
36
35
|
require "codnar/gvim"
|
36
|
+
require "codnar/haddock"
|
37
37
|
require "codnar/merger"
|
38
38
|
require "codnar/split"
|
39
39
|
require "codnar/reader"
|
@@ -40,7 +40,7 @@ module Codnar
|
|
40
40
|
return {
|
41
41
|
"syntax" => {
|
42
42
|
"patterns" => {
|
43
|
-
"comment_#{prefix}" => { "regexp" =>
|
43
|
+
"comment_#{prefix}" => { "regexp" => '^(\s*)' + prefix + '(?!!)\\s?(.*)$' },
|
44
44
|
},
|
45
45
|
"states" => {
|
46
46
|
"start" => {
|
@@ -92,8 +92,8 @@ module Codnar
|
|
92
92
|
return {
|
93
93
|
"syntax" => {
|
94
94
|
"patterns" => {
|
95
|
-
"comment_start_#{start_prefix}" => { "regexp" =>
|
96
|
-
"comment_continue_#{continue_prefix}" => { "regexp" =>
|
95
|
+
"comment_start_#{start_prefix}" => { "regexp" => '^(\s*)' + start_prefix+ '\s?(.*)$' },
|
96
|
+
"comment_continue_#{continue_prefix}" => { "regexp" => '^(\s*)' + continue_prefix + '\s?(.*)$' },
|
97
97
|
},
|
98
98
|
"states" => {
|
99
99
|
"start" => {
|
@@ -140,7 +140,7 @@ module Codnar
|
|
140
140
|
CLASSIFY_C_COMMENTS = lambda do
|
141
141
|
# Since the prefix/inner/suffix passed to the configuration are regexps,
|
142
142
|
# we need to escape special characters such as "*".
|
143
|
-
return Comments.delimited_comments(
|
143
|
+
return Comments.delimited_comments('/\*', ' \*', ' \*/')
|
144
144
|
end
|
145
145
|
|
146
146
|
# Classify delimited HTML ("<!--", " -", "-->") style comments.
|
@@ -148,6 +148,12 @@ module Codnar
|
|
148
148
|
return Comments.delimited_comments("<!--", " -", "-->")
|
149
149
|
end
|
150
150
|
|
151
|
+
# Classify delimited Elixir style comments. These start with `@doc """`,
|
152
|
+
# end with `"""`, and have no prefix for the inner lines.
|
153
|
+
CLASSIFY_ELIXIR_COMMENTS = lambda do
|
154
|
+
return Comments.delimited_comments('@[a-z]*doc\s+"""', nil, '"""')
|
155
|
+
end
|
156
|
+
|
151
157
|
# Configuration for classifying lines to comments and code based on a
|
152
158
|
# delimited start prefix, inner line prefix and final suffix (e.g., "/*", "
|
153
159
|
# *", " */" for C-style comments or "<!--", " -", "-->" for HTML style
|
@@ -156,10 +162,10 @@ module Codnar
|
|
156
162
|
return {
|
157
163
|
"syntax" => {
|
158
164
|
"patterns" => {
|
159
|
-
"comment_prefix_#{prefix}" => { "regexp" =>
|
160
|
-
"comment_inner_#{inner}" => { "regexp" => "^(
|
161
|
-
"comment_suffix_#{suffix}" => { "regexp" =>
|
162
|
-
"comment_line_#{prefix}_#{suffix}" => { "regexp" =>
|
165
|
+
"comment_prefix_#{prefix}" => { "regexp" => '^(\s*)' + prefix + '(?!!)\s?(.*)$' },
|
166
|
+
"comment_inner_#{inner}" => { "regexp" => inner.nil? ? "^()(.*)$" : '^(\s*)' + inner + '\s?(.*)$' },
|
167
|
+
"comment_suffix_#{suffix}" => { "regexp" => '^(\s*)' + suffix + '\s*$' },
|
168
|
+
"comment_line_#{prefix}_#{suffix}" => { "regexp" => '^(\s*)' + prefix + '(?!!)\s?(.*?)\s*' + suffix + '\s*$' },
|
163
169
|
},
|
164
170
|
"states" => {
|
165
171
|
"start" => {
|
data/lib/codnar/gvim.rb
CHANGED
@@ -15,7 +15,7 @@ module Codnar
|
|
15
15
|
|
16
16
|
# The cache used for speeding up recomputing the same syntax highlighting
|
17
17
|
# HTML.
|
18
|
-
@cache = Cache.new(".
|
18
|
+
@cache = Cache.new(".codnar-cache") do |data|
|
19
19
|
GVim.uncached_syntax_to_html(data.text, data.syntax, data.commands)
|
20
20
|
end
|
21
21
|
|
@@ -43,7 +43,7 @@ module Codnar
|
|
43
43
|
#
|
44
44
|
# Since GVim is as slow as molasses to start up, we cache the results of
|
45
45
|
# highlighting the syntax of each code fragment in a directory called
|
46
|
-
# <tt>.
|
46
|
+
# <tt>.codnar-cache</tt>, which can appear at the current working directory
|
47
47
|
# or in any of its parents.
|
48
48
|
def self.cached_syntax_to_html(text, syntax, commands = [])
|
49
49
|
data = { "text" => text, "syntax" => syntax, "commands" => commands }
|
@@ -80,6 +80,7 @@ module Codnar
|
|
80
80
|
ENV["DISPLAY"] = "none" # Otherwise the X11 server *does* affect the result.
|
81
81
|
command = [
|
82
82
|
"gvim",
|
83
|
+
"-s", "/dev/null", # Magic: avoids a sleep of 2 seconds in VIM startup!
|
83
84
|
"-f", "-X",
|
84
85
|
"-u", "none",
|
85
86
|
"-U", "none",
|
data/lib/codnar/haddock.rb
CHANGED
@@ -3,8 +3,14 @@ module Codnar
|
|
3
3
|
# Convert Haddoc to HTML.
|
4
4
|
class Haddock
|
5
5
|
|
6
|
+
# The cache used for speeding up recomputing the same syntax highlighting
|
7
|
+
# HTML.
|
8
|
+
@cache = Cache.new(".codnar-cache") do |data|
|
9
|
+
Haddock.uncached_to_html(data.haddock)
|
10
|
+
end
|
11
|
+
|
6
12
|
# Process a Haddock String and return the resulting HTML.
|
7
|
-
def self.
|
13
|
+
def self.uncached_to_html(haddock)
|
8
14
|
with_temporary_directory do |path|
|
9
15
|
write_temporary_file(path, haddock)
|
10
16
|
run_haddock(path)
|
@@ -13,6 +19,15 @@ module Codnar
|
|
13
19
|
end
|
14
20
|
end
|
15
21
|
|
22
|
+
# Since Haddock is as slow as molasses to start up, we cache the results of
|
23
|
+
# highlighting the syntax of each code fragment in a directory called
|
24
|
+
# <tt>.codnar-cache</tt>, which can appear at the current working
|
25
|
+
# directory or in any of its parents.
|
26
|
+
def self.to_html(haddock)
|
27
|
+
data = { "haddock" => haddock }
|
28
|
+
return @cache[data]
|
29
|
+
end
|
30
|
+
|
16
31
|
protected
|
17
32
|
|
18
33
|
# Run a block using a temporary directory, that is then removed. TODO: This
|
data/lib/codnar/version.rb
CHANGED
@@ -24,6 +24,10 @@ class TestSplitDelimitedCommentsConfigurations < Test::Unit::TestCase
|
|
24
24
|
check_any_comment([ "<!--", " -", "-->" ], Codnar::Configuration::CLASSIFY_HTML_COMMENTS.call)
|
25
25
|
end
|
26
26
|
|
27
|
+
def test_delimited_comments
|
28
|
+
check_any_comment([ '@doc """', nil, '"""' ], Codnar::Configuration::CLASSIFY_ELIXIR_COMMENTS.call)
|
29
|
+
end
|
30
|
+
|
27
31
|
protected
|
28
32
|
|
29
33
|
# The "<<<" will be replaced by the start comment prefix,
|
@@ -56,7 +60,7 @@ protected
|
|
56
60
|
|
57
61
|
def check_any_comment(patterns, configuration)
|
58
62
|
prefix, inner, suffix = patterns
|
59
|
-
check_split_file(ANY_COMMENT_CODE.gsub("<<<", prefix).gsub(">>>", suffix).gsub("<>", inner),
|
63
|
+
check_split_file(ANY_COMMENT_CODE.gsub("<<<", prefix).gsub(">>>", suffix).gsub(inner ? "<>" : "<> ", inner || ""),
|
60
64
|
Codnar::Configuration::CLASSIFY_SOURCE_CODE.call("any"),
|
61
65
|
Codnar::Configuration::FORMAT_PRE_COMMENTS,
|
62
66
|
configuration) do |path|
|
@@ -65,7 +69,7 @@ protected
|
|
65
69
|
"locations" => [ { "file" => path, "line" => 1 } ],
|
66
70
|
"containers" => [],
|
67
71
|
"contained" => [],
|
68
|
-
"html" => ANY_COMMENT_HTML
|
72
|
+
"html" => ANY_COMMENT_HTML,
|
69
73
|
} ]
|
70
74
|
end
|
71
75
|
end
|
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: 129
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 77
|
10
|
+
version: 0.1.77
|
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: 2012-
|
18
|
+
date: 2012-11-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: andand
|
@@ -323,7 +323,7 @@ licenses: []
|
|
323
323
|
post_install_message:
|
324
324
|
rdoc_options:
|
325
325
|
- --title
|
326
|
-
- Code Narrator 0.1.
|
326
|
+
- Code Narrator 0.1.77
|
327
327
|
- --main
|
328
328
|
- README.rdoc
|
329
329
|
- --line-numbers
|