Mercurial > hg > octave-nkf
annotate src/mkgendoc @ 12121:87237a866c71 release-3-2-x
this branch is no longer maintained and is closed for further development
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 22 Jan 2011 01:00:54 -0500 |
parents | 71fca0fc2436 |
children | 0d4613a736e9 |
rev | line source |
---|---|
3295 | 1 #! /bin/sh |
7019 | 2 # |
8920 | 3 # Copyright (C) 1999, 2000, 2002, 2003, 2005, 2006, 2007, 2008, |
4 # 2009 John W. Eaton | |
7019 | 5 # |
6 # This file is part of Octave. | |
7 # | |
8 # Octave is free software; you can redistribute it and/or modify it | |
9 # under the terms of the GNU General Public License as published by the | |
10 # Free Software Foundation; either version 3 of the License, or (at | |
11 # your option) any later version. | |
12 # | |
13 # Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 # for more details. | |
17 # | |
18 # You should have received a copy of the GNU General Public License | |
19 # along with Octave; see the file COPYING. If not, see | |
20 # <http://www.gnu.org/licenses/>. | |
3295 | 21 |
4299 | 22 SED=${SED:-'sed'} |
23 | |
3295 | 24 if test $# -ne 1; then |
25 echo "usage: mkgendoc f1" 1>&2 | |
26 exit 1 | |
27 fi | |
28 | |
29 DOC_FILES=`cat $1` | |
30 | |
31 if test -z "$DOC_FILES"; then | |
32 echo "mkgendoc: DOC_FILES is empty!" 1>&2 | |
33 exit 1 | |
34 fi | |
35 | |
36 cat << \EOF | |
3364 | 37 // DO NOT EDIT! Generated automatically by mkgendoc |
3295 | 38 |
4279 | 39 #if defined (__DECCXX) |
40 #define __USE_STD_IOSTREAM | |
41 #endif | |
42 | |
3543 | 43 #include <iostream> |
3295 | 44 #include <string> |
45 | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
46 #define XDEFUN_FILE_NAME(name) \ |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
47 std::string file_name = name; |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
48 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
49 #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
50 print_doc_string (#name, file_name, doc); |
3364 | 51 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
52 #define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
53 print_doc_string (name, file_name, doc); |
5796 | 54 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
55 #define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
56 print_doc_string (#name, file_name, doc); |
3295 | 57 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
58 #define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
59 print_doc_string (#name, file_name, doc); |
4234 | 60 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
61 #define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
62 print_doc_string (name, file_name, doc); |
3746 | 63 |
3295 | 64 #define XDEFALIAS_INTERNAL(alias, name) |
65 | |
66 #define XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
67 print_doc_string (#name, file_name, doc); |
3295 | 68 |
3321 | 69 #define XDEFCONST_INTERNAL(name, defn, doc) \ |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
70 print_doc_string (#name, file_name, doc); |
3295 | 71 |
72 static void | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
73 print_doc_string (const std::string& name, const std::string& file_name, |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
74 const std::string& doc) |
3295 | 75 { |
3553 | 76 std::cout << ""; |
3321 | 77 |
78 size_t len = name.length (); | |
79 | |
80 if (name[0] == '"' && name[len-1] == '"') | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
81 std::cout << name.substr (1, len-2) << "\n"; |
3321 | 82 else |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
83 std::cout << name << "\n"; |
3321 | 84 |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
85 std::cout << "@c " << file_name << "\n" |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
86 << doc << "\n"; |
3295 | 87 } |
88 | |
89 EOF | |
90 | |
91 for file in $DOC_FILES; do | |
4299 | 92 fcn=`echo $file | $SED 's,^\./,,; s/\.df//; s/-/_/g'` |
3295 | 93 echo "static void" |
94 echo "print_${fcn}_doc_strings (void)" | |
95 echo "{" | |
96 cat $file | |
97 echo "}" | |
98 echo "" | |
99 done | |
100 | |
101 cat << \EOF | |
102 | |
103 int | |
104 main (void) | |
105 { | |
5333 | 106 std::cout |
107 << "### DO NOT EDIT!\n" | |
108 << "###\n" | |
109 << "### This file is generated automatically from the Octave sources.\n" | |
110 << "### Edit those files instead and run make to update this file.\n" | |
111 << std::endl; | |
112 | |
3295 | 113 EOF |
114 | |
115 for file in $DOC_FILES; do | |
4299 | 116 fcn=`echo $file | $SED 's,^\./,,; s/\.df//; s/-/_/g'` |
3295 | 117 echo " print_${fcn}_doc_strings ();" |
118 done | |
119 | |
120 cat << \EOF | |
121 | |
122 return 0; | |
123 } | |
124 EOF | |
125 | |
126 exit 0 |