Preparing your source code for ROBODoc ROBODoc allows you to mix the program documentation with the source code. It does require though that this documentation has a particular layout so ROBODoc can recognize it. There are three key concepts: headers, items, and sections.
Headers Headers are the building blocks of the documentation. Lets look at an example. The following header was taken from the documentation of the predecessor of ROBODoc, AutoDoc. A ROBODoc header in C. /****f* financial.library/StealMoney * NAME * StealMoney -- Steal money from the Federal Reserve Bank. (V77) * SYNOPSIS * error = StealMoney( userName, amount, destAccount, falseTrail ) * FUNCTION * Transfer money from the Federal Reserve Bank into the * specified interest-earning checking account. No records of * the transaction will be retained. * INPUTS * userName - name to make the transaction under. Popular * favorites include "Ronald Reagan" and * "Mohamar Quadaffi". * amount - Number of dollars to transfer (in thousands). * destAccount - A filled-in AccountSpec structure detailing the * destination account (see financial/accounts.h). * If NULL, a second Great Depression will be * triggered. * falseTrail - If the DA_FALSETRAIL bit is set in the * destAccount, a falseTrail structure must be * provided. * RESULT * error - zero for success, else an error code is returned * (see financial/errors.h). * EXAMPLE * Federal regulations prohibit a demonstration of this function. * NOTES * Do not run on Tuesdays! * BUGS * Before V88, this function would occasionally print the * address and home phone number of the caller on local police * 976 terminals. We are confident that this problem has been * resolved. * SEE ALSO * CreateAccountSpec(),security.device/SCMD_DESTROY_EVIDENCE, * financial/misc.h ****** * You can use this space for remarks that should not be included * in the documentation. */ A header consists of three different elements: a begin marker, a number of items, and an end marker. The begin marker in the example is: ****f* financial.library/StealMoney It marks the beginning of a header. It also tells ROBODoc the name of the element that is being documented, StealMoney, the module it is part of, financial.library, the kind of element, f, which stands for function. ROBODoc always expects that a / separates the module name and an element name. So ModFoo/funcBar is a valid name, but funcBar is not. See for more information. Names can also contain spaces but ROBODoc won't create links to names with embedded spaces. You can also have multiple names for a header. This is useful if you document similar objects together in one header (for example assembly subroutines with multiple jump-in points). Multiple names are separated by commas and can span over more than one line. ****f* financial.library/StealMoney, Steal_Money In the above example all references found to StealMoney and Steal_Money in other headers will be automatically linked to this header. The separation character(s) can be specified by the . See for more information. The end marker: ****** marks the end of a header. Items begin with an item name and are followed by the item's body. An example: * FUNCTION * Transfer money from the Federal Reserve Bank into the * specified interest-earning checking account. No records of * the transaction will be retained. In this case the item's name is FUNCTION. Each line of an item starts with a remark marker. In this case *. That what ROBODoc needs to recognize a header is therefore: The markers needed by ROBODoc to recognize a header. /****f* financial.library/StealMoney * NAME * * SYNOPSIS * * FUNCTION * * * * INPUTS * * * * * * * * * * * * RESULT * * * EXAMPLE * * NOTES * * BUGS * * * * * SEE ALSO * * ****** The above example is in C. ROBODoc supports many more languages though. See .
Header Types ROBODoc defines a number of header types. You don't need to use them but they can be useful for sorting information. The header type tells ROBODoc what kind of object you are documenting. This information allows ROBODoc to create more useful index tables. The type is identified by one or two characters. ROBODoc expects to find them after the fourth * in the begin marker. So #****f is a valid marker, but #**f** is not. If a single character is given, the type is defined as listed in the following table Default header types cHeader for a class dHeader for a constant (from define) fHeader for a functionh Header for a module in a projectmHeader for a method sHeader for a structure tHeader for a types uHeader for a unit test vHeader for a variable *Generic header for everything else
If two characters are given, the first character should be i and the second can be any of the other characters from the table above. This creates an internal header of the type specified by the second character. Internal headers are special. They can be used to hide certain headers. They are only extracted if requested. You can use them to document internal functions, classes, etc. that you do not want clients to see, creating what might be a programmer's manual as opposed to a user's manual. So /****if* Module/func1 defines an internal function called func1. Headers marked internal are by default not included in the generated documentation. If you want to include them use the option . You can also generate the documentation from only the internal headers with the option . You can define your own header types using the ROBODoc configuration file, robodoc.rc. See . This way you can document anything you like, for instance makefile entries, system tests, or exceptions.
Items By default ROBODoc recognizes the following items: NAME Item name plus a short description. COPYRIGHT Who own the copyright : "(c) <year>-<year> by <company/person>" SYNOPSIS USAGE How to use it. FUNCTION DESCRIPTION PURPOSE What does it do. AUTHOR Who wrote it. CREATION DATE When did the work start. MODIFICATION HISTORY HISTORY Who has done which changes and when. INPUTS ARGUMENTS OPTIONS PARAMETERS SWITCHES What can we feed into it. OUTPUT SIDE EFFECTS What output is made. RESULT RETURN VALUE What do we get returned. EXAMPLE A clear example of the items use. NOTES Any annotations DIAGNOSTICS Diagnostic output. WARNINGS ERRORS Warning and error-messages. BUGS Known bugs. TODO IDEAS What to implement next and ideas. PORTABILITY Where does it come from, where will it work. SEE ALSO References to other functions, man pages, other documentation. METHODS NEW METHODS OOP methods. ATTRIBUTES NEW ATTRIBUTES OOP attributes. TAGS Tag-item description. DERIVED FROM OOP super class. DERIVED BY OOP sub class. USES CHILDREN What modules are used by this one. USED BY PARENTS Which modules do use this one. COMMANDS Command description. SOURCE Source code inclusion. You can define your own items using the ROBODoc configuration file, robodoc.rc. See .
Sections The structure of source code for a project is usually hierarchical. A project might consists of several applications, an application of several modules, a module of several functions or even sub modules. ROBODoc allows you to show this hierarchy in your documentation. For this you specify the hierarchy in the header name. For instance, you have a project that is going to create a new language called D. The D Language project might consists of three applications: a preprocessor, a compiler, and a linker. The compiler consists of two modules, a parser and a generator. The parser module consists of several functions. The following three headers show how this hierarchy can be defined in the header name. #****h* D-Language/Compiler # FUNCTION # The compiler takes a preprocessed source file and # turns it into an object file. #*** #****h* D-Language/Linker # FUNCTION # The linker module contains functions that scan a # object file and build the executable. #*** #****h* Compiler/Parser # FUNCTION # The parser module contains functions that scan a # preprocessed source file and build the syntax tree. #*** #****f* Parser/ReadToken # FUNCTION # ReadToken reads the next token from the input # file. #*** When you generate documentation with the option , ROBODoc uses the hierarchical information when generating the table of contents and document section information. For instance in HTML sections are started with <H1>, <H2>, <H3> depending on the level in the hierarchy. The table of contents will also contain levels. The table of contents for the above example will be: 1. D-Language/Compiler 1.1 Compiler/Parser 1.1.1 Parser/ReadToken 2. D-Language/Linker
Smart Text Formatting By default ROBODoc creates preformatted text in the output documentation for all the text it finds in an item. This means that the formatting of the output looks the same as the formatting of the text of an item. Line-breaks and indentation stay the same. This is easy but does not always create the best looking output. ROBODoc can also try to deduce the formatting of your text based on the layout and indentation of your text and on special characters in the text. It works a bit similar to the input method of Wikis. In the context of this manual this is called Smart Formatting. You switch this on with the option . ROBODoc now tries to find three kind of elements: paragraphs, lists, and preformatted text. Paragraphs are separated by empty lines. So the following item has two paragraphs. Two paragraphs. FUNCTION This function does something. And it then does something else and a bit more. A List starts with a line that ends with a ':' which is then followed by one or more list items. List items should start with '*', '-', or 'o'. So the following item contains a valid list: A list. FUNCTION This function does: * a lot of foo * some snafuing * and a bit of foobarring. A list item can span more than one line if the second and following lines are indented. So this is also a valid list: A list where one of the items spans more than one line. FUNCTION This function does: * a lot of foo and preprocessing of the raw input with the aid of the some magic * some snafuing * and a bit of foobarring. If list items directly follow the name of a robodoc item they also form a valid list. So this is a valid list: an implicit list INPUTS * inputname -- the name of the input file * outputname -- the name of the output file * n -- the number of characters to be written Preformatted text is indicated by indenting it more that the surrounding text. The first non-empty line in an item determines the base indenting. Any lines with an indentation larger than this are preformatted. An example: Preformatted text FUNCTION The following lines are preformatted +--------+ | A box | | | +--------+ End of the preformatted text. The following is a complete example. All three elements of smart formatting. This is some example text. And some more. This is even more, and we start a list: * a list item * a list item * a list item And we can also do preformatted stuff by indenting +--------+ | | +--------+ The box will stay. will be turn into The corresponding HTML output. <p>This is some example text. And some more.</p> <p>This is even more, and we start a list:</p> <ul> <li>a list item</li> <li>a list item</li> <li>a list item</li> </ul> <p>And we can also do preformatted stuff by indenting</p> <pre> +--------+ | | +--------+ </pre> <p> The box will stay.</p>