File: README.html

package info (click to toggle)
cxref 1.6d-6
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,680 kB
  • sloc: ansic: 16,542; yacc: 2,091; sh: 917; lex: 462; perl: 452; makefile: 425; lisp: 256; cpp: 188; python: 80
file content (394 lines) | stat: -rw-r--r-- 16,014 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<HTML>

<HEAD>
<TITLE>C Cross Referencing &amp; Documenting tool. Version 1.6.</TITLE>
</HEAD>

<BODY>

<h1>C Cross Referencing &amp; Documenting tool. Version 1.6 - cxref</h1>

A program that can automatically generate documentation and cross references for
a C program.
<br>
The input is any C program with appropriate comments and the output is LaTeX,
HTML, RTF or SGML files.

<h2>Program Options</h2>

The name of the program is cxref.
<br>
<pre>
Usage: cxref filename [ ... filename]
             [-Odirname] [-Nbasename] [-Rdirname]
             [-all-comments] [-no-comments]
             [-verbatim-comments] [-block-comments]
             [-xref[-all][-file][-func][-var][-type]]
             [-warn[-all][-comment][-xref]]
             [-index[-all][-file][-func][-var][-type]]
             [-raw]
             [-latex]
             [-html[-src]]
             [-rtf]
             [-sgml]
             [-Idirname] [-Ddefine] [-Udefine]
             [-CPP cpp_program] [-- cpp_arg [ ... cpp_arg]]

Usage: cxref filename [ ... filename] -delete
             [-Odirname] [-Nbasename] [-Rdirname]
</pre>

