summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2015-10-12 10:42:15 -0700
committerDavid Tolnay <dtolnay@gmail.com>2015-10-12 10:42:15 -0700
commit05d1c09cc1c6975dd3c2be76a9149ffa84255894 (patch)
treeee54b21484778c59e53eeb87151625e891eb08b5 /docs
parent9d6e91ea7b5c7c1be8a9e167190ac02c46a294ce (diff)
Split up Rakefile to minimize dependencies (fix #435)
Diffstat (limited to 'docs')
-rw-r--r--docs/Rakefile122
-rw-r--r--docs/Rakefile.manual49
-rw-r--r--docs/Rakefile.website68
3 files changed, 129 insertions, 110 deletions
diff --git a/docs/Rakefile b/docs/Rakefile
index c31d5976..3f4655db 100644
--- a/docs/Rakefile
+++ b/docs/Rakefile
@@ -1,121 +1,23 @@
-require 'bonsai'
-require 'json'
-require 'liquid'
-require 'maruku'
-require 'ronn'
-require 'tempfile'
-require 'yaml'
+rakefile_manual = File.expand_path("Rakefile.manual", __FILE__)
+rakefile_website = File.expand_path("Rakefile.website", __FILE__)
-module ExtraFilters
- def markdownify(input)
- Maruku.new(input).to_html
- end
-
- def section_id(input)
- input.gsub(/[^a-zA-Z0-9_]/, '')
- end
-
- def entry_id(input)
- input.gsub(' ', '')
- end
-
- def no_paragraph(input)
- input.gsub('<p>', '').gsub('</p>', '')
- end
-
- def json(input)
- input.to_json
- end
-
- def unique(input)
- @n = (@n || 0) + 1
- input + @n.to_s
- end
+desc "Build the manpage from the bonsai source of the manual"
+task :manpage do
+ system %(#{$0} -f #{rakefile_manual} manpage)
end
-Liquid::Template.register_filter(ExtraFilters)
-
-desc "Serve a live view of the website on http://localhost:5000/jq/"
-task :serve do
- begin
- Bonsai.log "Press Control+C to quit"
-
- require 'rack'
- require 'sinatra'
- require 'watch'
- require 'launchy'
-
- Bonsai.root_dir = Dir.pwd
-
- server = fork {
- app = Rack::Builder.app {
- map "/jq" do
- use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
- end
- run Bonsai::DevelopmentServer
- }
- Rack::Handler.default.run(app, :Port => 5000) do
- Launchy.open("http://localhost:5000/jq/")
- end
- }
- Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
- rescue Interrupt
- Process.kill("QUIT", server)
- Process.wait(server)
- exit
- end
+desc "Collect jq unit test cases from the bonsai source of the manual"
+task :mantests do
+ system %(#{$0} -f #{rakefile_manual} mantests)
end
desc "Build the website from the bonsai sources"
task :build do
- Bonsai.root_dir = Dir.pwd
- Bonsai::Exporter.publish!
-end
-
-def load_manual
- YAML::load(File.open("content/3.manual/manual.yml"))
+ system %(#{$0} -f #{rakefile_website} build)
end
-desc "Build the manpage from the bonsai source of the manual"
-task :manpage do
- Tempfile.open "manpage" do |f|
- manual = load_manual
- f.puts manual['manpage_intro']
- f.puts manual['body']
- manual['sections'].each do |section|
-
- f.puts "## #{section['title'].upcase}\n"
- f.puts section['body']
- f.puts ""
- (section['entries'] || []).each do |entry|
- f.puts "### #{entry['title']}\n"
- f.puts entry['body']
- f.puts ""
- (entry['examples'] || []).each do |example|
- f.puts " jq '#{example['program']}'"
- f.puts " #{example['input']}"
- f.puts " => #{example['output'].join(", ")}"
- f.puts
- end
- end
- f.puts ""
- end
- f.puts manual['manpage_epilogue']
- f.close
- puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
- end
+desc "Serve a live view of the website on http://localhost:5000/jq/"
+task :serve do
+ system %(#{$0} -f #{rakefile_website} serve)
end
-desc "Collect jq unit test cases from the bonsai source of the manual"
-task :mantests do
- load_manual['sections'].each do |section|
- (section['entries'] || []).each do |entry|
- (entry['examples'] || []).each do |example|
- puts example['program'].gsub("\n", " ")
- puts example['input']
- example['output'].each do |s| puts s end
- puts
- end
- end
- end
-end
diff --git a/docs/Rakefile.manual b/docs/Rakefile.manual
new file mode 100644
index 00000000..03eccb0f
--- /dev/null
+++ b/docs/Rakefile.manual
@@ -0,0 +1,49 @@
+require 'ronn'
+require 'tempfile'
+require 'yaml'
+
+def load_manual
+ YAML::load(File.open("content/3.manual/manual.yml"))
+end
+
+task :manpage do
+ Tempfile.open "manpage" do |f|
+ manual = load_manual
+ f.puts manual['manpage_intro']
+ f.puts manual['body']
+ manual['sections'].each do |section|
+
+ f.puts "## #{section['title'].upcase}\n"
+ f.puts section['body']
+ f.puts ""
+ (section['entries'] || []).each do |entry|
+ f.puts "### #{entry['title']}\n"
+ f.puts entry['body']
+ f.puts ""
+ (entry['examples'] || []).each do |example|
+ f.puts " jq '#{example['program']}'"
+ f.puts " #{example['input']}"
+ f.puts " => #{example['output'].join(", ")}"
+ f.puts
+ end
+ end
+ f.puts ""
+ end
+ f.puts manual['manpage_epilogue']
+ f.close
+ puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
+ end
+end
+
+task :mantests do
+ load_manual['sections'].each do |section|
+ (section['entries'] || []).each do |entry|
+ (entry['examples'] || []).each do |example|
+ puts example['program'].gsub("\n", " ")
+ puts example['input']
+ example['output'].each do |s| puts s end
+ puts
+ end
+ end
+ end
+end
diff --git a/docs/Rakefile.website b/docs/Rakefile.website
new file mode 100644
index 00000000..4044bb2f
--- /dev/null
+++ b/docs/Rakefile.website
@@ -0,0 +1,68 @@
+require 'bonsai'
+require 'json'
+require 'liquid'
+require 'maruku'
+
+module ExtraFilters
+ def markdownify(input)
+ Maruku.new(input).to_html
+ end
+
+ def section_id(input)
+ input.gsub(/[^a-zA-Z0-9_]/, '')
+ end
+
+ def entry_id(input)
+ input.gsub(' ', '')
+ end
+
+ def no_paragraph(input)
+ input.gsub('<p>', '').gsub('</p>', '')
+ end
+
+ def json(input)
+ input.to_json
+ end
+
+ def unique(input)
+ @n = (@n || 0) + 1
+ input + @n.to_s
+ end
+end
+
+Liquid::Template.register_filter(ExtraFilters)
+
+task :build do
+ Bonsai.root_dir = Dir.pwd
+ Bonsai::Exporter.publish!
+end
+
+task :serve do
+ begin
+ Bonsai.log "Press Control+C to quit"
+
+ require 'rack'
+ require 'sinatra'
+ require 'watch'
+ require 'launchy'
+
+ Bonsai.root_dir = Dir.pwd
+
+ server = fork {
+ app = Rack::Builder.app {
+ map "/jq" do
+ use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
+ end
+ run Bonsai::DevelopmentServer
+ }
+ Rack::Handler.default.run(app, :Port => 5000) do
+ Launchy.open("http://localhost:5000/jq/")
+ end
+ }
+ Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
+ rescue Interrupt
+ Process.kill("QUIT", server)
+ Process.wait(server)
+ exit
+ end
+end