|
Packit Service |
4684c1 |
;;; extract-c-doc.scm -- Output Texinfo from "snarffed" C files.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; Copyright 2006-2012 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
4684c1 |
;;; it under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
;;; the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
;;; (at your option) any later version.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; This program is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
4684c1 |
;;; GNU General Public License for more details.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; You should have received a copy of the GNU General Public License
|
|
Packit Service |
4684c1 |
;;; along with this program; if not, write to the Free Software
|
|
Packit Service |
4684c1 |
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
;;; Written by Ludovic Courtès <ludo@chbouib.org>.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(use-modules (system documentation c-snarf)
|
|
Packit Service |
4684c1 |
(system documentation output)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(srfi srfi-1))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(define (main file cpp+args cpp-flags . procs)
|
|
Packit Service |
4684c1 |
;; Arguments:
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
;; 1. C file to be processed;
|
|
Packit Service |
4684c1 |
;; 2. how to invoke the CPP (e.g., "cpp -E");
|
|
Packit Service |
4684c1 |
;; 3. additional CPP flags (e.g., "-I /usr/local/include");
|
|
Packit Service |
4684c1 |
;; 4. optionally, a list of Scheme procedure names whose documentation is
|
|
Packit Service |
4684c1 |
;; to be output. If no such list is passed, then documentation for
|
|
Packit Service |
4684c1 |
;; all the Scheme functions available in the C source file is issued.
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
(let* ((cpp+args (string-tokenize cpp+args))
|
|
Packit Service |
4684c1 |
(cpp (car cpp+args))
|
|
Packit Service |
4684c1 |
(cpp-flags (append (cdr cpp+args)
|
|
Packit Service |
4684c1 |
(string-tokenize cpp-flags)
|
|
Packit Service |
4684c1 |
(list "-DSCM_MAGIC_SNARF_DOCS "))))
|
|
Packit Service |
4684c1 |
;;(format (current-error-port) "cpp-flags: ~a~%" cpp-flags)
|
|
Packit Service |
4684c1 |
(format (current-error-port) "extracting Texinfo doc from `~a'... "
|
|
Packit Service |
4684c1 |
file)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
;; Don't mention the name of C functions.
|
|
Packit Service |
4684c1 |
(*document-c-functions?* #f)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(let ((proc-doc-list
|
|
Packit Service |
4684c1 |
(run-cpp-and-extract-snarfing file cpp cpp-flags)))
|
|
Packit Service |
4684c1 |
(display "@c Automatically generated, do not edit.\n")
|
|
Packit Service |
4684c1 |
(display (string-concatenate
|
|
Packit Service |
4684c1 |
(map procedure-texi-documentation
|
|
Packit Service |
4684c1 |
(if (null? procs)
|
|
Packit Service |
4684c1 |
proc-doc-list
|
|
Packit Service |
4684c1 |
(filter (lambda (proc-doc)
|
|
Packit Service |
4684c1 |
(let ((proc-name
|
|
Packit Service |
4684c1 |
(assq-ref proc-doc
|
|
Packit Service |
4684c1 |
'scheme-name)))
|
|
Packit Service |
4684c1 |
(member proc-name procs)))
|
|
Packit Service |
4684c1 |
proc-doc-list))))))
|
|
Packit Service |
4684c1 |
(format (current-error-port) "done.~%")
|
|
Packit Service |
4684c1 |
(exit 0)))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
;;; Local Variables:
|
|
Packit Service |
4684c1 |
;;; mode: scheme
|
|
Packit Service |
4684c1 |
;;; coding: latin-1
|
|
Packit Service |
4684c1 |
;;; End:
|