Skip to content

Commit

Permalink
* Added MaMa documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dichodaemon committed May 16, 2007
1 parent 8be2888 commit ca7b64b
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 32 deletions.
80 changes: 53 additions & 27 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
@@ -1,41 +1,67 @@
require 'rubygems' require 'rubygems'
require 'hoe' require 'hoe'


class Hoe rubyforge_name = "oniguruma"
# Dirty hack to eliminate Hoe from gem dependencies
def extra_deps begin
@extra_deps.delete_if{ |x| x.first == 'hoe' }
class Hoe
# Dirty hack to eliminate Hoe from gem dependencies
def extra_deps
@extra_deps.delete_if{ |x| x.first == 'hoe' }
end

# Dirty hack to package only the required files per platform
def spec= s
if ENV['PLATFORM'] =~ /win32/
s.files = s.files.reject! {|f| f =~ /extconf\.rb/}
else
s.files = s.files.reject! {|f| f =~ /win\//}
end
@spec = s
end
end end


# Dirty hack to package only the required files per platform version = /^== *(\d+\.\d+\.\d+)/.match( File.read( 'History.txt' ) )[1]
def spec= s
h = Hoe.new('oniguruma', version) do |p|
p.rubyforge_name = 'oniguruma'
p.author = ['Dizan Vasquez', 'Nikolai Lugovoi']
p.email = 'dichodaemon@gmail.com'
p.summary = 'Bindings for the oniguruma regular expression library'
p.description = p.paragraphs_of('README.txt', 1 ).join('\n\n')
p.url = 'http://oniguruma.rubyforge.org'
if ENV['PLATFORM'] =~ /win32/ if ENV['PLATFORM'] =~ /win32/
s.files = s.files.reject! {|f| f =~ /extconf\.rb/} p.lib_files = ["win/oregexp.so"]
p.spec_extras[:require_paths] = ["win", "lib", "ext" ]
p.spec_extras[:platform] = Gem::Platform::WIN32
else else
s.files = s.files.reject! {|f| f =~ /win\//} p.spec_extras[:extensions] = ["ext/extconf.rb"]
end end
@spec = s p.rdoc_pattern = /^(lib|bin|ext)|txt$/
p.changes = p.paragraphs_of('History.txt', 0).join("\n\n")
p.clean_globs = ["manual/*"]
end end
end


version = /^== *(\d+\.\d+\.\d+)/.match( File.read( 'History.txt' ) )[1] desc 'Create MaMa documentation'
task :mama => :clean do
system "mm -c -t refresh -o manual mm/manual.mm"
end

desc 'Publish MaMa documentation to RubyForge'
task :mama_publish => [:clean, :mama] do
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
host = "#{config["username"]}@rubyforge.org"
remote_dir = "/var/www/gforge-projects/#{h.rubyforge_name}"
local_dir = 'manual'
system "rsync -av #{local_dir}/ #{host}:#{remote_dir}"
end


Hoe.new('oniguruma', version) do |p| rescue LoadError => e
p.rubyforge_name = 'oniguruma' desc 'Run the test suite.'
p.author = ['Dizan Vasquez', 'Nikolai Lugovoi'] task :test do
p.email = 'dichodaemon@gmail.com' system "ruby -Ibin:lib:test test_#{rubyforge_name}.rb"
p.summary = 'Bindings for the oniguruma regular expression library' end
p.description = p.paragraphs_of('README.txt', 1 ).join('\n\n')
p.url = 'http://oniguruma.rubyforge.org'
if ENV['PLATFORM'] =~ /win32/
p.lib_files = ["win/oregexp.so"]
p.spec_extras[:require_paths] = ["win", "lib", "ext" ]
p.spec_extras[:platform] = Gem::Platform::WIN32
else
p.spec_extras[:extensions] = ["ext/extconf.rb"]
end
p.rdoc_pattern = /^(lib|bin|ext)|txt$/
p.changes = p.paragraphs_of('History.txt', 0).join("\n\n")
end end




12 changes: 7 additions & 5 deletions ext/oregexp.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static VALUE oregexp_make_match_data(ORegexp * oregexp, OnigRegion * region, VAL
return (VALUE)match; return (VALUE)match;
} }


/* /**
* call-seq: * call-seq:
* rxp.match(str) => matchdata or nil * rxp.match(str) => matchdata or nil
* rxp.match(str, begin, end) => matchdata or nil * rxp.match(str, begin, end) => matchdata or nil
Expand Down Expand Up @@ -588,7 +588,7 @@ static VALUE oregexp_m_gsub_bang(int argc, VALUE *argv, VALUE self) {
* Performs the substitutions of ORegexp#sub in place, returning * Performs the substitutions of ORegexp#sub in place, returning
* _str_, or _nil_ if no substitutions were performed. * _str_, or _nil_ if no substitutions were performed.
* *
**/ */
static VALUE oregexp_m_sub_bang(int argc, VALUE *argv, VALUE self) { static VALUE oregexp_m_sub_bang(int argc, VALUE *argv, VALUE self) {
return oregexp_safe_gsub(self, argc, argv, 1, 1); return oregexp_safe_gsub(self, argc, argv, 1, 1);
} }
Expand Down Expand Up @@ -653,6 +653,7 @@ struct scan_packet {
static VALUE oregexp_packed_scan( struct scan_packet * args) { static VALUE oregexp_packed_scan( struct scan_packet * args) {
return oregexp_scan(args->self, args->str, args->region); return oregexp_scan(args->self, args->str, args->region);
} }

/** /**
* call-seq: * call-seq:
* rxp.scan(str) # => [matchdata1, matchdata2,...] or nil * rxp.scan(str) # => [matchdata1, matchdata2,...] or nil
Expand All @@ -671,7 +672,6 @@ static VALUE oregexp_m_scan(VALUE self, VALUE str) {
return rb_ensure( oregexp_packed_scan, (VALUE)&call_args, oregexp_cleanup_region, (VALUE)region); return rb_ensure( oregexp_packed_scan, (VALUE)&call_args, oregexp_cleanup_region, (VALUE)region);
} }



/** /**
* call-seq: * call-seq:
* rxp === str => true or false * rxp === str => true or false
Expand Down Expand Up @@ -708,7 +708,8 @@ static VALUE oregexp_m_eqq(VALUE self, VALUE str) {
} }
return Qtrue; return Qtrue;
} }
/*
/**
* call-seq: * call-seq:
* rxp =~ string => int or nil * rxp =~ string => int or nil
* *
Expand All @@ -718,7 +719,8 @@ static VALUE oregexp_m_eqq(VALUE self, VALUE str) {
* *
* ORegexp.new( 'SIT' ) =~ "insensitive" #=> nil * ORegexp.new( 'SIT' ) =~ "insensitive" #=> nil
* ORegexp.new( 'SIT', :options => OPTION_IGNORECASE ) =~ "insensitive" #=> 5 * ORegexp.new( 'SIT', :options => OPTION_IGNORECASE ) =~ "insensitive" #=> 5
**/ */

static VALUE oregexp_match_op(VALUE self, VALUE str) { static VALUE oregexp_match_op(VALUE self, VALUE str) {
VALUE args[] = {str}; VALUE args[] = {str};
VALUE ret = oregexp_match(1, args, self); VALUE ret = oregexp_match(1, args, self);
Expand Down
101 changes: 101 additions & 0 deletions mm/manual.mm
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,101 @@
~Oniguruma for Ruby~
~~Ruby bindings for oniguruma~~

#Main# | index

= About =

This library provides bindings to [Oniguruma http://www.geocities.jp/kosako3/oniguruma/],
a regular expression library which is standard with Ruby 1.9. It allows users
of Ruby 1.8 to access the extended functionality without the need to recompile
or to upgrade Ruby.

This site provides an overview of the library, the api documentation is
[here http://oniguruma.rubyforge.org/oniguruma].

= Requirements =

* [Oniguruma http://www.geocities.jp/kosako3/oniguruma/] regular expression library (/>= 4.x.x/)

= Installation =

If you have [rubygems http://docs.rubygems.org/] installation is straightforward by typing
(as root if needed):

--------hl shell-unix-generic,,false------
gem install -r oniguruma
------------------------------------------

If you prefer to get the sources, the last stable version may be
downloaded [here http://rubyforge.org/frs/?group_id=3289].

= Status =

The library interface is mature. Existing bugs are being fixed as they are
found.

#Use#

= Details =

Oniguruma provides the same functionality (and almost the same interface) than
standard regexp in Ruby. The main missing feature is the slash syntax to
declare regular expressions `/regexp/`. On the other hand, oniguruma provides
additional functionality:

* Extensive multibyte support.
-----------hl ruby,,false-----
reg = ORegexp.new( 'р(уби.*)', 'i', 'utf8' )
matches = reg.match("Text: Ехал Грека Через Реку")
puts matches[0] #=> "Ехал"
------------------------------

* Named groups.
-----------hl ruby,,false-----
reg = ORegex.new( '(?<before>.*)(a)(?<after>.*)' )
match = reg.match( 'terraforming' )
puts match[0] #=> 'terraforming'
puts match[:before] #=> 'terr'
puts match[:after] #=> 'forming'
------------------------------

* Named backreferences.
-----------hl ruby,,false-----
re = ORegexp.new('(?<pre>\w+?)\d+(?<after>\w+)')
puts re.sub('abc123def', ' \<after>123\<pre> ') #=> " def123abc "
------------------------------

* Positive and negative Lookbehind.
-----------hl ruby,,false-----
re = ORegexp.new('(?>!g)ong')
m1 = re.match("song")
puts m1[0] #=> ong
m2 = re.match("gong") #=> nil
------------------------------

* Support for different regexp syntaxes (Python, Perl, etc.).
-----------hl ruby,,false-----
re = ORegexp.new( 'section{ (?P<name> [^}]* ) }', :syntax => SYNTAX_PYTHON )
re.sub('section{First}', 'subsection{\1}') #=> "subsection{First}"
------------------------------

# Links #


= Rubyforge project page =

* [Textpow http://rubyforge.org/projects/oniguruma].

= Documentation =

* [Api Documentation http://oniguruma.rubyforge.org/oniguruma].

= Requirements =

* [Oniguruma http://www.geocities.jp/kosako3/oniguruma/].

= Projects using Textpow =

* [Textpow http://textpow.rubyforge.org/].
* [Ultraviolet Syntax Highlighting Engine http://ultraviolet.rubyforge.org/].
* [Macaronic markup engine http://mama.rubyforge.org/].

0 comments on commit ca7b64b

Please sign in to comment.