forked from asciidoctor/asciidoctor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
115 lines (103 loc) · 2.93 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require File.expand_path '../lib/asciidoctor/version', __FILE__
def prepare_test_env
# rather than hardcoding gc settings in test task,
# could use https://gist.github.com/benders/788695
ENV['RUBY_GC_MALLOC_LIMIT'] = '90000000'
ENV['RUBY_FREE_MIN'] = '200000'
end
begin
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
prepare_test_env
puts "LANG: #{ENV['LANG']}"
test.libs << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
test.warning = true
end
task :default => :test
rescue LoadError
end
=begin
# Run tests with Encoding::default_external set to US-ASCII
begin
Rake::TestTask.new(:test_us_ascii) do |test|
prepare_test_env
puts "LANG: #{ENV['LANG']}"
test.libs << 'test'
test.pattern = 'test/**/*_test.rb'
test.ruby_opts << '-EUS-ASCII' if RUBY_VERSION >= '1.9'
test.verbose = true
test.warning = true
end
rescue LoadError
end
=end
begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
end
rescue LoadError
end
=begin
begin
require 'rdoc/task'
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "Asciidoctor #{Asciidoctor::VERSION}"
rdoc.markup = 'tomdoc' if rdoc.respond_to?(:markup)
rdoc.rdoc_files.include('LICENSE', 'lib/**/*.rb')
end
rescue LoadError
end
=end
begin
require 'yard'
require 'yard-tomdoc'
require './lib/asciidoctor'
require './lib/asciidoctor/extensions'
# Prevent YARD from breaking command statements in literal paragraphs
class CommandBlockPostprocessor < Asciidoctor::Extensions::Postprocessor
def process output
output.gsub(/<pre>\$ (.+?)<\/pre>/m, '<pre class="command code"><span class="const">$</span> \1</pre>')
end
end
Asciidoctor::Extensions.register do |doc|
postprocessor CommandBlockPostprocessor
end
# register .adoc extension for AsciiDoc markup helper
YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS[:asciidoc] = %w(adoc)
YARD::Rake::YardocTask.new do |yard|
yard.files = %w(
lib/**/*.rb
-
CHANGELOG.adoc
LICENSE
)
# --no-highlight enabled to prevent verbatim blocks in AsciiDoc that begin with $ from being dropped
# need to patch htmlify method to not attempt to syntax highlight blocks (or fix what's wrong)
yard.options = %w(
--exclude backends
--exclude opal_ext
--hide-api private
-o rdoc
--plugin tomdoc
--title Asciidoctor\ API\ Documentation
)
end
rescue LoadError
end
begin
require 'bundler/gem_tasks'
# Enhance the release task to create an explicit commit for the release
Rake::Task[:release].enhance [:commit_release]
task :commit_release do
Bundler::GemHelper.new.send(:guard_clean)
sh "git commit --allow-empty -a -m 'Release #{Asciidoctor::VERSION}'"
end
rescue LoadError
end
desc 'Open an irb session preloaded with this library'
task :console do
sh 'bundle console', :verbose => false
end