<!-- saved from url=(0026)http://www.naturaldocs.org -->
<tablewidth=100%border=0cellspacing=0cellpadding=0><tr><tdcolspan=3class=Header><tablewidth=100%border=0cellspacing=0cellpadding=0><tr><td><imgsrc="../images/header/leftside.png"width=30height=75><ahref="../index.html"><imgsrc="../images/header/logo.png"width=524height=75alt="Natural Docs"></a></td><tdalign=right><imgsrc="../images/header/rightside.png"width=30height=75></td></tr></table></td></tr><tr><td><imgsrc="../images/header/overleftmargin.png"width=10height=6></td><tdclass=SideMenuTop><imgsrc="../images/header/overmenu.png"width=14height=6></td><tdclass=BodyTop><imgsrc="../images/header/overbody.png"width=24height=6></td></tr><tr><td></td><tdclass=SideMenunowrap><divclass=SideMenuSection><divclass=SideMenuTitle><imgsrc="../images/menu/about.png"width=52height=13alt="About"></div><divclass=SideMenuBody><ahref="../languages.html"class=SideMenuEntry>Language Support</a><ahref="../output.html"class=SideMenuEntry>Output Formats</a></div></div><divclass=SideMenuSection><divclass=SideMenuTitle><imgsrc="../images/menu/using.png"width=45height=13alt="Using"></div><divclass=SideMenuBody><ahref="../documenting.html"class=SideMenuEntryid=SelectedSideMenuEntry>Documenting<br>Your Code</a><ahref="../keywords.html"class=SideMenuEntry>Keywords</a><ahref="../running.html"class=SideMenuEntry>Running</a><ahref="../troubleshooting.html"class=SideMenuEntry>Troubleshooting</a></div></div><divclass=SideMenuSection><divclass=SideMenuTitle><imgsrc="../images/menu/customizing.png"width=96height=13alt="Customizing"></div><divclass=SideMenuBody><ahref="../menu.html"class=SideMenuEntry>Organizing the Menu</a><ahref="../styles.html"class=SideMenuEntry>CSS Styles</a><ahref="../customizingtopics.html"class=SideMenuEntry>Topics and Keywords</a><ahref="../customizinglanguages.html"class=SideMenuEntry>Languages, Indexes,<br>and Prototypes</a></div></div><divclass=SideMenuSection><divclass=SideMenuTitle><imgsrc="../images/menu/community.png"width=86height=13alt="Community"></div><divclass=SideMenuBody><ahref="http://www.naturaldocs.org/"class=SideMenuEntry>Web Site</a><ahref="http://www.naturaldocs.org/mailinglist.html"class=SideMenuEntry>Mailing Lists</a><ahref="http://www.naturaldocs.org/messageboards.html"class=SideMenuEntry>Message Boards</a><ahref="http://www.naturaldocs.org/bugs.html"class=SideMenuEntry>Bugs and<br>Feature Requests</a></div></div></td><tdclass=Bodywidth=100%><divclass=PageTitle>Documenting Your Code</div><divclass=TOC><ahref="#Comments">Comments</a>·<ahref="#TextFiles">Text Files</a>·<ahref="#KeywordsTopicsAndScope">Keywords, Topics, and Scope</a>·<ahref="#Linking">Linking</a><br><ahref="#FormattingAndLayout">Formatting and Layout</a>·<ahref="#PageTitles">Page Titles</a>·<ahref="#Summaries">Summaries</a>·<ahref="#JavadocCompatibility">Javadoc Compatibility</a></div><divclass=CToolTipid="ttAdd"><divclass=CFunction><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParameters>int Add (</td><tdclass=PType>int </td><tdclass=PParameter>x,</td><td></td></tr><tr><td></td><tdclass=PType>int </td><tdclass=PParameter>y</td><tdclass=PAfterParameters>)</td></tr></table></td></tr></table>Adds two integers.</div></div><divclass=CToolTipid="ttSubtract"><divclass=CFunction><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParameters>int Subtract (</td><tdclass=PType>int </td><tdclass=PParameter>x,</td><td></td></tr><tr><td></td><tdclass=PType>int </td><tdclass=PParameter>y</td><tdclass=PAfterParameters>)</td></tr></table></td></tr></table>Subtracts two integers.</div></div><divclass=CToolTipid="ttMultiply"><divclass=CFunction><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParameters>int Multiply (</td>
Multiplies two integers and returns the result. */
// Function: Multiply
// Multiplies two integers and returns the result.
</pre><p>Note that when stringing line comments together, blank lines that you want to include in the documentation must start with the comment symbol as well. If a line is completely blank, it’s considered the end of the comment and thus the end of the Natural Docs topic.</p><aname="BoxesAndHorizontalLines"></a><divclass="SubTopic">Boxes and Horizontal Lines</div><p>Natural Docs can also handle comment boxes and horizontal lines. It doesn’t matter what symbols they use. The boxes don’t need to be closed on the right side, and they can have different symbols for the edges and corners.</p><preclass=Example>/*
</pre><aname="JavadocStyle"></a><divclass="SubTopic">Javadoc Style</div><p>If you have <ahref="../languages.html">full language support</a>, you can also use Javadoc-style comments to write Natural Docs documentation. To do this you repeat the last symbol on the first line of the comment once. The comment must appear directly above what it’s documenting, and you can omit the topic line if you want (the “<code>Function: Multiply</code>” part.)</p><preclass=Example>/**
* Multiplies two integers and returns the result.
*/
///
// Multiplies two integers together and returns the result.
</pre><p>If you omit the topic line and include any Javadoc tags in the comment, like <code>@param</code>, the entire comment will be treated as Javadoc and can only use Javadoc formatting. Otherwise it’s treated as a Natural Docs comment and you can use all the formatting options described on this page. You can have both styles in the same source file, but not in the same comment.</p><aname="PerlPOD"></a><divclass="SubTopic">Perl POD</div><p>Perl users can also use POD to do block comments.</p><preclass=Example>=begin nd
Function: Multiply
Multiplies two integers and returns the result.
=cut
</pre><p>You can also use <code>NaturalDocs</code> or <code>Natural Docs</code> in place of <code>ND</code>. None of them are case sensitive. If for some reason you want to go back to POD documentation instead of using <code>=cut</code>, you can write <code>=end nd</code>.</p><p>There’s a second form of just <code>=nd</code> which is offered as a convenience. However, it is <b>not valid POD</b>. Perl will skip over it and execute fine, but POD parsers will give errors and possibly include the unformatted text in the output. Use the longer, valid form unless you know for certain that no one will ever try to run POD on your code.</p><preclass=Example>=nd
Function: Multiply
Multiplies two integers and returns the result.
=cut
</pre></div><divclass=Topic><aname="TextFiles"></a><divclass=TopicTitle>Text Files</div><p>Documentation can also be included in text files. Any file with a .txt extension appearing in the source tree and starting with a topic line will included in the documentation. It will be treated the same as a source file, meaning it will appear in the menu, its topics will be in the indexes, and its topics can be linked to from anywhere in the documentation. The only difference is you don’t need comment symbols.</p><p>Remember that the topic line is required to be the first line of content. If the first non-blank line is not in the “<code>Function: Multiply</code>” format the file will be ignored. An easy way to do this is to use the <code>Title</code> keyword, although all of <ahref="../keywords.html">the other ones</a> will work as well.</p><preclass=Example>Title: License
This project is licensed under the GPL.
</pre><p>This method is convenient for documenting file formats, configuration settings, the general program architecture, or anything else that isn’t directly tied to a source file.</p></div><divclass=Topic><aname="KeywordsTopicsAndScope"></a><divclass=TopicTitle>Keywords, Topics, and Scope</div><p>A topic in Natural Docs starts with a topic line in the format <code>“keyword: name”</code>. You can have multiple topics per comment as long as you separate them with a blank line. The keywords aren’t case sensitive.</p><p>The list of keywords is pretty predictable: Function, Class, Variable, etc. Just use what you’re documenting. There are many synonyms as well, so you can use keywords like Func, Procedure, Proc, Method and Constructor. Look at the <ahref="../keywords.html">full list of keywords</a> to see everything that’s available.</p><p>The <ahref="../keywords.html">list of keywords</a> is separated into topic types. Each type gets its own index, and which specific keyword you use doesn’t matter. Some also have scoping rules or other behavior as noted.</p><aname="Scope"></a><divclass="SubTopic">Scope</div><p>Like the code it’s documenting, Natural Docs topics have scope. This mostly has to do with <ahref="#Linking">linking</a>: if you’re in a class you can link to its members by their name alone, but if you’re not, you have to use a notation like <code>class.member</code> or <code>class::member</code>.</p><p>If you have <ahref="../languages.html">full language support</a> and are documenting something that appears in the code, the scope will be handled automatically. If you’re using text files, have basic language support, or are including a topic that doesn’t correspond to something in the code, scoping follows these rules:</p><ul><li>Everything after a class topic (or <ahref="../keywords.html">anything that says “Starts Scope”</a>) is part of that class.</li><li>Everything after a section topic (or <ahref="../keywords.html">anything that says “Ends Scope”</a>) is global again.</li><li>File topics (or <ahref="../keywords.html">anything that says “Always Global”</a>) are global but do not change the scope for what follows.</li><p></ul></p><aname="ListTopics"></a><divclass="SubTopic">List Topics</div><p>If you looked at the list, you saw that most of the keywords have plural forms. That’s for list topics, which let you document many small things without using the full syntax. Anything that appears in <ahref="#DefinitionLists">definition lists</a> within that topic will be treated as if it had its own topic. It will appear in the indexes and be linkable, just like normal topics.</p><p>Function list topics will automatically break apart in the output as well, so it will look the same as if you documented each one individually.</p></div><divclass=Topic><aname="Linking"></a><divclass=TopicTitle>Linking</div><p>Linking is the one place where Natural Docs has some negative effect on the readability of the comments. The alternative would be to automatically guess where links should be, but systems that do that can sometimes pepper your sentences with unintentional links to functions called “is” or “on”. However, the Natural Docs syntax is still as minimal as possible. Simply surround any topic you want to link to with angle brackets. Natural Docs will keep track off all the topics and where they are defined, so you don’t need to use HTML-like syntax or remember what file anything is in. Also, if the link can’t be resolved to anything, Natural Docs leaves the angle brackets in the output so if something wasn’t intended to be a link (such as <code>#include <somefile.h></code>) it won’t be mangled.</p><preclass=Example>Let's link to function <Multiply>.
</pre><divclass=NDContent><pclass=CParagraph>Let’s link to function <ahref="#Example_Class.Multiply"class=LFunctionid=link632onMouseOver="ShowTip(event, 'ttMultiply', 'link632')"onMouseOut="HideTip('ttMultiply')">Multiply</a>.</p></div><p>Links and topic names are case sensitive, regardless of whether the language is or not.</p><p>When linking to functions, it doesn’t matter if you include empty parenthesis or not. Both <code><Function></code> and <code><Function()></code> will work. However, if you documented the function with parameters as part of the name, you will need to include those parameters whenever linking to it. It is recommended that you only include parameters in the topic name if you need to distinguish between two functions with the same name.</p><p>If the topic has a <ahref="#Summaries">summary sentence</a>, hovering over the link will give it to you as a tooltip. If the topic has a prototype, that will be included as well. You can try it above.</p><divclass="SubTopic">Scope</div><p>If a topic is <ahref="#Scope">considered part of a class</a>, they can be linked to using any of the three most common class/member notations: <code>class.member</code>, <code>class::member</code>, and <code>class->member</code>. Natural Docs will not be confused by <code><class->member></code>. Like in the language itself, if the topic you’re writing is in that class’ scope you can link to it simply as <code><member></code>.</p><p>If you have multi-level classes and packages, links can be relative as well. So if you’re in <code>Project::UI::Window::Base</code> and you want to link to <code>Project::UI::Button::Base</code>, just using <code><Button::Base></code> will work.</p><aname="PluralsAndPossessives"></a><divclass="SubTopic">Plurals and Possessives</div><p>To make the documentation easier to write and easier to read in the source file, you can include plurals and possessives inside the angle brackets. In other words, you don’t have to use awkward syntax like <code><Object>s</code>, although that’s supported as well. You can simply write <code><Objects></code> and it will link to the symbol <code>Object</code> just fine. It can handle any plural and/or possessive form you can throw at it. I’m not kidding: <code>Foxes</code>, <code>Fox’s</code>, <code>Foxes’</code>, <code>Children</code>, <code>Mice</code>, <code>Alumni</code>, <code>Indices</code>, <code>Amoebae</code>, <code>Teeth</code>, just try to trip it up.</p><aname="URLsAndEMail"></a><divclass="SubTopic">URLs and E-Mail</div><p>You can also link to URLs and e-mail addresses. It will detect them automatically, but you can also put them in angle brackets if you like.</p><preclass=Example>Visit <http://www.website.com> or send messages to
email@address.com.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><pclass=CParagraph>Visit <ahref="#"onClick="return false;"class=LURL>http://www.website.com</a> or send messages to <ahref="#"onclick="location.href='mai' + 'lto:' + 'em' + 'ail' + '@' + 'addre' + 'ss.com'; return false;"class="LEMail">em<spanstyle="display: none;">.nosp@m.</span>ail<span>@</span>addre<spanstyle="display: none;">.nosp@m.</span>ss.com</a>.</p></div></div></div></div><p>E-mail addresses are protected in a way that should avoid spam crawlers. Although the link above looks and acts like a regular link (try it) the HTML code actually looks like this:</p><preclass=Example><a href="#"
</pre></div><divclass=Topic><aname="FormattingAndLayout"></a><divclass=TopicTitle>Formatting and Layout</div><p>You can apply additional formatting and layout to your Natural Docs content, all in ways that will appear very natural in the source code.</p><aname="Paragraphs"></a><divclass="SubTopic">Paragraphs</div><p>You can break paragraphs by leaving blank lines between them. So we have this in our content:</p><preclass=Example>The first paragraph blah blah blah blah blah blah blah blah
</pre><p>and we get this in our output:</p><divclass=NDContent><divclass=CBody><divclass=CFunction><divclass=CTopic><pclass=CParagraph>The first paragraph blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.</p><pclass=CParagraph>The second paragraph blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.</p></div></div></div></div><aname="BoldAndUnderline"></a><divclass="SubTopic">Bold and Underline</div><p>You can apply bold to a stretch of text by surrounding it with asterisks. You can apply underlining by surrounding it with underscores instead. With underlining, it doesn’t matter if you use an underscore for every space between words or not; they’ll be converted to spaces if you do.</p><preclass=Example>Some *bold text* and some _underlined text_
and yet _more_underlined_text_.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><pclass=CParagraph>Some <b>bold text</b> and some <u>underlined text</u> and yet <u>more underlined text</u>.</p></div></div></div></div><aname="Headings"></a><divclass="SubTopic">Headings</div><p>You can add headings to your output just by ending a line with a colon and having a blank line above it.</p><preclass=Example>Some text before the heading.
Heading:
Some text under the heading.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><pclass=CParagraph>Some text before the heading.</p><h4class=CHeading>Heading</h4><pclass=CParagraph>Some text under the heading.</p></div></div></div></div><p>You <u>must</u> have a blank line above the heading or it will not work. You can skip the blank after it but not before.</p><aname="BulletLists"></a><divclass="SubTopic">Bullet Lists</div><p>You can add bullet lists by starting a line with a dash, an asterisk, an o, or a plus. Bullets can have blank lines between them if you want, and subsequent lines don’t have to be indented. You end a list by skipping a line and doing something else.</p><preclass=Example>- Bullet one.
- Bullet two.
Bullet two continued.
- Bullet three.
Some text after the bullet list.
o Spaced bullet one.
o Spaced bullet two.
Spaced bullet two continued.
o Spaced bullet three.
Some text after the spaced bullet list.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><ulclass=CBulletList><li>Bullet one.</li><li>Bullet two. Bullet two continued.</li><li>Bullet three.</li></ul><pclass=CParagraph>Some text after the bullet list.</p><ulclass=CBulletList><li>Spaced bullet one.</li><li>Spaced bullet two. Spaced bullet two continued.</li><li>Spaced bullet three.</li></ul><pclass=CParagraph>Some text after the spaced bullet list.</p></div></div></div></div><aname="DefinitionLists"></a><divclass="SubTopic">Definition Lists</div><p>You can add a definition list by using the format below, specifically “text space dash space text”. Like bullet lists, you can have blank lines between them if you want, subsequent lines don’t have to be indented, and you end the list by skipping a line and doing something else.</p><preclass=Example>First - This is the first item.
Second - This is the second item.
This is more of the second item.
Third - This is the third item.
This is more of the third item.
Some text after the definition list.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>First</td><tdclass=CDLDescription>This is the first item.</td></tr><tr><tdclass=CDLEntry>Second</td><tdclass=CDLDescription>This is the second item. This is more of the second item.</td></tr><tr><tdclass=CDLEntry>Third</td><tdclass=CDLDescription>This is the third item. This is more of the third item.</td></tr></table><pclass=CParagraph>Some text after the definition list.</p></div></div></div></div><p>Remember that with definition lists, if you’re using the plural form of the keywords each entry can be linked to as if it had its own topic.</p><aname="CodeAndTextDiagrams"></a><divclass="SubTopic">Code and Text Diagrams</div><p>You can add example code or text diagrams by starting each line with <code>></code>, <code>|</code>, or <code>:</code>. If you have a vertical line or text box with the comment, you must separate these symbols from it with a space.</p><preclass=Example>: a = b + c;
> +-----+ +-----+
> | A | --> | B |
> +-----+ +-----+
> |
> +-----+
> | C |
> +-----+
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><preclass=CCode>a = b + c;</pre><preclass=CCode>+-----+ +-----+<br>| A | --> | B |<br>+-----+ +-----+<br> |<br> +-----+<br> | C |<br> +-----+</pre></div></div></div></div><p>For long stretches, this may be too tedious. You can start a code section by placing <code>(start code)</code> or just <code>(code)</code> alone on a line. You end it with either <code>(end code)</code> or just <code>(end)</code>. You can’t put any other content on these lines.</p><preclass=Example>(start code)
if (x == 0) {
DoSomething();
}
return x;
(end)
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><preclass=CCode>if (x == 0) {<br> DoSomething();<br>}<br><br>return x;</pre></div></div></div></div><p>You can also use <code>example</code>, <code>diagram</code>, or <code>table</code> instead of <code>code</code>. Just use whatever’s appropriate. Always flexible, it will accept <code>begin</code> for <code>start</code> and it will accept <code>finish</code> or <code>done</code> for <code>end</code> so you don’t have to remember the exact word.</p><aname="Images"></a><divclass="SubTopic">Images</div><p>You can include images in your documentation by writing “<code>(see filename)</code>”. If you put it alone on a line it will be embedded in place.</p><preclass=Example>This is the first paragraph.
(see logo.gif)
This is the second paragraph.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><pclass=CParagraph>This is the first paragraph.</p><imgsrc="../images/logo.gif"width="268"height="61"><pclass=CParagraph>This is the second paragraph.</p></div></div></div></div><p>If it’s not alone on a line the image will appear after the end of the paragraph, the text will become a link to it, and the file name will be used as a caption.</p><preclass=Example>This is the first paragraph (see logo.gif) This is
more of the first paragraph.
</pre><divclass=NDContent><divclass=CFunction><divclass=CTopic><divclass=CBody><pclass=CParagraph>This is the first paragraph <ahref="#Image1"class=CImageLink>(see logo)</a> This is more of the first paragraph.</p><divclass=CImage><aname="Image1"></a><divclass=CImageCaption>logo</div><imgsrc="../images/logo.gif"width="268"height="61"></div></div></div></div></div><p>The image file names are relative to the source file the comment appears in or any directories specified with the <ahref="../running.html#CommandLine"><code>-img</code> command line option</a>. You can use relative paths like <code>(see images/logo.gif)</code> and <code>(see ../images/logo.gif)</code>, but you cannot use absolute paths, URLs, or specify a file that’s not in a folder included by <ahref="../running.html#CommandLine"><code>-i</code></a> or <ahref="../running.html#CommandLine"><code>-img</code></a>.</p><p>Natural Docs supports gif, jpg, jpeg, png, and bmp files.</p></div><divclass=Topic><aname="PageTitles"></a><divclass=TopicTitle>Page Titles</div><p>Natural Docs automatically determines the page title as follows:</p><ul><li>If there’s only one topic in the file, that topic’s title becomes the page title.</li><li>Otherwise, if the first topic in the file is a class, section, or file, that topic’s title becomes the page title.</li><li>Otherwise, the file name becomes the page title.</li><p></ul></p><p>This should be enough for most people. However, if you don’t like the page title Natural Docs has chosen for you, add a “<code>Title: [name]</code>” comment to the top of the file to override it. <code>Title</code> is a synonym of Section, so that will satisfy the second rule and make it the page title.</p></div><divclass=Topic><aname="Summaries"></a><divclass=TopicTitle>Summaries</div><p>Summaries are automatically generated for every file, class, and section. You don’t have to do anything special to get them.</p><p>There are two things you may want to keep in mind when documenting your code so that the summaries are nicer. The first is that they use the first sentence in the topic as the description, so long as it’s plain text and not something like a bullet list. It will also appear in the tooltip whenever that topic is linked to.</p><p>The second is that you may want to manually add group topics to divide long lists and make the summaries easier to navigate. Natural Docs will automatically group them by type if you do not, but sometimes you want to be more specific. You don’t need to provide a description, just adding a “<code>Group: [name]</code>” comment is sufficient. Note that once you manually add a group automatic grouping is completely turned off for that class.</p><p>Here’s an example summary. Note that as before, when you hover over a link, you’ll get the prototype and summary line as a tooltip.</p><divclass=NDSummary><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><tr><tdclass=SEntrySize><divclass=SMain><divclass=SEntry><ahref="#Example_Class">Example Class</a></div></div></td><tdclass=SDescriptionSize><divclass=SMain><divclass=SDescription>A example class that does arithmetic with functions for people scared of operators.</div></div></td></tr><tr><td><divclass=SGroup><divclass=SEntry><divclass=SIndent1><ahref="#Example_Class.Arithmetic_Functions">Arithmetic Functions</a></div></div></div></td><td><divclass=SGroup><divclass=SDescription><divclass=SIndent1></div></div></div></td></tr><trclass=SMarked><td><divclass=SFunction><divclass=SEntry><divclass=SIndent2><ahref="#Example_Class.Add"id=link1onMouseOver="ShowTip(event, 'ttAdd', 'link1')"onMouseOut="HideTip('ttAdd')">Add</a></div></div></div></td><td><divclass=SFunction><divclass=SDescription><divclass=SIndent2>Adds two integers.</div></div></div></td></tr><tr><td><divclass=SFunction><divclass=SEntry><divclass