diff options
-rw-r--r-- | ROADMAP | 16 | ||||
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | TODO | 21 | ||||
-rw-r--r-- | bench/bench.rb | 24 | ||||
-rw-r--r-- | demo/demo_load_encoder.out | 2 | ||||
-rw-r--r-- | demo/demo_load_encoder.rb | 4 | ||||
-rw-r--r-- | demo/demo_load_scanner.out | 7 | ||||
-rw-r--r-- | demo/demo_load_scanner.rb | 21 | ||||
-rw-r--r-- | lib/coderay.rb | 7 | ||||
-rw-r--r-- | lib/coderay/encoder.rb | 2 | ||||
-rw-r--r-- | lib/coderay/helpers/plugin.rb | 11 | ||||
-rw-r--r-- | lib/coderay/helpers/word_list.rb | 5 | ||||
-rw-r--r-- | lib/coderay/scanner.rb | 2 |
13 files changed, 107 insertions, 17 deletions
@@ -0,0 +1,16 @@ +# vim:ts=4:ft=ruby:
+
+0.6.0
+Plaintext, Ruby, C
+
+0.8.0
+XML, HTML, CSS
+
+1.2
+YAML, eRuby, irb, RHTML, SQL, Python
+
+1.4
+PHP, Perl (*schauder*), Pascal/Delphi, C++, Java
+
+1.6
+Haskell, Prolog, CS, VB, TeX, BBCode, Textile, Makefile
@@ -129,7 +129,7 @@ task :make => [:build, :make_gem] BUILD_FILE = 'build'
task :build do
- $version.sub!(/\d+$/) { |minor| minor.to_i - 1 }
+ $version.sub!(/\.(\d+)\./) { minor = $1; ".#{minor.to_i - 1}." }
$version << '.' << (`svn info`[/Revision: (\d+)/,1])
end
@@ -3,15 +3,25 @@ Category = X (done), / (partly done), T (test), (else) Planned = planned in version 0.x
Priority = 3 (low) .. 1 (high), 0 (extrem high)
Expense = 0 (trivial), 1 (low) .. 3 (high)
+ Assigned Day
Project:
Documentation:
-3/4 0 2 Doc the interface
-3/4 0 1 write examples
+3/4 0 2 Do Doc the interface
+3/4 0 1 Sa write examples
+ 1 2 Mi Code Cleanup: Indentation, Docu
+ 2 2 Mo Rewrite Tools: coderay, bench.rb, highlight.rb
+
+
+
+Plugins:
+ 1 1 Sa Plugin mapping (cpp --> Scanners::C etc.)
Scanners:
+ 1 2 More Languages! (See Roadmap)
+
Ruby:
L 3 2 Regexp comment highlighting
L 3 2 Options: Highlight characters/escapes/inline code
@@ -21,10 +31,9 @@ L 2 1 Meta characters Encoders:
HTML:
-3/4 1 2 dynamic CSS creation
- => alternative inline style via <span style="...">
+L 1 2 dynamic CSS creation: new CSS class
Colors:
- 1 2 colorschemes
+ 1 2 So colorschemes
Statistic:
L 3 1 return Statistic object with to_s method instead of String
@@ -33,5 +42,3 @@ L 3 1 return Statistic object with to_s method instead of String Tools:
testfox:
L 2 3 wxRuby and HTML output
-
-
diff --git a/bench/bench.rb b/bench/bench.rb index 38f8a19..f7c7388 100644 --- a/bench/bench.rb +++ b/bench/bench.rb @@ -129,13 +129,31 @@ Benchmark.bm(20) do |bm| if compare time = bm.report('Syntax') do - c = Syntax::Convertors::HTML.for_syntax 'ruby' + c = Syntax::Convertors::HTML.for_syntax lang + puts 'No Syntax syntax found!' if c.tokenizer.is_a? Syntax::Default + begin + v = $VERBOSE + $VERBOSE = nil + raise + output = c.convert(data) + $VERBOSE = v + rescue => boom + output = boom.inspect + end Dir.chdir(here) do File.open('test.syntax.' + format, 'wb') do |f| - f.write '<html><head><style>%s</style></head><body><div class="ruby">%s</div></body></html>' % [DATA.read, c.convert(data)] + f.write '<html><head><style>%s</style></head><body><div class="ruby">%s</div></body></html>' % [DATA.read, output] end end - $file_created << " and test.syntax.#{format}" + $file_created << ", test.syntax.#{format}" + end + puts "\t%7.2f KB/sec" % ((@size / 1024.0) / time.real) + + time = bm.report('SilverCity') do + Dir.chdir(here) do + `c:/Python/Scripts/source2html.pyo --generator=#{lang} example.#{lang} > test.silvercity.html` + end + $file_created << ", test.silvercity.#{format}" end puts "\t%7.2f KB/sec" % ((@size / 1024.0) / time.real) end diff --git a/demo/demo_load_encoder.out b/demo/demo_load_encoder.out index d1a1d97..dffd5c3 100644 --- a/demo/demo_load_encoder.out +++ b/demo/demo_load_encoder.out @@ -3,3 +3,5 @@ Now it is loaded: CodeRay::Encoders::YAML See?
Require is also possible: CodeRay::Encoders::Tokens
See?
+Require all Encoders:
+{:tokens=>CodeRay::Encoders::Tokens, :statistic=>CodeRay::Encoders::Statistic, :div=>CodeRay::Encoders::Div, :text=>CodeRay::Encoders::Text, :debug=>CodeRay::Encoders::Debug, :xml=>CodeRay::Encoders::XML, :count=>CodeRay::Encoders::Count, :stats=>CodeRay::Encoders::Statistic, :span=>CodeRay::Encoders::Span, :yaml=>CodeRay::Encoders::YAML, :null=>CodeRay::Encoders::Null, :html=>CodeRay::Encoders::HTML}
diff --git a/demo/demo_load_encoder.rb b/demo/demo_load_encoder.rb index 4861ee7..9f921cd 100644 --- a/demo/demo_load_encoder.rb +++ b/demo/demo_load_encoder.rb @@ -15,3 +15,7 @@ tokens_encoder = require_plugin 'CodeRay::Encoders/tokens' print 'Require is also possible: '
p tokens_encoder
puts 'See?'
+
+puts 'Require all Encoders:'
+CodeRay::Encoders.load_all
+p CodeRay::Encoders.plugin_hash
diff --git a/demo/demo_load_scanner.out b/demo/demo_load_scanner.out new file mode 100644 index 0000000..d51b55f --- /dev/null +++ b/demo/demo_load_scanner.out @@ -0,0 +1,7 @@ +CodeRay::Encoders::Ruby is not defined; you must load it first.
+Now it is loaded: CodeRay::Scanners::Ruby
+See?
+Require is also possible: CodeRay::Scanners::C
+See?
+Require all Scanners:
+{:delphi=>"Delphi", :plaintext=>"Plaintext", :c=>"C", :ruby=>"Ruby", :cpp=>"C", :plain=>"Plaintext"}
diff --git a/demo/demo_load_scanner.rb b/demo/demo_load_scanner.rb new file mode 100644 index 0000000..900f014 --- /dev/null +++ b/demo/demo_load_scanner.rb @@ -0,0 +1,21 @@ +require 'coderay'
+
+begin
+ CodeRay::Scanners::Ruby
+rescue
+ puts 'CodeRay::Encoders::Ruby is not defined; you must load it first.'
+end
+
+ruby_scanner = CodeRay::Scanners[:ruby]
+print 'Now it is loaded: '
+p ruby_scanner
+puts 'See?'
+
+c_scanner = require_plugin 'CodeRay::Scanners/c'
+print 'Require is also possible: '
+p c_scanner
+puts 'See?'
+
+puts 'Require all Scanners:'
+CodeRay::Scanners.load_all
+p CodeRay::Scanners
diff --git a/lib/coderay.rb b/lib/coderay.rb index 5e9f3f8..62b5991 100644 --- a/lib/coderay.rb +++ b/lib/coderay.rb @@ -128,7 +128,12 @@ # The scanning methods provide more flexibility; we recommend to use these. module CodeRay - Version = '0.4.6' + # Version: Major.Minor.Teeny[.Revision] + # Major: 0 for pre-release + # Minor: odd for beta, even for stable + # Teeny: development state + # Revision: Subversion Revision number (generated on rake) + Version = '0.6.0' require 'coderay/tokens' require 'coderay/scanner' diff --git a/lib/coderay/encoder.rb b/lib/coderay/encoder.rb index 362cfb4..8b6c22a 100644 --- a/lib/coderay/encoder.rb +++ b/lib/coderay/encoder.rb @@ -9,7 +9,7 @@ module CodeRay # belonging to the given format.
module Encoders
extend PluginHost
- plugin_path 'coderay/encoders'
+ plugin_path File.dirname(__FILE__), 'encoders'
# = Encoder
#
diff --git a/lib/coderay/helpers/plugin.rb b/lib/coderay/helpers/plugin.rb index 5c90901..63c3739 100644 --- a/lib/coderay/helpers/plugin.rb +++ b/lib/coderay/helpers/plugin.rb @@ -105,10 +105,19 @@ module PluginHost end
end
+ # A Hash of plugion_id => Plugin pairs.
def plugin_hash
@plugin_hash ||= create_plugin_hash
end
+ def inspect
+ map = plugin_hash.dup
+ map.each do |id, plugin|
+ map[id] = plugin.name[/(?>[\w_]+)$/]
+ end
+ map.inspect
+ end
+
# Every plugin must register itself for one or more
# +ids+ by calling register_for, which calls this method.
@@ -137,7 +146,7 @@ module PluginHost # Loads all plugins using all_plugin_names and load.
def load_all
for plugin in all_plugin_names
- load_plugin plugin
+ load plugin
end
end
diff --git a/lib/coderay/helpers/word_list.rb b/lib/coderay/helpers/word_list.rb index 1371446..be81fd0 100644 --- a/lib/coderay/helpers/word_list.rb +++ b/lib/coderay/helpers/word_list.rb @@ -78,10 +78,11 @@ module CodeRay # Creates a new WordList with +default+ as default value.
#
# Text case is ignored.
- def initialize default = false
- super() do |h, k|
+ def initialize default = false, &block
+ block ||= proc do |h, k|
h[k] = h.fetch k.downcase, default
end
+ super default
end
# Checks if a word is included.
diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb index 609f4da..33bcb09 100644 --- a/lib/coderay/scanner.rb +++ b/lib/coderay/scanner.rb @@ -17,7 +17,7 @@ module CodeRay # See PluginHost.
module Scanners
extend PluginHost
- plugin_path 'coderay/scanners'
+ plugin_path File.dirname(__FILE__), 'scanners'
require 'strscan'
|