forked from rouge-ruby/rouge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
83 lines (67 loc) · 1.78 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require 'rake/clean'
task :spec do
spec_files = FileList.new('./spec/**/*_spec.rb')
switch_spec_files = spec_files.map { |x| "-r#{x}" }.join(' ')
sh "ruby -I./lib -r ./spec/spec_helper #{switch_spec_files} -e Minitest::Unit.autorun"
end
task :doc do
sh 'yard'
end
namespace :doc do
task :server do
sh 'yard server --reload'
end
task :clean do
sh 'rm -rf ./doc/ ./.yardoc/'
end
end
def php_references(&b)
return enum_for :php_references unless block_given?
php_manual_url = 'http://us3.php.net/distributions/manual/php_manual_en.tar.gz'
sh 'mkdir -p /tmp/rouge'
Dir.chdir '/tmp/rouge' do
sh "wget -O- #{php_manual_url} | tar -xz"
Dir.chdir './php-chunked-xhtml' do
Dir.glob('./ref.*').sort.each { |x| yield File.read(x) }
end
end
end
def php_functions(&b)
return enum_for :php_functions unless block_given?
php_references do |file|
file =~ %r(<title>(.*?) Functions</title>)
name = $1
next unless name
functions = file.scan %r(<a href="function\..*?\.html">(.*?)</a>)
yield [name, functions]
end
end
def php_builtins_source
yield "# automatically generated by `rake phpbuiltins`"
yield "module Rouge"
yield " module Lexers"
yield " class PHP"
yield " def self.builtins"
yield " @builtins ||= {}.tap do |b|"
php_functions do |n, fs|
yield " b[#{n.inspect}] = Set.new %w(#{fs.join(' ')})"
end
yield " end"
yield " end"
yield " end"
yield " end"
yield "end"
end
task :phpbuiltins do
File.open('lib/rouge/lexers/php/builtins.rb', 'w') do |f|
php_builtins_source do |line|
f.puts line
end
end
end
CLEAN.include('*.gem')
task :build => [:clean, :spec] do
puts
sh "gem build rouge.gemspec"
end
task :default => :spec