From ab416f759f860ce25788bf618ff1538f5d523116 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 5 Mar 2010 22:08:40 -0500 Subject: Updated copyrights to 2003-2010 --- doc/ledger.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/ledger.texi b/doc/ledger.texi index 3b0785eb..43a4389d 100644 --- a/doc/ledger.texi +++ b/doc/ledger.texi @@ -5,7 +5,7 @@ @dircategory User Applications @copying -Copyright (c) 2003-2009, John Wiegley. All rights reserved. +Copyright (c) 2003-2010, John Wiegley. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are -- cgit v1.2.3 From dc1b3907207cc5ccf3d27a01aa877e841bf7ac6f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 5 Mar 2010 22:09:26 -0500 Subject: Make the manual encoding be utf-8 --- doc/ledger.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/ledger.texi b/doc/ledger.texi index 43a4389d..6573a066 100644 --- a/doc/ledger.texi +++ b/doc/ledger.texi @@ -35,7 +35,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @end copying -@documentencoding iso-8859-1 +@documentencoding utf-8 @iftex @finalout -- cgit v1.2.3 From 87ad6f52f8089d9cd8a9ba3889151ad835a8dd0a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 15 Mar 2010 01:27:52 -0400 Subject: ldg-texi.el now auto-generates regression tests --- doc/ledger.texi | 15 +++++++++++++ lisp/ldg-texi.el | 67 +++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 64 insertions(+), 18 deletions(-) (limited to 'doc') diff --git a/doc/ledger.texi b/doc/ledger.texi index 6573a066..10e80a60 100644 --- a/doc/ledger.texi +++ b/doc/ledger.texi @@ -4107,4 +4107,19 @@ parser_t @section General Utility +@c data: foo +@smallexample +2004/05/01 * Checking balance + Assets:Bank:Checking $1,000.00 + Equity:Opening Balances +@end smallexample + +@c smex utility-1: $LEDGER -f $foo bal +@smallexample + $1,000.00 Assets:Bank:Checking + $-1,000.00 Equity:Opening Balances +-------------------- + 0 +@end smallexample + @bye diff --git a/lisp/ldg-texi.el b/lisp/ldg-texi.el index b621ee83..0810369b 100644 --- a/lisp/ldg-texi.el +++ b/lisp/ldg-texi.el @@ -2,14 +2,16 @@ (defvar ledger-sample-doc-path "/Users/johnw/src/ledger/doc/sample.dat") (defvar ledger-normalization-args "--args-only --columns 80") -(defun ledger-texi-expand-examples () +(defun ledger-texi-update-examples () (interactive) (save-excursion (goto-char (point-min)) - (while (re-search-forward "^@c \\(\\(?:small\\)?example\\): \\(.*\\)" nil t) + (while (re-search-forward "^@c \\(\\(?:sm\\)?ex\\) \\(\\S-+\\): \\(.*\\)" nil t) (let ((section (match-string 1)) - (command (match-string 2)) - (data-file ledger-sample-doc-path)) + (example-name (match-string 2)) + (command (match-string 3)) expanded-command + (data-file ledger-sample-doc-path) + input output) (goto-char (match-end 0)) (forward-line) (when (looking-at "@\\(\\(?:small\\)?example\\)") @@ -28,35 +30,64 @@ (search-forward (format "@c data: %s" label)) (re-search-forward "@\\(\\(?:small\\)?example\\)") (forward-line) - (let ((beg (point)) - content) + (let ((beg (point))) (re-search-forward "@end \\(\\(?:small\\)?example\\)") - (setq content (buffer-substring-no-properties + (setq input (buffer-substring-no-properties beg (match-beginning 0))) (with-current-buffer (find-file-noselect data-file) (erase-buffer) - (insert content) + (insert input) (save-buffer)))))) - (if (string-match "\\$LEDGER" command) - (setq command + (setq expanded-command command) + (if (string-match "\\$LEDGER" expanded-command) + (setq expanded-command (replace-match (format "%s -f \"%s\" %s" ledger-path data-file ledger-normalization-args) - t t command))) + t t expanded-command))) (save-restriction (narrow-to-region (point) (point)) - (shell-command command t (get-buffer-create " *ldg-texi*")) + (shell-command expanded-command t (get-buffer-create " *ldg-texi*")) (if (= (point-min) (point-max)) (progn (push-mark nil t) (message "Command '%s' yielded no result at %d" - command (point)) + expanded-command (point)) (ding)) + (setq output (buffer-string)) (goto-char (point-min)) - (insert "@" section ?\n) - (goto-char (point-max)) - (unless (eolp) - (insert ?\n)) - (insert "@end " section ?\n))))))) + (let ((section-name (if (string= section "smex") + "smallexample" + "example"))) + (insert "@" section-name ?\n) + (goto-char (point-max)) + (unless (eolp) + (insert ?\n)) + (insert "@end " section-name ?\n)))) + + ;; Update the regression test associated with this example + + (with-current-buffer + (find-file-noselect + (expand-file-name (concat example-name ".test") + "../test/manual")) + (erase-buffer) + (let ((case-fold-search nil)) + (if (string-match "\\$LEDGER\\s-+" command) + (setq command (replace-match "" t t command))) + (if (string-match " -f \\$\\([-a-z]+\\)" command) + (setq command (replace-match "" t t command)))) + + (insert command ?\n) + (insert "<<<" ?\n) + (insert input) + (insert ">>>1" ?\n) + (insert output) + (insert ">>>2" ?\n) + (insert "=== 0" ?\n) + (save-buffer) + (kill-buffer (current-buffer))))))) + +(provide 'ldg-texi) -- cgit v1.2.3