Tips and Tricks
The SOURCE Item With a little extra work you can include part of your source code into your documentation too. The following example shows how this is done: /****f* Robodoc/RB_Panic [2.0d] * NAME * RB_Panic - Shout panic, free resources, and shut down. * SYNOPSIS * RB_Panic (cause, add_info) * RB_Panic (char *, char *) * FUNCTION * Prints an error message. * Frees all resources used by robodoc. * Terminates program. * INPUTS * cause - pointer to a string which describes the * cause of the error. * add_info - pointer to a string with additional information. * SEE ALSO * RB_Close_The_Shop () * SOURCE */ void RB_Panic (char *cause, char *add_info) { printf ("Robodoc: Error, %s\n",cause) ; printf (" %s\n", add_info) ; printf ("Robodoc: Panic Fatal error, closing down..\n") ; RB_Close_The_Shop () ; /* Free All Resources */ exit(100) ; } /*******/ You can add a SOURCE item as the last item of your header. Then instead of closing your header with an end marker, you close it normally. The end marker is instead placed at the end of the fragment of source code that you want to include. SOURCE items are included by default. If you want to create a document without the SOURCE items use the option . You can also make normal items work like the source item, see .
Minimizing Duplicate Information It is always good to avoid having the same information in several different locations. It is easy to create headers that have a lot information duplication. Take for instance the following header. /****f* Robodoc/RB_Panic [2.0d] * NAME * RB_Panic - Shout panic, free resources, and shut down. * SYNOPSIS * RB_Panic (cause, add_info) * RB_Panic (char *, char *) * FUNCTION * Prints an error message. * Frees all resources used by robodoc. * Terminates program. * INPUTS * cause - pointer to a string which describes the * cause of the error. * add_info - pointer to a string with additional information. * SEE ALSO * RB_Close_The_Shop () * SOURCE */ void RB_Panic (char *cause, char *add_info) { printf ("Robodoc: Error, %s\n",cause) ; printf (" %s\n", add_info) ; printf ("Robodoc: Panic Fatal error, closing down..\n") ; RB_Close_The_Shop () ; /* Free All Resources */ exit(100) ; } /*******/ The name RB_Panic occurs five times. This is tedious to type and difficult to maintain. However with a the right robodoc.rc this can be changed to: /****f* Robodoc/RB_Panic [2.0d] * SUMMARY * Shout panic, free resources, and shut down. * SYNOPSIS */ void RB_Panic (char* cause, char *add_info) /* * FUNCTION * Prints an error message. * Frees all resources used by robodoc. * Terminates program. * INPUTS * cause - pointer to a string which describes the * cause of the error. * add_info - pointer to a string with additional information. * SEE ALSO * RB_Close_The_Shop () * SOURCE */ { printf ("Robodoc: Error, %s\n",cause) ; printf (" %s\n", add_info) ; printf ("Robodoc: Panic Fatal error, closing down..\n") ; RB_Close_The_Shop () ; /* Free All Resources */ exit(100) ; } /*******/ RB_Panic occurs only twice now. In addition changes to the function definition only have to be done once. The robodoc.rc required for this is: # robodoc.rc file items: SUMMARY SYNOPSIS INPUTS OUTPUTS SEE ALSO BUGS source items: SYNOPSIS remark begin markers: /* remark end markers: */
Advanced formatting with raw HTML and LaTeX code By default an item's body shows up in your documentation in the same way as it is formatted in your source code. All special characters for the output mode are escaped. For instance an < is translated to a &lt; in HTML mode. Sometimes however you like to have some more control of what goes into the documentation. This is possible with the piping. If a line of your item's body starts with one of the special piping markers, the text after this marker is copied verbatim into your documentation. The following example shows how this is done, and how to add equations to your documentation. /****m* pipe/pipetest * NAME * pipetest * DESCRIPTION * Simple header to show "piping" features in items. * EXAMPLE * Only "pipes" which match selected output style are picked up. * |html <CENTER>This will be included in <B>HTML</B> output.</CENTER> * |latex \centerline{This will be included in \LaTeX output} * Space is mandatory following the pipe marker. The following is not a * valid pipe marker: * |html<B>Moi!</B> * You should see an equation on the following line: * |html y = x^2 (sorry, plain HTML is not very powerful) * |latex \centerline{$y = x^2$} * How does this look like? * Here comes a multi-line equation array: * |latex \begin{eqnarray} * |latex \frac{\partial u}{\partial \tau} & = & D_u {\nabla}^2 u + * |latex \frac{1}{\epsilon} * |latex \left ( \hat{u}-{\hat{u}}^2-f\, {v} \, \frac{\hat{u}-q}{\hat{u}+q} * |latex \right ) \; , \label{diffspot:1} \\ * |latex \frac{\partial v}{\partial \tau} & = & \hat{u}-v \; , * |latex \label{diffspot:2} \\ * |latex \frac{\partial r}{\partial \tau} & = & D_r {\nabla}^2 r \; . * |latex \label{diffspAot:3} * |latex \end{eqnarray} * |html <I>TODO: write this in html</I> * End of the example. ****** */
Linking to external documents (href, file, mailto, images) In HTML mode ROBODoc recognizes the following links to external documents. href:body -- This is replaced with <a href="body">body</A> file:/body -- This is replaced with <a href="file:/body">file:/body</A> mailto:body -- This is replaced with <a href="mailto:body">body</A> http://body -- This is replaced with <a href="http://body">http://body</A> image:body -- This is replaced with <image src="body">
Linking from an external document To link from an external document to one of the HTML documents generated by ROBODoc you need a label. ROBODoc creates two labels for each header. The first one starts with robo followed by a number. You can not use this one because the numbers will change each time you run ROBODoc. The second label is an escaped version of the whole header name. In this label all the non alphanumeric characters of the name are replaced by their two digit hexadecimal code. An example, if your header name is Analyser/RB_ToBeAdded the label is Analyser2fRB5fToBeAdded. Here / was replaced by 2f and _ was replaced by 5f. As long as you do not change the header name, this label stays the same each time you run ROBODoc.
Using external tools You can also execute external tools from ROBODoc and even pass data to them. The output of these tools can be included in your documentation for instance. There are several types of external tools you can use: Arbitrary tool with passing data through stdin Arbitrary tool without passing data through stdin The DOT tool The following example shows how to use each of them. /****m* tools/tooltest * * NAME * Tooltest * * DESCRIPTION * Example showing how to invoke external tools. * * EXAMPLE * This one sorts elements into the file href:nexus-6.txt * The input data is passed through stdin. * * |tool sort > nexus-6.txt * Zhora * Pris * Leon Kowalski * Roy Batty * Rachel * Rick Deckard? * |tool end * * We can also execute tools without having any stdin data. * In the following example the output is simply redirected into href:tears.txt * * |exec echo "All those moments will be lost in time like tears in rain." > tears.txt * * You can also include neat DOT graphs in your documentation. * This one shows a hash table. * * |dot start * digraph G { * nodesep=.05; * rankdir=LR; * node [shape=record,width=.1,height=.1]; * * node0 [label = "<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | ",height=2.0]; * node [width = 1.5]; * node1 [label = "{<n> n14 | 719 |<p> }"]; * node2 [label = "{<n> a1 | 805 |<p> }"]; * node3 [label = "{<n> i9 | 718 |<p> }"]; * node4 [label = "{<n> e5 | 989 |<p> }"]; * node5 [label = "{<n> t20 | 959 |<p> }"] ; * node6 [label = "{<n> o15 | 794 |<p> }"] ; * node7 [label = "{<n> s19 | 659 |<p> }"] ; * * node0:f0 -> node1:n; * node0:f1 -> node2:n; * node0:f2 -> node3:n; * node0:f5 -> node4:n; * node0:f6 -> node5:n; * node2:p -> node6:n; * node4:p -> node7:n; * } * |dot end * ****** */ If you want to use the DOT tool you need the Graphviz package. More information and the binaries can be found at http://www.graphviz.org/ . The created graphs are automatically included in the documentation (HTML and LaTeX only). If you generate PDF output from your LaTeX file and you want to include DOT graphs in it, you will also need the epstopdf utility. ROBODoc lets DOT generate PNG images for HTML output and PS and PDF images for LaTeX output.
ROBODoc-ing an existing project The ROBODoc package includes also a standalone binary named robohdrs. This helper program can take clean source file and insert ROBODoc headers to functions, global variables, and macros. There are issues with this tool but it saves lots of cumbersome typing when starting on documenting an existing code-base with ROBODoc. Type man robohdrs or robohdrs -h for help. Example: robohdrs -s -p testproj -i "MODIFICATION HISTORY" -i IDEAS testproj.c Note that robohdrs is supported on UNIX-like platforms only. It requires fork() and Exuberant Ctags 5.3.1 or newer.
Using ROBODoc under Windows When you use ROBODoc under windows, don't forget that it is a command line tool. ROBODoc relies on the console window to inform you about problems and errors. An easy mistake to make is to create a shortcut to robodoc.exe and then click on the icon to generate the documentation each time you made some changes to your source code. If you have a fast machine a console window pops up quickly and after that your documentation is ready. This works very fine until you make a mistake in one of your headers. The console window still pops up, but before you have a chance to read any of the error messages it is gone again. Most likely you won't even have noticed there were error messages. You will end up with empty documentation or old documentation. It is Better to create a batch file with the following commands and to store all the options in a robodoc.rc file: robodoc.exe pause Now the console window stays open and you have the opportunity to read the error messages. While the window is open, right click on the title bar, go to properties->layout and set the buffer size to something like 2500. That way, the next time you run it, you can scroll back and view all error messages.