From f84910bf7fc65c1214215df449caf67e9757a0a8 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Tue, 4 Nov 2008 10:32:58 +0000 Subject: [PATCH] Some mods on capone-doc Added slet --- tools/capone/lib/common.ss | 30 +++++++++++++++++++++ tools/capone/src/capone-doc | 54 ++++++++++++++++++++++++++----------- tools/capone/src/capone.cpp | 2 +- 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/tools/capone/lib/common.ss b/tools/capone/lib/common.ss index edde865..9b6d82a 100644 --- a/tools/capone/lib/common.ss +++ b/tools/capone/lib/common.ss @@ -87,6 +87,36 @@ (else (throw "Unsupported type in 'for' loop")))))) +;; +;; Split a list to a list of pairs so we can easily +;; embed it in 'let' expression via 'slet' macro +;; e.g. (1 2 3 4) => ((1 2) (3 4)) +;; +(define (explode-list lst) + (let loop ((lst lst) + (n '())) + (if (null? lst) + (reverse n) + (begin + ;; huh... + (set! n (cons (list (car lst) (cadr lst)) n)) + (loop (cddr lst) n) +)))) + +;; +;; slet or 'simplified let' is a 'let' with little less bracess +;; e.g. (let (a 1 b 2) body) +;; +(define-macro (slet . body) + `(let ,@(list (explode-list (car body))) + ,@(cdr body) +)) + +(define-macro (slet* . body) + `(let* ,@(list (explode-list (car body))) + ,@(cdr body) +)) + ;; ;; range function; returns a list of numbers in form [start end) ;; diff --git a/tools/capone/src/capone-doc b/tools/capone/src/capone-doc index 453c337..b09caaf 100755 --- a/tools/capone/src/capone-doc +++ b/tools/capone/src/capone-doc @@ -10,41 +10,56 @@ sub write_prolog { $_[0] - + +
EOL } sub write_epilog { print < @@ -53,7 +68,7 @@ EOL sub main { if(@ARGV eq 0) { - print "Usage: capone-doc [FILE]\n"; + print "Usage: capone-doc [FILE] [TITLE]\n"; print "Generate html-ized documentation by extracting documentation\n"; print "specific tags on the specific manner from capone source file\n"; return; @@ -62,20 +77,25 @@ sub main { $in_block = 0; $filename = $ARGV[0]; + if($ARGV[1] eq "") { + $title = $filename . " documentation"; + } else { + $title = $ARGV[1]; + } + open(INFILE, $filename) or die "Can't open $filename: $!"; - &write_prolog($filename); + &write_prolog($title); while() { # find markers if(/^;;=/) { if($in_block eq 0) { - print "
\n"; + print "
\n"; $in_block = 1; } else { - print "
\n"; + print "
\n"; print "
\n"; - print "
-- ∂ --
\n"; $in_block = 0; } @@ -86,7 +106,6 @@ sub main { if($in_block eq 1) { # strip comments s/;;\s*\n$/
\n/; - #s/;;\s*//; s/;;//; # \code and \endcode @@ -102,6 +121,9 @@ sub main { # \return s/\\return (.*)/ returns:<\/b> $1
/; + # \syntax + s/\\syntax (.*)/ syntax:<\/b> $1<\/i>
/; + # \br s/\\br/
/g; diff --git a/tools/capone/src/capone.cpp b/tools/capone/src/capone.cpp index 2d4696e..3f6ca96 100644 --- a/tools/capone/src/capone.cpp +++ b/tools/capone/src/capone.cpp @@ -149,7 +149,7 @@ int main(int argc, char** argv) { do_file_or_expr(f, NULL, l, argc, argv); fclose(f); } else { - printf("\033[33mcapone " VERSION "\033[0m (based on tinyscheme 1.39)\n"); + printf("capone " VERSION " (based on tinyscheme 1.39)\n"); printf("Type \"(quit)\" or press Ctrl-C to exit interpreter when you are done."); do_file_or_expr(stdin, NULL, l, argc, argv); }