~ chicken-core (chicken-5) /scripts/compare-documentation-exports.scm
Trap1;; This script takes a filename as its first argument, which should be a file2;; consisting of multiple lists in this format: ((module name) exported-symbol ...)3;; It imports the specified module and checks that the export list of the module matches4;; with the one supplied in the file.5;; This is useful to check that the documentation and module exports are synchronized.67;; TODO make the script read svn-wiki syntax directly89(import chicken.sort srfi-1)1011(define *exit-code* 0)1213(define (warn msg . args)14 (apply fprintf (current-error-port)15 msg args)16 (set! *exit-code* 1))1718(define (module-exports mod)19 (receive (_ ve se) (##sys#module-exports mod)20 (sort (append (map car ve) (map car se)) symbol<?)))2122(define (symbol<? s1 s2)23 (string<? (symbol->string s1)24 (symbol->string s2)))2526(define (check-module name exports)27 (eval `(import ,name))28 (let* ((exports (sort exports symbol<?))29 (canonical-name30 (string->symbol31 (string-intersperse (map ->string name) ".")))32 (mod (##sys#find-module canonical-name))33 (mod-exports (module-exports mod))34 (diff (lset-difference eqv? exports mod-exports)))35 (unless (null? diff)36 (warn "Mismatch is ~a: ~a~%"37 name diff))))3839(define (run-checks filename)40 (with-input-from-file filename41 (lambda ()42 (port-for-each check read))))4344(define (check desc)45 (check-module (car desc) (cdr desc)))4647(run-checks (car (command-line-arguments)))4849(exit *exit-code*)