publish org doc from Rakefile

This commit is contained in:
Noam Postavsky 2013-11-26 21:47:47 -05:00
parent 07b1d3925c
commit fd3fa39444
2 changed files with 41 additions and 16 deletions

View File

@ -54,11 +54,11 @@ task :release => [:package, 'doc:archive'] do
raise "Not implemented for github yet!" raise "Not implemented for github yet!"
end end
rule '.html' => '.rst' do |t|
sh "doc/compile-doc.py #{t.source} > #{t.name}"
end
desc "Generate document" desc "Generate document"
task :doc => FileList['doc/*.rst'].ext('html') task :doc do
sh "#{$EMACS} -Q -L . --batch -l doc/yas-doc-helper.el" +
" -f yas--generate-html-batch"
end
namespace :doc do namespace :doc do
task :archive do task :archive do
@ -79,8 +79,10 @@ namespace :doc do
Dir.glob("doc/images/*").each do |file| Dir.glob("doc/images/*").each do |file|
FileUtils.cp file, 'doc/gh-pages/images' FileUtils.cp file, 'doc/gh-pages/images'
end end
rev = `git rev-parse --verify HEAD`
Dir.chdir 'doc/gh-pages' do Dir.chdir 'doc/gh-pages' do
sh "git commit -a -m 'Automatic documentation update.'" sh "git commit -a -m 'Automatic documentation update.\n\n" +
"From #{rev.chomp()}'"
sh "git push" sh "git push"
end end
end end

View File

@ -24,6 +24,12 @@
;;; Code: ;;; Code:
(eval-when-compile
(require 'cl))
(require 'org)
(require 'org-publish)
(require 'yasnippet) ; docstrings must be loaded
(defun yas--document-symbol (symbol level) (defun yas--document-symbol (symbol level)
(flet ((concat-lines (&rest lines) (flet ((concat-lines (&rest lines)
(mapconcat #'identity lines "\n"))) (mapconcat #'identity lines "\n")))
@ -94,18 +100,35 @@
;; This lets all the org files be exported to HTML with ;; This lets all the org files be exported to HTML with
;; `org-publish-current-project' (C-c C-e P). ;; `org-publish-current-project' (C-c C-e P).
(progn
(defvar yas--document-org-project-plist
`(:style
"<link rel='stylesheet' type='text/css' href='stylesheets/styles.css'/>"
:base-directory ,default-directory
:publishing-directory ,default-directory))
(let ((project (assoc "yasnippet" org-publish-project-alist))) (let* ((rev (or (with-temp-buffer
(if project (when (eq (call-process "git" nil t nil
(setcdr project yas--document-org-project-plist) "rev-parse" "--verify" "HEAD") 0)
(push `("yasnippet" . ,yas--document-org-project-plist) (buffer-string)))
org-publish-project-alist)))) yas--version))
(dir (if load-file-name (file-name-directory load-file-name)
default-directory))
(proj-plist
(list
:base-directory dir :publishing-directory dir
:html-postamble
(concat "<hr><p class='creator'>Generated by %c on %d from "
rev "</p>\n"
"<p class='xhtml-validation'>%v</p>\n")))
(project (assoc "yasnippet" org-publish-project-alist)))
(if project
(setcdr project proj-plist)
(push `("yasnippet" . ,proj-plist)
org-publish-project-alist)))
(defun yas--generate-html-batch ()
(let ((org-publish-use-timestamps-flag nil)
(org-export-copy-to-kill-ring nil)
(org-confirm-babel-evaluate nil)
(make-backup-files nil))
(org-publish "yasnippet" 'force)))
(provide 'yas-doc-helper) (provide 'yas-doc-helper)
;;; yas-doc-helper.el ends here ;;; yas-doc-helper.el ends here