summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-04-28 11:10:09 +0200
committerRicardo Wurmus <rekado@elephly.net>2021-04-28 11:10:09 +0200
commitdf2e1dc8bc18b8b8aaa06c23b2066a5db6822eed (patch)
tree8eef2e8333c057e4cf79ef044c3675589c5e13ef
parent7f8613cb088f0df0b1979620f36686aea1300465 (diff)
doc: Generalize snarf helper script.
-rw-r--r--Makefile.am9
-rw-r--r--doc/snarf.scm38
2 files changed, 28 insertions, 19 deletions
diff --git a/Makefile.am b/Makefile.am
index 9696eda..f00268d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,9 +56,10 @@ AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)"
AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)"
+BUILT_SOURCES = drmaa/v1/ffi.scm doc/low.texi
-doc/low.texi: drmaa/v1/low.go
- $(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE) doc/snarf.scm
+$(top_builddir)/doc/low.texi: drmaa/v1/low.go
+ $(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE) --no-auto-compile -e main $(top_srcdir)/doc/snarf.scm "(drmaa v1 low)" "$@"
info_TEXINFOS = doc/drmaa.texi
drmaa_TEXINFOS = doc/low.texi
@@ -72,6 +73,7 @@ EXTRA_DIST += README.org \
AUTHORS \
ChangeLog \
guix.scm \
+ doc/snarf.scm \
build-aux/test-driver.scm \
configure.ac \
Makefile.am \
@@ -97,7 +99,6 @@ clean-go:
.NOTPARALLEL:
CLEANFILES = \
- doc/low.texi \
- drmaa/v1/ffi.scm \
+ $(BUILT_SOURCES) \
$(GOBJECTS) \
$(TESTS:tests/%.scm=%.log)
diff --git a/doc/snarf.scm b/doc/snarf.scm
index 5dd2f7d..15088c0 100644
--- a/doc/snarf.scm
+++ b/doc/snarf.scm
@@ -78,27 +78,35 @@
(string-upcase (symbol->string sym)))
(resolve-interface module)))
(let ((unsorted
- (module-map
- (lambda (sym var)
- (let ((proc (variable-ref var)))
- (cons sym (format #false
- "\
+ (filter identity
+ (module-map
+ (lambda (sym var)
+ (false-if-exception
+ (let ((proc (variable-ref var)))
+ (cons sym (format #false
+ "\
@cindex ~a
@deffn {Scheme Procedure} ~a ~a
~a
@end deffn
" sym sym
- (arguments->string proc)
- (fancy-docstring proc known-procedures)))))
- (resolve-interface module))))
+(arguments->string proc)
+(fancy-docstring proc known-procedures))))))
+ (resolve-interface module)))))
(sort unsorted (lambda (a b)
(string< (symbol->string (car a))
(symbol->string (car b)))))))
-(with-output-to-file "doc/low.texi"
- (lambda ()
- (for-each (match-lambda
- ((sym . doc)
- (display doc)
- (newline)))
- (docs '(drmaa v1 low)))))
+(define (main . args)
+ (match (command-line)
+ ((_ module file)
+ (let ((directory (dirname file)))
+ (unless (file-exists? directory)
+ (mkdir directory)))
+ (with-output-to-file file
+ (lambda ()
+ (for-each (match-lambda
+ ((sym . doc)
+ (display doc)
+ (newline)))
+ (docs (call-with-input-string module read))))))))