aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgenerate-ttl-files.scm60
1 files changed, 60 insertions, 0 deletions
diff --git a/generate-ttl-files.scm b/generate-ttl-files.scm
new file mode 100755
index 0000000..65db03f
--- /dev/null
+++ b/generate-ttl-files.scm
@@ -0,0 +1,60 @@
+#! ./pre-inst-env
+!#
+(use-modules (ice-9 format)
+ (ice-9 futures)
+ (ice-9 getopt-long)
+ (ice-9 ftw))
+
+(let* ((option-spec
+ '((settings (single-char #\s) (value #t))
+ (output (single-char #\o) (value #t))
+ (documentation (single-char #\d) (value #t))))
+ (options (getopt-long (command-line) option-spec))
+ (settings (option-ref options 'settings #f))
+ (output (option-ref options 'output #f))
+ (documentation (option-ref options 'documentation #f)))
+ (define (enter? name stat result)
+ stat result ;ignore
+ ;; Skip version control directories if any.
+ (not (member (basename name) '(".git" ".svn" "CVS"))))
+
+ (define (leaf name stat result)
+ stat result ;ignore
+ (when (string-suffix? ".scm" name)
+ (let* ((base-file-name (basename name ".scm"))
+ (cmd (format #f " ~a --settings ~a --output ~a --documentation ~a"
+ name
+ settings
+ (string-append output "/" base-file-name ".ttl")
+ (string-append documentation "/" base-file-name ".md"))))
+ (touch
+ (future
+ (begin
+ (display (format #f "Running ~a" cmd))
+ (display "\n")
+ (system cmd)))))))
+
+ (define (down name stat result)
+ name stat ;ignore
+ result)
+
+ (define (up name stat result)
+ name stat ;ignore
+ result)
+
+ (define (skip name stat result)
+ name stat ;ignore
+ result)
+
+ ;; Ignore unreadable files/directories but warn the user.
+ (define (error name stat errno result)
+ stat ;ignore
+ (format (current-error-port) "warning: ~a: ~a~%"
+ name (strerror errno))
+ result)
+
+ (file-system-fold enter? leaf down up skip error
+ 0 ;initial counter is zero bytes
+ "./examples"))
+
+