1 ;;; extract-c-doc.scm -- Output Texinfo from "snarffed" C files.
3 ;;; Copyright 2006-2012 Free Software Foundation, Inc.
6 ;;; This program is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with this program; if not, write to the Free Software
18 ;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ;;; Written by Ludovic Courtès <ludo@chbouib.org>.
22 (use-modules (system documentation c-snarf)
23 (system documentation output)
27 (define (main file cpp+args cpp-flags . procs)
30 ;; 1. C file to be processed;
31 ;; 2. how to invoke the CPP (e.g., "cpp -E");
32 ;; 3. additional CPP flags (e.g., "-I /usr/local/include");
33 ;; 4. optionally, a list of Scheme procedure names whose documentation is
34 ;; to be output. If no such list is passed, then documentation for
35 ;; all the Scheme functions available in the C source file is issued.
37 (let* ((cpp+args (string-tokenize cpp+args))
39 (cpp-flags (append (cdr cpp+args)
40 (string-tokenize cpp-flags)
41 (list "-DSCM_MAGIC_SNARF_DOCS "))))
42 ;;(format (current-error-port) "cpp-flags: ~a~%" cpp-flags)
43 (format (current-error-port) "extracting Texinfo doc from `~a'... "
46 ;; Don't mention the name of C functions.
47 (*document-c-functions?* #f)
50 (run-cpp-and-extract-snarfing file cpp cpp-flags)))
51 (display "@c Automatically generated, do not edit.\n")
52 (display (string-concatenate
53 (map procedure-texi-documentation
56 (filter (lambda (proc-doc)
60 (member proc-name procs)))
62 (format (current-error-port) "done.~%")