home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Docs / cxref-1.4a.lha / README < prev    next >
Encoding:
Text File  |  1997-12-07  |  16.7 KB  |  345 lines

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