mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
guile-tools is a scheme script that loads scheme modules
* meta/guile-tools: Changed to be a scheme script. Instead of looking for executables in a "scripts dir", we just look for modules in (scripts), and load the modules directly. * module/Makefile.am: * module/scripts/: Move the scripts into module/ so they can be compiled. Rename scripts from `foo' to `foo.scm'. * libguile/Makefile.am: Invoke the snarf->texi code via guile-tools. * configure.in: * .gitignore: Update for changes.
This commit is contained in:
parent
798244609b
commit
6d66647d5b
30 changed files with 134 additions and 290 deletions
83
module/scripts/snarf-guile-m4-docs.scm
Normal file
83
module/scripts/snarf-guile-m4-docs.scm
Normal file
|
@ -0,0 +1,83 @@
|
|||
;;; snarf-guile-m4-docs --- Parse guile.m4 comments for texi documentation
|
||||
|
||||
;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this software; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301 USA
|
||||
|
||||
;;; Author: Thien-Thi Nguyen <ttn@gnu.org>
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Usage: snarf-guile-m4-docs FILE
|
||||
;;
|
||||
;; Grep FILE for comments preceding macro definitions, massage
|
||||
;; them into valid texi, and display to stdout. For each comment,
|
||||
;; lines preceding "^# Usage:" are discarded.
|
||||
;;
|
||||
;; TODO: Generalize.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-module (scripts snarf-guile-m4-docs)
|
||||
:use-module (ice-9 rdelim)
|
||||
:export (snarf-guile-m4-docs))
|
||||
|
||||
(define (display-texi lines)
|
||||
(display "@deffn {Autoconf Macro}")
|
||||
(for-each (lambda (line)
|
||||
(display (cond ((and (>= (string-length line) 2)
|
||||
(string=? "# " (substring line 0 2)))
|
||||
(substring line 2))
|
||||
((string=? "#" (substring line 0 1))
|
||||
(substring line 1))
|
||||
(else line)))
|
||||
(newline))
|
||||
lines)
|
||||
(display "@end deffn")
|
||||
(newline) (newline))
|
||||
|
||||
(define (prefix? line sub)
|
||||
(false-if-exception
|
||||
(string=? sub (substring line 0 (string-length sub)))))
|
||||
|
||||
(define (massage-usage line)
|
||||
(let loop ((line (string->list line)) (acc '()))
|
||||
(if (null? line)
|
||||
(list (list->string (reverse acc)))
|
||||
(loop (cdr line)
|
||||
(cons (case (car line)
|
||||
((#\( #\) #\,) #\space)
|
||||
(else (car line)))
|
||||
acc)))))
|
||||
|
||||
(define (snarf-guile-m4-docs . args)
|
||||
(let* ((p (open-file (car args) "r"))
|
||||
(next (lambda () (read-line p))))
|
||||
(let loop ((line (next)) (acc #f))
|
||||
(or (eof-object? line)
|
||||
(cond ((prefix? line "# Usage:")
|
||||
(loop (next) (massage-usage (substring line 8))))
|
||||
((prefix? line "AC_DEFUN")
|
||||
(display-texi (reverse acc))
|
||||
(loop (next) #f))
|
||||
((and acc (prefix? line "#"))
|
||||
(loop (next) (cons line acc)))
|
||||
(else
|
||||
(loop (next) #f)))))))
|
||||
|
||||
(define main snarf-guile-m4-docs)
|
||||
|
||||
;;; snarf-guile-m4-docs ends here
|
Loading…
Add table
Add a link
Reference in a new issue