]> code.delx.au - gnu-emacs-elpa/blobdiff - Rakefile
Don't indent empty lines in snippet expansion
[gnu-emacs-elpa] / Rakefile
index b908c3b6e57f110e62ce6275c8ae4629c9387fe2..f88237bd762c58433d2719c2668f41086cd8e220 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -2,63 +2,57 @@
 
 require 'fileutils'
 
+$EMACS = ENV["EMACS"]
+if not $EMACS or $EMACS == 't'
+  $EMACS = "emacs"
+end
+
 def find_version
-  File.read("yasnippet.el") =~ /;; Package-version: *([0-9.]+[a-z]?) *$/
+  File.read("yasnippet.el", :encoding => "UTF-8") =~ /;; Package-version: *([0-9.]+?) *$/
   $version = $1
 end
 find_version
 FileUtils.mkdir_p('pkg')
 
-desc "generate bundle file for classic snippets."
-task :bundle do
-  sh 'emacs --batch -l yasnippet.el --eval "(yas/compile-bundle)"'
-  sh "tar czf pkg/yasnippet-bundle-#{$version}.el.tgz yasnippet-bundle.el"
-end
-
-desc "generate bundle file for textmate snippets."
-task :textmate_bundle => [:convert] do
-  sh 'emacs --batch -l yasnippet.el --eval "(yas/compile-textmate-bundle)"'
-  sh "tar czf pkg/yasnippet-textmate-bundle-#{$version}.el.tgz yasnippet-textmate-bundle.el"
-end
-
-desc "convert some textmate bundles to yasnippets"
-task :convert_bundles do
-  sh 'for bundle in html ruby rails css; do ./extras/textmate_import.rb -d extras/bundles/$bundle-tmbundle -o extras/imported/$bundle-mode -q ; done'
+desc "run tests in batch mode"
+task :tests do
+  sh "#{$EMACS} -Q -L . -l yasnippet-tests.el" +
+    " --batch -f ert-run-tests-batch-and-exit"
 end
 
 desc "create a release package"
 task :package do
   release_dir = "pkg/yasnippet-#{$version}"
   FileUtils.mkdir_p(release_dir)
-  files = ['extras', 'snippets', 'yasnippet.el', 'dropdown-list.el']
+  files = ['snippets', 'yasnippet.el']
   FileUtils.cp_r files, release_dir
-  FileUtils.rm_r Dir[release_dir + "/**/.svn"]
-  FileUtils.cd 'pkg'
-  sh "tar cjf yasnippet-#{$version}.tar.bz2 yasnippet-#{$version}"
-  FileUtils.cd ".."
+  File.open(File.join(release_dir,'yasnippet-pkg.el'), 'w') do |file|
+    file.puts <<END
+(define-package "yasnippet"
+                "#{$version}"
+                "A template system for Emacs")
+END
+  end
+  sh "git clean -f snippets"
+  FileUtils.cd 'pkg' do
+    sh "tar cf yasnippet-#{$version}.tar yasnippet-#{$version}"
+  end
 end
 
 desc "create a release package and upload it to google code"
-task :release => [:bundle, :package, 'doc:archive'] do
-  sh "googlecode_upload.py -s \"YASnippet Release #{$version}\"" +
-    " -p yasnippet -l \"Featured,Type-Package,OpSys-All\"" +
-    " pkg/yasnippet-#{$version}.tar.bz2"
-  sh "googlecode_upload.py -s \"YASnippet Bundle #{$version}\"" +
-    " -p yasnippet -l \"Featured,Type-Package,OpSys-All\"" +
-    " pkg/yasnippet-bundle-#{$version}.el.tgz"
-  sh "googlecode_upload.py -s \"YASnippet Document #{$version}\"" +
-    " -p yasnippet -l \"Featured,Type-Docs,OpSys-All\"" +
-    " pkg/yasnippet-doc-#{$version}.tar.bz2"
-  FileUtils.cp "yasnippet-bundle.el", "pkg/yasnippet-bundle-#{$version}.el"
-  sh "echo for ELPA | mutt -a pkg/yasnippet-bundle-#{$version}.el -s " +
-     "'YASnippet bundle v#{$version}' elpa@tromey.com"
+task :release => [:package, 'doc:archive'] do
+  raise "Not implemented for github yet!"
 end
 
-rule '.html' => '.rst' do |t|
-  sh "doc/compile-doc.py #{t.source} > #{t.name}"
-end
 desc "Generate document"
-task :doc => FileList['doc/*.rst'].ext('html')
+task :doc, [:htmlize] do |t, args|
+  load_path = '-L .'
+  if args[:htmlize]
+    load_path += " -L #{args[:htmlize]}"
+  end
+  sh "#{$EMACS} -Q #{load_path} --batch -l doc/yas-doc-helper.el" +
+    " -f yas--generate-html-batch"
+end
 
 namespace :doc do
   task :archive do
@@ -67,13 +61,52 @@ namespace :doc do
     sh "tar cjf pkg/yasnippet-doc-#{$version}.tar.bz2 " +
       "--exclude=doc/.svn --exclude=doc/images/.svn doc/*.html doc/images"
   end
+
+  task :upload do
+    if File.exists? 'doc/gh-pages'
+      Dir.chdir 'doc/gh-pages' do
+        sh "git checkout gh-pages"
+      end
+      Dir.glob("doc/*.{html,css}").each do |file|
+        FileUtils.cp file, 'doc/gh-pages'
+      end
+      Dir.glob("doc/images/*").each do |file|
+        FileUtils.cp file, 'doc/gh-pages/images'
+      end
+      Dir.glob("doc/stylesheets/*.css").each do |file|
+        FileUtils.cp file, 'doc/gh-pages/stylesheets'
+      end
+      curRev = `git rev-parse --verify HEAD`.chomp()
+      expRev = IO.read('doc/html-revision').chomp()
+      if curRev != expRev
+        raise ("The HTML rev: #{expRev},\n" +
+               "current  rev: #{curRev}!\n")
+      end
+      if !system "git diff-index --quiet HEAD"
+        system "git status --untracked-files=no"
+        raise "You have uncommitted changes!"
+      end
+      Dir.chdir 'doc/gh-pages' do
+        sh "git commit -a -m 'Automatic documentation update.\n\n" +
+          "From #{curRev.chomp()}'"
+        sh "git push"
+      end
+    end
+  end
 end
 
-desc "Compile yasnippet.el into yasnippet.elc" 
+desc "Compile yasnippet.el into yasnippet.elc"
 
 rule '.elc' => '.el' do |t|
-  sh "emacs --batch -L . --eval \"(byte-compile-file \\\"#{t.source}\\\")\""
+  sh "#{$EMACS} --batch -L . --eval \"(setq byte-compile-error-on-warn t)\"" +
+     " -f batch-byte-compile #{t.source}"
 end
-task :compile => FileList["yasnippet.el", "dropdown-list.el"].ext('elc')
+task :compile => FileList["yasnippet.el"].ext('elc')
 
 task :default => :doc
+
+desc "use yasmate to convert textmate bundles"
+task :convert_bundles do
+      cd "yasmate"
+      sh "rake convert_bundles"
+    end