~ chicken-core (chicken-5) 5b9822a1950cc95cc12d847eaeba4caa0479101d
commit 5b9822a1950cc95cc12d847eaeba4caa0479101d Author: Kooda <kooda@upyum.com> AuthorDate: Sat May 5 13:03:44 2018 +0200 Commit: Peter Bex <peter@more-magic.net> CommitDate: Sun May 13 15:33:41 2018 +0200 Add a little script to check the consistency between documentation and actual modules Signed-off-by: Peter Bex <peter@more-magic.net> diff --git a/distribution/manifest b/distribution/manifest index a7fccbbd..55e2f286 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -377,6 +377,7 @@ scripts/chicken-flymake scripts/chicken-flymake.bat scripts/csc-trans scripts/compile-all +scripts/compare-documentation-exports.scm scripts/reconstruct-egg-name.scm scripts/mini-salmonella.scm scripts/make-wrapper.scm diff --git a/scripts/compare-documentation-exports.scm b/scripts/compare-documentation-exports.scm new file mode 100644 index 00000000..0334fc81 --- /dev/null +++ b/scripts/compare-documentation-exports.scm @@ -0,0 +1,49 @@ +;; This script takes a filename as its first argument, which should be a file +;; consisting of multiple lists in this format: ((module name) exported-symbol ...) +;; It imports the specified module and checks that the export list of the module matches +;; with the one supplied in the file. +;; This is useful to check that the documentation and module exports are synchronized. + +;; TODO make the script read svn-wiki syntax directly + +(import chicken.sort srfi-1) + +(define *exit-code* 0) + +(define (warn msg . args) + (apply fprintf (current-error-port) + msg args) + (set! *exit-code* 1)) + +(define (module-exports mod) + (receive (_ ve se) (##sys#module-exports mod) + (sort (append (map car ve) (map car se)) symbol<?))) + +(define (symbol<? s1 s2) + (string<? (symbol->string s1) + (symbol->string s2))) + +(define (check-module name exports) + (eval `(import ,name)) + (let* ((exports (sort exports symbol<?)) + (canonical-name + (string->symbol + (string-intersperse (map ->string name) "."))) + (mod (##sys#find-module canonical-name)) + (mod-exports (module-exports mod)) + (diff (lset-difference eqv? exports mod-exports))) + (unless (null? diff) + (warn "Mismatch is ~a: ~a~%" + name diff)))) + +(define (run-checks filename) + (with-input-from-file filename + (lambda () + (port-for-each check read)))) + +(define (check desc) + (check-module (car desc) (cdr desc))) + +(run-checks (car (command-line-arguments))) + +(exit *exit-code*)Trap