get-info.ss
#lang scheme

;; Extracts cross-ref info from the installed documentation.
;; (Relies on the details of Setup PLT's cross-reference format.)

(require setup/dirs
         scheme/fasl)

(for-each (lambda (doc)
            (printf " Checking ~a info...\n" doc)
            (let ([in (build-path (find-doc-dir) doc "out.sxref")]
                  [dest (format "~a.info" doc)])
              (when ((file-or-directory-modify-seconds in #f (lambda () +inf.0))
                     . > . 
                     (file-or-directory-modify-seconds dest #f (lambda () -inf.0)))
                (let ([v (cadr (call-with-input-file* in fasl->s-exp))])
                  (printf "   updating\n")
                  (with-output-to-file dest
                    #:exists 'truncate/replace
                    (lambda ()
                      (printf "~s\n" v)))))))
          '("reference" "scribble" "htdp-langs"))