Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add batch operation, so md-readme can be used from Makefiles. Provide…

… sample Makefile.
  • Loading branch information...
commit df989ca82781839b701df4cf9ee202ab983fb29a 1 parent afef9b7
@hober hober authored
Showing with 25 additions and 2 deletions.
  1. +12 −0 Makefile
  2. +13 −2 md-readme.el
View
12 Makefile
@@ -0,0 +1,12 @@
+EMACS = emacs
+
+# Here's a sample rule for another project. Just change md-readme.el to
+# the name of your elisp file. It needs md-readme.el is in your
+# load-path, but allows you to pass LOAD_PATH to make. In our case, a
+# simple "make LOAD_PATH=." should do the trick.
+
+README.md: md-readme.el
+ @$(EMACS) -q --no-site-file -batch \
+ -eval "(mapc (lambda (dir) (add-to-list 'load-path dir)) (parse-colon-path (getenv \"LOAD_PATH\")))" \
+ -l md-readme \
+ -f mdr-generate-batch $< $@
View
15 md-readme.el
@@ -64,14 +64,25 @@
;; 2009-11: First release.
;;; Code:
-(defun mdr-generate ()
+(defun mdr-generate (&optional out-filename)
"Generate README.md from the header of the current file."
(interactive)
(let ((header (mdr-extract-header)))
- (with-temp-file "README.md"
+ (with-temp-file (or out-filename "README.md")
(insert header)
(mdr-convert-header))))
+(defun mdr-generate-batch ()
+ "Generate README.md from elisp files on the command line.
+Takes two command line arguments: the elisp filename, and the target
+Markdown filename (which defaults to 'README.md'."
+ (let ((in-filename (expand-file-name (or (car command-line-args-left) "")))
+ (out-filename (expand-file-name (or (cadr command-line-args-left) "README.md"))))
+ (message "Generating %s from %s..." out-filename in-filename)
+ (with-current-buffer (find-file in-filename)
+ (mdr-generate out-filename))
+ (setq command-line-args-left (cddr command-line-args-left))))
+
(defun mdr-convert-header ()
"Convert the header to Markdown.
This function transforms the header in-place, so be sure to
Please sign in to comment.
Something went wrong with that request. Please try again.