1 <!-- $Id: preparing.xml,v 1.5 2007/05/11 08:16:44 thuffir Exp $ -->
3 <section id="preparing">
4 <title id="preparing.title">Preparing your source code for ROBODoc</title>
6 <para> ROBODoc allows you to mix the program documentation with
7 the source code. It does require though that this documentation
8 has a particular layout so ROBODoc can recognize it. There are
9 three key concepts: headers, items, and sections. </para>
12 <title>Headers</title>
14 <para>Headers are the building blocks of the documentation. Lets
15 look at an example. The following header was taken from the
16 documentation of the predecessor of ROBODoc, AutoDoc.</para>
18 <example id="robodocheader">
19 <title>A ROBODoc header in C.</title>
21 /****f* financial.library/StealMoney
23 * StealMoney -- Steal money from the Federal Reserve Bank. (V77)
25 * error = StealMoney( userName, amount, destAccount, falseTrail )
27 * Transfer money from the Federal Reserve Bank into the
28 * specified interest-earning checking account. No records of
29 * the transaction will be retained.
31 * userName - name to make the transaction under. Popular
32 * favorites include "Ronald Reagan" and
34 * amount - Number of dollars to transfer (in thousands).
35 * destAccount - A filled-in AccountSpec structure detailing the
36 * destination account (see financial/accounts.h).
37 * If NULL, a second Great Depression will be
39 * falseTrail - If the DA_FALSETRAIL bit is set in the
40 * destAccount, a falseTrail structure must be
43 * error - zero for success, else an error code is returned
44 * (see financial/errors.h).
46 * Federal regulations prohibit a demonstration of this function.
48 * Do not run on Tuesdays!
50 * Before V88, this function would occasionally print the
51 * address and home phone number of the caller on local police
52 * 976 terminals. We are confident that this problem has been
55 * CreateAccountSpec(),security.device/SCMD_DESTROY_EVIDENCE,
58 * You can use this space for remarks that should not be included
59 * in the documentation.
63 <para>A header consists of three different elements: a
64 begin marker, a number of items, and an end marker. The begin marker
65 in the example is:</para>
68 ****f* financial.library/StealMoney
71 <para>It marks the beginning of a header. It also tells ROBODoc
74 <listitem><para>the name of the element that is being documented, StealMoney,</para></listitem>
75 <listitem><para>the module it is part of, financial.library,</para></listitem>
76 <listitem><para>the kind of element, <literal>f</literal>, which stands for function.</para></listitem>
80 ROBODoc always expects that a <literal>/</literal> separates the module name and an element name.
81 So <literal>ModFoo/funcBar</literal>
82 is a valid name, but <literal>funcBar</literal> is not.
83 See <xref linkend="sections" endterm="sections.title" /> for more
88 Names can also contain spaces but ROBODoc won't create links to names with
93 You can also have multiple names for a header. This is useful if you
94 document similar objects together in one header (for example assembly
95 subroutines with multiple jump-in points). Multiple names are separated by
96 commas and can span over more than one line.
98 ****f* financial.library/StealMoney, Steal_Money
100 In the above example all references found to <literal>StealMoney</literal>
101 and <literal>Steal_Money</literal> in other headers will be automatically
102 linked to this header.
103 The separation character(s) can be specified by the
104 <xref linkend="separate_characters_block" endterm="separate_characters_block.title" />.
105 See <xref linkend="customizing" endterm="customizing.title" /> for more
118 marks the end of a header.
121 <para>Items begin with an item name and are followed by the
122 item's body. An example: </para>
126 * Transfer money from the Federal Reserve Bank into the
127 * specified interest-earning checking account. No records of
128 * the transaction will be retained.
132 In this case the item's name is FUNCTION.
136 Each line of an item starts with a remark marker. In this case
137 <literal>*</literal>.
140 <para>That what ROBODoc needs to recognize a header is therefore:</para>
143 <title>The markers needed by ROBODoc to recognize a header.</title>
145 /****f* financial.library/StealMoney
186 The above example is in C. ROBODoc supports many more
187 languages though. See <xref linkend="defaultheaders" endterm="defaultheaders.title" />.
193 <section id="header_types">
194 <title id="header_types.title">Header Types</title>
196 <para> ROBODoc defines a number of header types. You don't need
197 to use them but they can be useful for sorting information. The
198 header type tells ROBODoc what kind of object you are documenting.
199 This information allows ROBODoc to create more useful index
202 <para>The type is identified by one or two characters. ROBODoc
203 expects to find them after the fourth <literal>*</literal> in the
204 begin marker. So <literal>#****f</literal> is a valid marker,
205 but <literal>#**f**</literal> is not.</para>
207 <para>If a single character is given, the type is defined as
208 listed in the following table</para>
210 <table frame="all"><title>Default header types</title>
211 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
212 <colspec colname='c1'/>
213 <colspec colname='c2'/>
215 <row><entry>c</entry><entry>Header for a class </entry></row>
216 <row><entry>d</entry><entry>Header for a constant (from define)</entry> </row>
217 <row><entry>f</entry><entry>Header for a function</entry></row>
218 <row><entry>h</entry>
219 <entry id="header_type_h">Header for a module in a project</entry></row>
220 <row><entry>m</entry><entry>Header for a method</entry> </row>
221 <row><entry>s</entry><entry>Header for a structure</entry> </row>
222 <row><entry>t</entry><entry>Header for a types</entry> </row>
223 <row><entry>u</entry><entry>Header for a unit test</entry> </row>
224 <row><entry>v</entry><entry>Header for a variable</entry> </row>
225 <row><entry>*</entry><entry>Generic header for everything else</entry> </row>
230 <para>If two characters are given, the first character should be
231 <literal>i</literal> and the second can be any of the other
232 characters from the table above. This creates an internal header
233 of the type specified by the second character. Internal headers
234 are special. They can be used to hide certain headers. They are
235 only extracted if requested. You can use them to document internal
236 functions, classes, etc. that you do not want clients to see,
237 creating what might be a programmer's manual as opposed to a
238 user's manual.</para>
240 <para>So <literal>/****if* Module/func1</literal> defines an
241 internal function called <literal>func1</literal>.
244 <para>Headers marked internal are by default not included in the
245 generated documentation. If you want to include them use the
246 option <option>--internal</option>. You can also generate the
247 documentation from only the internal headers with the option
248 <option>--internalonly</option>.
251 <para>You can define your own header types using the ROBODoc
252 configuration file, <filename>robodoc.rc</filename>.
253 See <xref linkend="headertypes_block" endterm="headertypes_block.title" />.
254 This way you can document anything you like, for instance makefile
255 entries, system tests, or exceptions.
260 <section> <title>Items</title>
262 <para> By default ROBODoc recognizes the following items: </para>
270 <para>Item name plus a short description.
280 <para>Who own the copyright : "(c) <year>-<year> by
281 <company/person>"
333 <para>When did the work start.
346 <para>Who has done which changes and when.
369 What can we feed into it.
382 <para>What output is made.
396 What do we get returned.
407 A clear example of the items use.
428 <para> Diagnostic output.
441 <para>Warning and error-messages.
463 <listitem><para>What to implement next and ideas. </para></listitem>
470 <listitem><para>Where does it come from, where will it work. </para></listitem>
477 <listitem><para>References to other functions, man pages, other documentation. </para></listitem>
488 <listitem><para>OOP methods.</para></listitem>
500 <listitem><para>OOP attributes.</para></listitem>
509 <para>Tag-item description.
517 <listitem><para>OOP super class. </para></listitem>
524 <listitem><para>OOP sub class. </para></listitem>
534 <listitem><para>What modules are used by this one. </para></listitem>
544 <listitem><para>Which modules do use this one. </para></listitem>
551 <listitem><para>Command description. </para></listitem>
558 <listitem><para>Source code inclusion. </para></listitem>
563 <para>You can define your own items using the ROBODoc
564 configuration file, <filename>robodoc.rc</filename>. See <xref
565 linkend="customizing" endterm="customizing.title" />. </para>
569 <section id="sections">
570 <title id="sections.title">Sections</title>
572 <para>The structure of source code for a project is usually
573 hierarchical. A project might consists of several applications,
574 an application of several modules, a module of several functions
575 or even sub modules. ROBODoc allows you to show this hierarchy in
576 your documentation. For this you specify the hierarchy in the
577 header name. For instance, you have a project that is going to
578 create a new language called D. The D Language project might
579 consists of three applications: a preprocessor, a compiler, and a
580 linker. The compiler consists of two modules, a parser and a
581 generator. The parser module consists of several
584 <para>The following three headers show how this hierarchy can be
585 defined in the header name.</para>
588 #****h* D-Language/Compiler
590 # The compiler takes a preprocessed source file and
591 # turns it into an object file.
596 #****h* D-Language/Linker
598 # The linker module contains functions that scan a
599 # object file and build the executable.
604 #****h* Compiler/Parser
606 # The parser module contains functions that scan a
607 # preprocessed source file and build the syntax tree.
612 #****f* Parser/ReadToken
614 # ReadToken reads the next token from the input
619 <para>When you generate documentation with the option
620 <option>--section</option>, ROBODoc uses the hierarchical
621 information when generating the table of contents and document
622 section information. For instance in HTML sections are started
623 with <H1>, <H2>, <H3> depending on the level
624 in the hierarchy. The table of contents will also contain levels. The
625 table of contents for the above example will be: </para>
628 1. D-Language/Compiler
630 1.1.1 Parser/ReadToken
636 <section id="formatting"> <title id="formatting.title">Smart Text Formatting</title>
638 <para>By default ROBODoc creates preformatted text in the output
639 documentation for all the text it finds in an item. This means
640 that the formatting of the output looks the same as the formatting of
641 the text of an item. Line-breaks and indentation stay the same.
642 This is easy but does not always create the best looking
645 <para>ROBODoc can also try to deduce the formatting of your text based
646 on the layout and indentation of your text and on special characters in the text.
647 It works a bit similar to the input method of Wikis. In the context of this
648 manual this is called Smart Formatting.
651 <para>You switch this on with the option <option>--nopre</option>.
652 ROBODoc now tries to find three kind of elements: paragraphs,
653 lists, and preformatted text.</para>
655 <para>Paragraphs are separated by empty lines. So the following item
656 has two paragraphs.</para>
659 <title>Two paragraphs.</title>
662 This function does something.
664 And it then does something else
669 <para> A List starts with a line that ends with a ':' which is then
670 followed by one or more list items. List items should start with '*',
671 '-', or 'o'. So the following item contains a valid list: </para>
674 <title>A list.</title>
680 * and a bit of foobarring.
684 <para> A list item can span more than one line if the second and following
685 lines are indented. So this is also a valid list:</para>
688 <title>A list where one of the items spans more than one line.</title>
692 * a lot of foo and preprocessing of the
693 raw input with the aid
696 * and a bit of foobarring.
701 <para>If list items directly follow the name of a robodoc item they
702 also form a valid list. So this is a valid list:</para>
705 <title>an implicit list</title>
708 * inputname -- the name of the input file
709 * outputname -- the name of the output file
710 * n -- the number of characters to be written
714 <para> Preformatted text is indicated by indenting it more that the
715 surrounding text. The first non-empty line in an item determines the
716 base indenting. Any lines with an indentation larger than this are
717 preformatted. An example:</para>
720 <title>Preformatted text</title>
721 <literallayout class="monospaced">
723 The following lines are preformatted
728 End of the preformatted text.
732 <para>The following is a complete example.</para>
734 <example id="fullsmart">
735 <title>All three elements of smart formatting.</title>
736 <literallayout class="monospaced">
737 This is some example text.
740 This is even more, and we start a list:
745 And we can also do preformatted stuff
754 <para>will be turn into</para>
756 <example id="fulloutput">
757 <title>The corresponding HTML output.</title>
758 <literallayout class="monospaced">
759 <p>This is some example text.
760 And some more.</p>
762 <p>This is even more, and we start a list:</p>
764 <li>a list item</li>
765 <li>a list item</li>
766 <li>a list item</li>
769 <p>And we can also do preformatted stuff
770 by indenting</p>
776 <p> The box will stay.</p>