define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / tools / cxref / README.sgml
blob7b2f3c27da6a2990a0276c2b466c78262655cae3
1 <!DOCTYPE LINUXDOC SYSTEM>
3 <!-- cxref program (c) Andrew M. Bishop 1995,96,97,98,99. -->
5 <article>
7 <title>C Cross Referencing &amp; Documenting tool. Version 1.5.
8 <author>Andrew M. Bishop
10 <sect>C Cross Referencing &amp; Documenting tool. Version 1.5 - cxref
12 <p>
13 A program that can automatically generate documentation and cross references for
14 a C program.
15 <newline>
16 The input is any C program with appropriate comments and the output is LaTeX,
17 HTML, RTF or SGML files.
19 <sect1>Program Options
21 <p>
22 The name of the program is cxref.
24 <tscreen><verb>
25 Usage: cxref filename [ ... filename]
26 [-Odirname] [-Nbasename] [-Rdirname]
27 [-all-comments] [-no-comments]
28 [-verbatim-comments] [-block-comments]
29 [-xref[-all][-file][-func][-var][-type]]
30 [-warn[-all][-comment][-xref]]
31 [-index[-all][-file][-func][-var][-type]]
32 [-raw]
33 [-latex209|-latex2e]
34 [-html20|-html32][-src]
35 [-rtf]
36 [-sgml]
37 [-Idirname] [-Ddefine] [-Udefine]
38 [-CPP cpp_program] [-- cpp_arg [ ... cpp_arg]]
40 Usage: cxref filename [ ... filename] -delete
41 [-Odirname] [-Nbasename] [-Rdirname]
42 </verb></tscreen>
44 <descrip>
45 <tag><tt>filename</tt></tag>
46 The name of the file to document, any number of files may be
47 documented at a time.
48 <tag><tt>-delete</tt></tag>
49 The files named are to be deleted from the output directory and
50 their entries in the cross reference database and main output
51 files are to be removed.
52 <tag><tt>-Odirname</tt></tag>
53 The name of a directory to use for the output latex files and
54 the location of the cross reference files that are created.
55 <tag><tt>-Nbasename</tt></tag>
56 The name to use for the first part of the output and cross
57 reference files instead of cxref, the file extensions remain
58 the same.
59 <tag><tt>-Rdirname</tt></tag>
60 When the source files are in more than one directory, set
61 dirname to the name of the root directory of the source tree
62 (use relative path if easier e.g. `-R../..'). This will then
63 run cxref from that root directory and the `-Odirname' must be
64 relative to that directory.
65 <tag><tt>-all-comments</tt></tag>
66 In case you think that the existing comments might work,
67 (see below for description of special comments).
68 <newline><it>[Danger! This option can produce weird results.]</it>
69 <tag><tt>-no-comments</tt></tag>
70 Ignores all comments, useful if you just want the cross
71 references and not the documentation.
72 <tag><tt>-verbatim-comments</tt></tag>
73 When the comments that you have in the code are formatted
74 in a predetermined style that you want to preserve on the
75 output, this option will force them not to be reformatted.
76 <newline><it>[Note, this is for file and function comments only.]</it>
77 <tag><tt>-block-comments</tt></tag>
78 When the comments in the program are formatted in the `block'
79 style (with a leading `*' character on every line), this option
80 will remove that character from the output.
81 <newline><it>[Works for a single `*', `+', `|' or `:' on each line.]</it>
82 <tag><tt>-xref</tt></tag>
83 Produce cross referencing information (see below).
84 <descrip>
85 <tag><tt>-all</tt></tag> All cross references.
86 <tag><tt>-file</tt></tag>Cross references for files.
87 <tag><tt>-func</tt></tag>Cross references for functions.
88 <tag><tt>-var</tt></tag> Cross references for variables.
89 <tag><tt>-type</tt></tag>Cross references for types.
90 </descrip>
91 <tag><tt>-warn</tt></tag>
92 Produce warnings, the options must be concatenated together:
93 <descrip>
94 <tag><tt>-all</tt></tag> All warnings.
95 <tag><tt>-comment</tt></tag>Warn of missing comments.
96 <tag><tt>-xref</tt></tag> Warn of missing cross references.
97 </descrip>
98 <tag><tt>-index</tt></tag>
99 Produce a cross reference index, the options must be
100 concatenated together:
101 <descrip>
102 <tag><tt>-all</tt></tag> All indexes.
103 <tag><tt>-file</tt></tag>Index of files.
104 <tag><tt>-func</tt></tag>Index of functions.
105 <tag><tt>-var</tt></tag> Index of variables.
106 <tag><tt>-type</tt></tag>Index of types.
107 </descrip>
108 <tag><tt>-raw</tt></tag>
109 Produce a raw form of output, not really of much use except
110 with -warn.
111 <tag><tt>-latex209</tt></tag>
112 Produce a LaTeX file to document each of the source files and
113 also an extra file that includes each of these files. (Using
114 the LaTeX version 2.09 format.)
115 <tag><tt>-latex2e</tt></tag>
116 Produce the LaTeX file described above for use with the
117 LaTeX2e version of LaTeX.
118 <tag><tt>-html20</tt></tag>
119 Produce an HTML file to document each of the source files and
120 a main file to reference each of these files. (using the HTML
121 2.0 standard, no tables).
122 <tag><tt>-html32</tt></tag>
123 Produce the HTML file described above but using HTML 3.2.
124 <tag><tt>-rtf</tt></tag>
125 Produce a Rich Text Format (RTF) file to document the source
126 file.
127 <tag><tt>-html20-src</tt></tag>
128 Produce the HTML v2.0 output and a HTML version of the source
129 file with links into it.
130 <tag><tt>-html32-src</tt></tag>
131 Produce the HTML v3.2 output and a HTML version of the source
132 file with links into it.
133 <tag><tt>-sgml</tt></tag>
134 Produce an SGML file to document the source file. (Using the
135 LinuxDoc DTD).
136 <tag><tt>-Idirname</tt></tag>
137 GCC option to specify the path for include files.
138 <tag><tt>-Ddefine</tt></tag>
139 GCC option to define a pre-processor symbol.
140 <tag><tt>-Udefine</tt></tag>
141 GCC option to undefine a pre-processor symbol.
142 <tag><tt>-CPP program</tt></tag>
143 The name of the program to use instead of the compile time
144 default. The program must be able to perform all of the actions
145 that `gcc -E -C -dD' does to work. If the program takes
146 arguments then the whole thing needs to be in quotes so that it
147 is interpreted as a single argument to cxref.
148 <tag><tt>-- arg ... arg</tt></tag>
149 Extra arguments to be passed to the pre-processor can be placed
150 after the `--' separator.
151 </descrip>
153 <sect1>C Compiler Replacement cxref-cc
156 To simplify using cxref on existing source code, there is now a shell script
157 that will call the C compiler and then call cxref to process the source file.
158 This means that it can be used as a drop in replacement for CC in Makefiles and
159 the like.
161 <tscreen><verb>
162 Usage: cxref-cc [usual cc options]
163 </verb></tscreen>
165 The name of the source file is extracted from the list of options as well as the
166 `-D*', `-I*', `-U*' flags and when the C compiler exits succesfully cxref will
167 be called. The name of the C compiler to use is controlled by the CXREFCC
168 environment variable, or if this is not set then the CC environment variable, or
169 failing this just gcc.
171 Using this script requires the use of a `.cxref' configuration file to contain
172 the options since there is nowhere to put the options on the command line for
173 the C compiler.
175 This will only cross-reference and document the C source files since they are
176 the only ones that are compiled, but it will make sure that they are
177 cross-referenced with the correct options etc.
179 <sect1>Cxref configuration File
182 These command line arguments can also be put into a file named `.cxref' instead
183 of on the command line. When cxref is run the arguments to the program are
184 interpreted in the following order.
186 <enum>
187 <item>Those on the command line.
188 <item>Those in the `.cxref' file in the current directory.
189 <item>Those in the `.cxref' file in the source tree root specified by `-R'.
190 </enum>
192 This means that in a multi-directory source tree, each sub-directory can have a
193 `.cxref' file containing just the line `-R..' or appropriate. The main
194 directory can have a `.cxref' file containing the remainder of the options.
195 This removes completely the need to have any options on the command line apart
196 from the source file names.
198 The format of the `.cxref' file is any number of lines, each one containing a
199 single command line argument (equivalent to one of the argv). The only options
200 that cannot be used are the names of source files themselves and the `-delete'
201 option. Blank lines are ignored and lines starting with a '#' are comments.
203 <sect1>Program Documentation Comments
206 The documentation for the program is produced from comments in the code that are
207 appropriately formatted. The cross referencing comes from the code itself and
208 requires no extra work.
209 <newline>
210 The special comments are `/**** ****/' (for a file) and `/*++++ ++++*/' (for a
211 data object) any number of `*' or `+' can be used inside of the standard `/*'
212 and `*/' comment delimiters in the comments, they are ignored.
213 <newline>
214 If a comment line starts with whitespace and is followed by `+html+' then the
215 rest of the line is included only in the HTML output, and is not processed so it
216 can include HTML markup, `-html-' means that the rest of the line is included in
217 all except the HTML output. The same also applies to the other output formats,
218 `+none+' can be used for lines not to appear in any output. The exception to
219 this is that the raw output does not do any checking and will output all lines.
220 <newline>
221 In any situation where a comment follows a `,', `;' or `)' separated only by
222 spaces and tabs, the comment is pushed to before the punctuation to apply to
223 object there.
224 <newline>
225 The program is implemented using a full ANSI C grammar parser with some GCC
226 extensions, this means that the style of the code is unimportant, only the
227 content and comments.
229 <sect1>Automated Comment Insertion
232 To simplify the insertion of comments that will be parsed by cxref, the file
233 <tt>cxref.el</tt> provides a number of Emacs lisp functions. To use them add the line
234 <tt>(load "cxref")</tt> to your `.emacs' file or type <tt>M-x load-file cxref.el</tt> from
235 within Emacs.
237 The functions and key bindings are:
238 <descrip>
239 <tag><it>Control-C Control-F</it></tag>
240 Adds file comments, a /** **/ header at the top of the
241 file and if it is a .h file then it also adds a #ifndef,
242 #define at the beginning and #endif at the end to stop
243 multiple inclusions.
244 <tag><it>Control-C f</it></tag>
245 Adds comments to a function, the cursor must be on the
246 line containing the start of the function definition when
247 this function is called. The /*+ ... +*/ comment that is
248 added is of the header type (see the examples) not inline.
249 <tag><it>Control-C v</it></tag>
250 Adds a leading comment to the variable or other definition
251 on the current line.
252 <tag><it>Control-C e</it></tag>
253 Adds a trailing comment at the end of the line.
254 <tag><it>Control-C i</it></tag>
255 Adds an inline comment that is ignored by cxref.
256 </descrip>
258 <sect1>C Preprocessor
261 To improve the output that is available a modified version of the GNU CPP V2.7.2
262 is supplied (named cxref-cpp).
263 <newline>
264 This modified C preprocessor allows for a finer control over some features of
265 the preprocessing that are not important for a compiler. In a standard
266 preprocessor, the preprocessor directives are intended for use only by the
267 preprocessor, so passing the information through is not important.
268 <newline>
269 With cxref-cpp, there are two features that are different to the standard GNU
270 CPP:
271 <enum>
272 <item>The #include directives from the file are output in the same way as the
273 #defines are output. An extra flag has been added to cpp to do this, '-dI',
274 it works in the same way as the existing '-dD' flag for #defines.
275 <item>Comments trailing a #include or a #define are dropped with GNU CPP even if -C
276 is used. This is not important while compiling but is useful for documenting.
277 </enum>
279 <sect1>Cross Referencing
282 The cross referencing is performed for the following items
283 <descrip>
284 <tag>Files</tag>
285 <itemize>
286 <item>The files that the current file is included in
287 <it>(even when included via other files).</it>
288 </itemize>
289 <tag>#includes</tag>
290 <itemize>
291 <item>Files included in the current file.
292 <item>Files included by these files etc.
293 </itemize>
294 <tag>Variables</tag>
295 <itemize>
296 <item>The location of the definition of external variables.
297 <item>The files that have visibility of global variables.
298 <item>The files / functions that use the variable.
299 </itemize>
300 <tag>Functions</tag>
301 <itemize>
302 <item>The file that the function is prototyped in.
303 <item>The functions that the function calls.
304 <item>The functions that call the function.
305 <item>The files and functions that reference the function.
306 <item>The variables that are used in the function.
307 </itemize>
308 </descrip>
309 Each of these items is cross referenced in the output.
310 <newline>
311 The cross referencing uses files `cxref.variable', `cxref.function',
312 `cxref.include' and `cxref.typedef' in the output directory.<newline>
313 These are a complete list of the function and variable usage in the program and
314 could be used to generate a function call hierarchy or variable usage diagram
315 for example.<newline>
316 Two cxref passes of each file is needed, the first to build up the cross
317 referencing files and the second to use them.
318 <newline>
319 <it>(The file names are different if the `-N' option is used.)</it>
321 <sect1>LaTeX Output
324 The default LaTeX output is a file for each of the source files with one extra
325 file `cxref.tex' that includes each of the other files. This is to allow a
326 makefile to only update the changed files (although the references may require
327 all of the files to be checked again). When the cxref.tex file has been written
328 it can be modified by the user, any new files that are added are added at the
329 end of the source code section, the rest of the file being unchanged.
330 <newline>
331 The index is written to a file called `cxref.apdx.tex' and cxref.tex is updated
332 to refer to it.
333 <newline>
334 Also written out are three LaTeX style files `page.sty', `fonts.sty' and
335 `cxref.sty'. These set up the page to use a smaller margin and smaller fonts to
336 allow more to appear on a page and also define the new commands for typesetting
337 the cxref output.
338 <newline>
339 <it>(The file names `cxref.tex' and `cxref.apdx.tex' are different if the `-N'
340 option is used.)</it>
341 <newline>
342 The two different forms of LaTeX output are selected by using the <it>-latex209</it> or
343 the <it>-latex2e</it> options. These select between two sets of output that can be used
344 with those two different versions of LaTeX.
346 <sect1>HTML Output
349 The default HTML output is a file for each of the source files with one extra
350 file `cxref.html' that includes each of the other files. This is to allow a
351 makefile to only update the changed files (although the references may require
352 all of the files to be checked again). When the cxref.html file has been
353 written it can be modified by the user, any new files that are added are added
354 at the end before the table of contents, the rest of the file being unchanged.
355 <newline>
356 The index is written to a file called `cxref.apdx.html' and cxref.html is
357 updated to refer to it.
358 <newline>
359 <it>(The file names `cxref.html' and `cxref.apdx.html' are different if the `-N'
360 option is used.)</it>
361 <newline>
362 The two different forms of HTML output are selected by using the <it>-html20</it> or the
363 <it>-html32</it> options. These select between two sets of output that comply with the
364 HTML 2.0 and 3.2 definitions, they differ in their use of tables.
366 <sect1>RTF Output
369 Rich Text Format is a fairly low level page description format devised by
370 Microsoft. It is not a well defined and easy to understand standard as are the
371 other formats, but it is popular for document exchange.
372 <newline>
373 There is a single output file for each of the source files and an index file.
375 <sect1>SGML Output
378 Since SGML is a meta-language it is necessary to define the layout elements as
379 well as provide the information. The cxref output uses the LinuxDoc document
380 format and is designed for use with the SGMLtools programs
381 (http://www.sgmltools.org/).
382 <newline>
383 There is a single output file for each of the source files and an index file.
385 <sect1>Further Information
388 There is a list of frequently asked questions and their answers for the cxref
389 program in the FAQ file. A list of improvements planned for future versions of
390 the program are listed in the file TODO.
392 More up-to-date information can be found on the World Wide Web at the cxref
393 homepage, reached via the author's homepage http://www.gedanken.demon.co.uk/.
395 If you wish to submit bug reports or other comments about the program then email
396 the author amb@gedanken.demon.co.uk and put cxref in the subject line.
398 <sect1>Author and Copyright
401 The cxref program was written by Andrew M. Bishop in 1995,96,97,98,99.
402 <newline>
403 The cxref program is copyright Andrew M. Bishop 1995,96,97,98,99.
404 <newline>
405 The cxref-cpp program is copyright Free Software Foundation, Inc.
406 <newline>
407 The cxref and cxref-cpp programs can be freely distributed according to the
408 terms of the GNU General Public License (see the file `COPYING').
410 </article>