HomeAboutCodePastes
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordieggsy <dieggsy@protonmail.com>2020-12-24 09:40:57 -0500
committerdieggsy <dieggsy@protonmail.com>2020-12-24 09:45:15 -0500
commit34fffefe4a4eaf865100c3d4539f3c0476e21fa8 (patch)
treed53b17cdc02fc90276db5a4adceaca8a274e1a49
parentb8cbfdb7b3d0757c7ce8c7c7f956df3d0eb8dac6 (diff)
downloadchicken-chalk-34fffefe4a4eaf865100c3d4539f3c0476e21fa8.tar.gz
Change program license options and license location0.3.3
- Also, a bit of code cleanup - Update docs
-rw-r--r--chalk-bin.scm83
-rw-r--r--chalk.release-info1
-rw-r--r--chalk.svnwiki7
3 files changed, 48 insertions, 43 deletions
diff --git a/chalk-bin.scm b/chalk-bin.scm
index 5135510..5dcd9ad 100644
--- a/chalk-bin.scm
+++ b/chalk-bin.scm
@@ -57,10 +57,13 @@
(required #f)
(single-char #\T)
(value (required FILE)))
- (license "Whether to insert a license"
+ (no-license "Don't insert a license file"
+ (required #f)
+ (single-char #\L))
+ (license "File to use as license (defaults to LICENSE if unspecified)"
(required #f)
- (single-char #\L)
- (value (optional FILE)))
+ (single-char #\l)
+ (value (required FILE)))
(module-headers "Create === Module-name headers"
(required #f)
(single-char #\m))))
@@ -282,6 +285,7 @@
(print-usage))
(define outfile (alist-ref 'output pargs))
(define license (alist-ref 'license pargs))
+(define no-license (alist-ref 'no-license pargs))
(define head (alist-ref 'head pargs))
(define tail (alist-ref 'tail pargs))
(define prologue (alist-ref 'prologue pargs))
@@ -290,6 +294,7 @@
(equal? (pathname-extension f) "egg"))
(directory)))
(define egg-name (if egg-file (pathname-file egg-file) #f))
+(define egg-values (if egg-file (call-with-input-file egg-file (cut read <>)) '()))
(define release-file (if egg-name (make-pathname #f egg-name "release-info")))
(define ignore-egg (alist-ref 'ignore-egg pargs))
(define no-toc (alist-ref 'no-toc pargs))
@@ -312,12 +317,8 @@
(unless no-toc
(printf "[[toc:]]\n"))
(printf "== ~a\n" egg-name)
- (call-with-input-file egg-file
- (lambda (in)
- (let* ((values (read in))
- (synopsis (alist-ref 'synopsis values)))
- (when synopsis
- (printf "~a\n\n" (car synopsis)))))))
+ (and-let* ((synopsis (alist-ref 'synopsis egg-values)))
+ (printf "~a\n\n" (car synopsis))))
(when prologue
(if (file-exists? prologue)
@@ -338,36 +339,17 @@
(warning "Epilogue file not found, skipping...")))
(unless (or ignore-egg (not egg-file))
- (call-with-input-file egg-file
- (lambda (in)
- (let* ((values (read in))
- (author (alist-ref 'author values))
- (maintainer (alist-ref 'maintainer values)))
- (when maintainer
- (printf "=== Maintainer\n")
- (printf "~a\n" (car maintainer)))
- (when author
- (printf "=== Author\n")
- (printf "~a\n" (car author))
- (when email
- (printf "~a\n" email))
- (newline))))))
-
-(when license
- (let ((license-file (or (and (string? license)
- license)
- "LICENSE")))
- (if (file-exists? license-file)
- (begin
- (printf "=== License\n")
- (call-with-input-file license-file
- (lambda (in)
- (let ((str (read-string #f in)))
- (printf str)
- (newline)))))
- (warning "License file not found, skipping..."))))
+ (and-let* ((maintainer (alist-ref 'maintainer egg-values)))
+ (printf "=== Maintainer\n")
+ (printf "~a\n" (car maintainer)))
+ (and-let* ((author (alist-ref 'author egg-values)))
+ (printf "=== Author\n")
+ (printf "~a\n" (car author))
+ (when email
+ (printf "~a\n" email)))
+ (newline))
-(unless (or ignore-egg ignore-release)
+(unless (or ignore-egg (not egg-file) ignore-release)
(if (file-exists? release-file)
(begin
(printf "=== Version History\n")
@@ -392,11 +374,30 @@
descr
(lambda (c)
(or (char-whitespace? c)
- (char=? c #\;)))))))
- )))))
- (loop (read-line in)))))))
+ (char=? c #\;))))))))))))
+ (loop (read-line in))))))
+ (newline))
(warning "release-info file not found, skipping...")))
+(let* ((egg-license (alist-ref 'license egg-values))
+ (license-file (or license "LICENSE"))
+ (license-exists (file-exists? license-file)))
+ (when (or (and (not ignore-egg) egg-license)
+ (and (not no-license) license-exists))
+ (printf "=== License\n"))
+ (unless (or ignore-egg (not egg-file) (not egg-license))
+ (printf "~a\n\n" (car egg-license)))
+ (unless no-license
+ (if license-exists
+ (begin
+ (call-with-input-file license-file
+ (lambda (in)
+ (let loop ((line (read-line in)))
+ (unless (eof-object? line)
+ (printf " ~a\n" line)
+ (loop (read-line in)))))))
+ (warning "License file not found, skipping..."))))
+
(when tail
(if (file-exists? tail)
(call-with-input-file tail
diff --git a/chalk.release-info b/chalk.release-info
index 07339c4..5d21deb 100644
--- a/chalk.release-info
+++ b/chalk.release-info
@@ -1,5 +1,6 @@
;; -*- mode: scheme -*-
(uri targz "https://code.dieggsy.com/chicken-{egg-name}/snapshot/chicken-{egg-name}-{egg-release}.tar.gz")
+(release "0.3.3")
(release "0.3.2")
(release "0.3.1")
(release "0.3.0")
diff --git a/chalk.svnwiki b/chalk.svnwiki
index 70dc177..bc642e5 100644
--- a/chalk.svnwiki
+++ b/chalk.svnwiki
@@ -238,7 +238,8 @@ Usage: chalk [OPTION]... [FILE]...
-P, --prologue=FILE File to add after synopsis
-E, --epilogue=FILE File to add before maintainer info
-T, --tail=FILE File to add to end of documentation
- -L, --license[=FILE] Whether to insert a license
+ -L, --no-license Don't insert a license file
+ -l, --license=FILE File to use as license (defaults to LICENSE if unspecified)
-m, --module-headers Create === Module-name headers
</enscript>
@@ -256,7 +257,9 @@ generating a version history section of the documentation, for example:
=== Full Example
-Coming soon
+See the [[https://code.dieggsy.com/icu/tree/|ICU egg source code]] and
+[[https://wiki.call-cc.org/eggref/5/icu|documentation]] for a full example of a
+project using chalk.
=== Author
Diego A. Mundo