<dl>
<dt><tt>filename</tt>
<dd>The name of the file to document, any number of files may be
documented at a time.
<dt><tt>-delete</tt>
<dd>The files named are to be deleted from the output directory and
their entries in the cross reference database and main output
files are to be removed.
<dt><tt>-Odirname</tt>
<dd>The name of a directory to use for the output latex files and
the location of the cross reference files that are created.
<dt><tt>-Nbasename</tt>
<dd>The name to use for the first part of the output and cross
reference files instead of cxref, the file extensions remain
the same.
<dt><tt>-Rdirname</tt>
<dd>When the source files are in more than one directory, set
dirname to the name of the root directory of the source tree
(use relative path if easier e.g. `-R../..').  This will then
run cxref from that root directory and the `-Odirname' must be
relative to that directory.
<dt><tt>-all-comments</tt>
<dd>In case you think that the existing comments might work,
(see below for description of special comments).
<br><i>[Danger! This option can produce weird results.]</i>
<dt><tt>-no-comments</tt>
<dd>Ignores all comments, useful if you just want the cross
references and not the documentation.
<dt><tt>-verbatim-comments</tt>
<dd>When the comments that you have in the code are formatted
in a predetermined style that you want to preserve on the
output, this option will force them not to be reformatted.
<br><i>[Note, this is for file and function comments only.]</i>
<dt><tt>-block-comments</tt>
<dd>When the comments in the program are formatted in the `block'
style (with a leading `*' character on every line), this option
will remove that character from the output.
<br><i>[Works for a single `*', `+', `|' or `:' on each line.]</i>
<dt><tt>-xref</tt>
<dd>Produce cross referencing information (see below).
<dl compact>
<dt><tt>-all</tt> <dd>All cross references.
<dt><tt>-file</tt><dd>Cross references for files.
<dt><tt>-func</tt><dd>Cross references for functions.
<dt><tt>-var</tt> <dd>Cross references for variables.
<dt><tt>-type</tt><dd>Cross references for types.
</dl>
<dt><tt>-warn</tt>
<dd>Produce warnings, the options must be concatenated together:
<dl compact>
<dt><tt>-all</tt>    <dd>All warnings.
<dt><tt>-comment</tt><dd>Warn of missing comments.
<dt><tt>-xref</tt>   <dd>Warn of missing cross references.
</dl>
<dt><tt>-index</tt>
<dd>Produce a cross reference index, the options must be
concatenated together:
<dl compact>
<dt><tt>-all</tt> <dd>All indexes.
<dt><tt>-file</tt><dd>Index of files.
<dt><tt>-func</tt><dd>Index of functions.
<dt><tt>-var</tt> <dd>Index of variables.
<dt><tt>-type</tt><dd>Index of types.
</dl>
<dt><tt>-raw</tt>
<dd>Produce a raw form of output, not really of much use except
with -warn.
<dt><tt>-latex</tt>
<dd>Produce a LaTeX file to document each of the source files and
also an extra file that includes each of these files.
<dt><tt>-html</tt>
<dd>Produce an HTML 4.01 file to document each of the source files
and a main file to reference each of these files.
<dt><tt>-html-src</tt>
<dd>Produce the HTML output and an HTML version of the source file
with links into it.
<dt><tt>-rtf</tt>
<dd>Produce a Rich Text Format (RTF) file to document the source
file.
<dt><tt>-sgml</tt>
<dd>Produce an SGML file to document the source file.  (Using the
LinuxDoc DTD).
<dt><tt>-Idirname</tt>
<dd>GCC option to specify the path for include files.
<dt><tt>-Ddefine</tt>
<dd>GCC option to define a pre-processor symbol.
<dt><tt>-Udefine</tt>
<dd>GCC option to undefine a pre-processor symbol.
<dt><tt>-CPP program</tt>
<dd>The name of the program to use instead of the compile time
default.  The program must be able to perform all of the actions
that `gcc -E -C -dD' does to work. If the program takes
arguments then the whole thing needs to be in quotes so that it
is interpreted as a single argument to cxref.
<dt><tt>-- arg ... arg</tt>
<dd>Extra arguments to be passed to the pre-processor can be placed
after the `--' separator.
</dl>

<h2>C Compiler Replacement cxref-cc</h2>

To simplify using cxref on existing source code, there is now a shell script
that will call the C compiler and then call cxref to process the source file.
This means that it can be used as a drop in replacement for CC in Makefiles and
the like.

<pre>
Usage: cxref-cc [usual cc options]
</pre>

The name of the source file is extracted from the list of options as well as the
`-D*', `-I*', `-U*' flags and when the C compiler exits succesfully cxref will
be called.  The name of the C compiler to use is controlled by the CXREFCC
environment variable, or if this is not set then the CC environment variable, or
failing this just gcc.

Using this script requires the use of a `.cxref' configuration file to contain
the options since there is nowhere to put the options on the command line for
the C compiler.

This will only cross-reference and document the C source files since they are
the only ones that are compiled, but it will make sure that they are
cross-referenced with the correct options etc.

<h2>Cxref configuration File</h2>

These command line arguments can also be put into a file named `.cxref' instead
of on the command line.  When cxref is run the arguments to the program are
interpreted in the following order.

<ol>
<li>Those on the command line.
<li>Those in the `.cxref' file in the current directory.
<li>Those in the `.cxref' file in the source tree root specified by `-R'.
</ol>

This means that in a multi-directory source tree, each sub-directory can have a
`.cxref' file containing just the line `-R..' or appropriate.  The main
directory can have a `.cxref' file containing the remainder of the options.
This removes completely the need to have any options on the command line apart
from the source file names.

The format of the `.cxref' file is any number of lines, each one containing a
single command line argument (equivalent to one of the argv).  The only options
that cannot be used are the names of source files themselves and the `-delete'
option.  Blank lines are ignored and lines starting with a '#' are comments.

<h2>Program Documentation Comments</h2>

The documentation for the program is produced from comments in the code that are
appropriately formatted.  The cross referencing comes from the code itself and
requires no extra work.
<br>
The special comments are `/**** ****/' (for a file) and `/*++++ ++++*/' (for a
data object) any number of `*' or `+' can be used inside of the standard `/*'
and `*/' comment delimiters in the comments, they are ignored.
<br>
If a comment line starts with whitespace and is followed by `+html+' then the
rest of the line is included only in the HTML output, and is not processed so it
can include HTML markup, `-html-' means that the rest of the line is included in
all except the HTML output.  The same also applies to the other output formats,
`+none+' can be used for lines not to appear in any output.  The exception to
this is that the raw output does not do any checking and will output all lines.
<br>
In any situation where a comment follows a `,', `;' or `)' separated only by
spaces and tabs, the comment is pushed to before the punctuation to apply to
object there.
<br>
The program is implemented using a full ANSI C grammar parser with some GCC
extensions, this means that the style of the code is unimportant, only the
content and comments.

<h2>Automated Comment Insertion</h2>

To simplify the insertion of comments that will be parsed by cxref, the file
cxref.el provides a number of Emacs lisp functions.  To use them add the line
<tt>(load "cxref")</tt> to your `.emacs' file or type <tt>M-x load-file cxref.el</tt> from
within Emacs.
<p>
The functions and key bindings are:
<dl>
<dt><i>Control-C Control-X Control-F</i>
<dd>Adds file comments, a /** **/ header at the top of the
file and if it is a .h file then it also adds a #ifndef,
#define at the beginning and #endif at the end to stop
multiple inclusions.
<dt><i>Control-C Control-X f</i>
<dd>Adds comments to a function, the cursor must be on the
line containing the start of the function definition when
this function is called.  The /*+ ... +*/ comment that is
added is of the header type (see the examples) not inline.
<dt><i>Control-C Control-X v</i>
<dd>Adds a leading comment to the variable or other definition
on the current line.
<dt><i>Control-C Control-X e</i>
<dd>Adds a trailing comment at the end of the line.
<dt><i>Control-C Control-X i</i>
<dd>Adds an inline comment that is ignored by cxref.
</dl>

<h2>C Preprocessor</h2>

To improve the output that is available a modified version of the GNU CPP V2.7.2
is supplied (named cxref-cpp).
<br>
This modified C preprocessor allows for a finer control over some features of
the preprocessing that are not important for a compiler.  In a standard
preprocessor, the preprocessor directives are intended for use only by the
preprocessor, so passing the information through is not important.
<br>
With cxref-cpp, there are two features that are different to the standard GNU
CPP:
<ol>
<li>The #include directives from the file are output in the same way as the
#defines are output.  An extra flag has been added to cpp to do this, '-dI',
it works in the same way as the existing '-dD' flag for #defines.
<li>Comments trailing a #include or a #define are dropped with GNU CPP even if -C
is used. This is not important while compiling but is useful for documenting.
</ol>

<h2>Cross Referencing</h2>

The cross referencing is performed for the following items
<dl>
<dt>Files
<dd><menu>
<li>The files that the current file is included in
<i>(even when included via other files).</i>
</menu>
<dt>#includes
<dd><menu>
<li>Files included in the current file.
<li>Files included by these files etc.
</menu>
<dt>Variables
<dd><menu>
<li>The location of the definition of external variables.
<li>The files that have visibility of global variables.
<li>The files / functions that use the variable.
</menu>
<dt>Functions
<dd><menu>
<li>The file that the function is prototyped in.
<li>The functions that the function calls.
<li>The functions that call the function.
<li>The files and functions that reference the function.
<li>The variables that are used in the function.
</menu>
</dl>
Each of these items is cross referenced in the output.
<br>
The cross referencing uses files `cxref.variable', `cxref.function',
`cxref.include' and `cxref.typedef' in the output directory.
<br>
These are a complete list of the function and variable usage in the program and
could be used to generate a function call hierarchy or variable usage diagram
for example.
<br>
Two cxref passes of each file is needed, the first to build up the cross
referencing files and the second to use them.
<br>
<i>(The file names are different if the `-N' option is used.)</i>

<h2>LaTeX Output</h2>

The default LaTeX output is a file for each of the source files with one extra
file `cxref.tex' that includes each of the other files.  This is to allow a
makefile to only update the changed files (although the references may require
all of the files to be checked again).  When the cxref.tex file has been written
it can be modified by the user, any new files that are added are added at the
end of the source code section, the rest of the file being unchanged.
<br>
The index is written to a file called `cxref.apdx.tex' and cxref.tex is updated
to refer to it.
<br>
Also written out are three LaTeX style files `page.sty', `fonts.sty' and
`cxref.sty'.  These set up the page to use a smaller margin and smaller fonts to
allow more to appear on a page and also define the new commands for typesetting
the cxref output.
<br>
<i>(The file names `cxref.tex' and `cxref.apdx.tex' are different if the `-N'
option is used.)</i>

<h2>HTML Output</h2>

The default HTML output is a file for each of the source files with one extra
file `cxref.html' that includes each of the other files.  This is to allow a
makefile to only update the changed files (although the references may require
all of the files to be checked again).  When the cxref.html file has been
written it can be modified by the user, any new files that are added are added
at the end before the table of contents, the rest of the file being unchanged.
<br>
The index is written to a file called `cxref.apdx.html' and cxref.html is
updated to refer to it.
<br>
<i>(The file names `cxref.html' and `cxref.apdx.html' are different if the `-N'
option is used.)</i>
<br>
The HTML output uses the HTML 4.01 standard and all pages validate correctly.
<p>
As an example, the cross referencing produced by cxref for the cxref program
itself starts in the file <a href="example/cxref.html">example/cxref.html</a>.
This is a good example of the type of output that can be produced using cxref.

<h2>RTF Output</h2>

Rich Text Format is a fairly low level page description format devised by
Microsoft.  It is not a well defined and easy to understand standard as are the
other formats, but it is popular for document exchange.
<br>
There is a single output file for each of the source files and an index file.

<h2>SGML Output</h2>

Since SGML is a meta-language it is necessary to define the layout elements as
well as provide the information.  The cxref output uses the LinuxDoc document
format and is designed for use with the SGMLtools programs
(<a href="http://www.sgmltools.org/">http://www.sgmltools.org/</a>).
<br>
There is a single output file for each of the source files and an index file.

<h2>Example Special Comments</h2>

See the <a href="README.c">README.c</a> file, to see that the comments are indeed seen in the code,
<br>
The result of running this through cxref is in <a href="README.c.html">README.c.html</a>.

<h2>Further Information</h2>

There is a list of frequently asked questions and their answers for the cxref
program in the FAQ file (also available in <a href="FAQ.html">HTML format</a>).  A list of improvements planned for future versions of
the program are listed in the file TODO.

More up-to-date information can be found on the World Wide Web at the cxref
homepage, reached via the author's homepage <a href="http://www.gedanken.demon.co.uk/">http://www.gedanken.demon.co.uk/</a>.

If you wish to submit bug reports or other comments about the program then email
the author <a href="mailto:amb@gedanken.demon.co.uk">amb@gedanken.demon.co.uk</a> and put cxref in the subject line.

<h2>Author and Copyright</h2>

The cxref program was written by Andrew M. Bishop in 1995-2011.
<br>
The cxref program is copyright Andrew M. Bishop 1995-2011.
<br>
The cxref-cpp program is copyright Free Software Foundation, Inc.
<br>
The cxref and cxref-cpp programs can be freely distributed according to the
terms of the GNU General Public License (see the file `COPYING').

</BODY>
</HTML>