CPlusPlusDoc - An Easy to Use Documentation Tool for C++

(Version 2.0 now supports COM IDL documentation)

Download CPlusPlusDoc

 

Program Description:

CPlusPlusDoc is able to create HTML documentation for C++ class header files. The documentation produced closely resembles the HTML documentation created by Java's "javadoc" tool. The comment-tags used by the CPlusPlusDoc tool are very similar to javadoc's, allowing developers to use one style of comments that work whether programming in C++ or Java. Details of how to properly use CPlusPlusDoc comments and comment-tags are listed below.

 

Getting Started:

The "CPlusPlusDoc" executable file has been included with your download, so there is no need to re-build the source code. However, if you do want to rebuild the application, a makefile has been included (for Linux/Unix) that will allow you to easily rebuild the "CPlusPlusDoc" executable.

For Windows 95/98/NT/Millenium/2000/XP users, CPlusPlusDoc version 2.0 has been created. Version 2.0 has a powerful and intuitive graphical user interface, and also has the ability to document COM IDL files..

Both Windows and Linux/Unix downloads come with the "CPlusPlusDoc" executable. Each version allows you to double-click on the "CPlusPlusDoc" executable file using the operating system's graphical user interface, or you can use the operating system's command line.

The following is an example of the commands used to run the "CPlusPlusDoc" tool from the command line as if it were located in the "c:\DocumentationTools\CPlusPlusDoc" directory in Windows or the "/DocumentationTools/CPlusPlusDoc" directory in Linux/Unix:

Windows:

cd "c:\DocumentationTools\CPlusPlusDoc"

CPlusPlusDoc

Linux/Unix:

cd /DocumentationTools/CPlusPlusDoc"

CPlusPlusDoc

 

Using the Program:

After starting "CPlusPlusDoc", you will be shown the following:

"Please enter the absolute path to the parent directory of all header files and subdirectories:"

"Enter here:"

If, for instance, you have all your source code files in the "c:\sourceCode\headerFiles" on a Windows machine or the "/sourceCode/headerFiles" on a Linux/Unix machine, you would enter the following:

Windows:

c:\sourceCode\headerFiles

Linux/Unix:

/sourceCode/headerFiles

You will then be asked if you would like to document private class members:

"Do you want to document private class members:"

"Enter here:"

If you would like to document private class members, answer "yes" or "y", and if you don't, answer "no" or "n".

CPlusPlusDoc will then collect all the absolute paths of every file listed in the "headerFiles" directory, along with all the files in its sub-directories. All header files with a ".h" extension are then parsed through and searched for class definitions, each for which CPlusPlusDoc generates an HTML file.

CPlusPlusDoc generates a "docs" directory under the "headerFiles" directory, and places all documentation in this directory. CPlusPlusDoc creates a few files for its own use in the "docs" directory, and also produces an "index.html" file that is most useful for a developer because its layout allows him/her to easily navigate through all generated HTML files by providing links to each file. CPlusPlusDoc generates a "log.txt" file that details the number of classes, inner structures, and inner unions having been documented, along with a listing of each class that was documented and the header file it came from. CPlusPlusDoc also includes a commented line near the top of the HTML code in the HTML file it produces that lists the absolute path to the header file the HTML file is produced from.

 

How to Document Source Code:

Just like javadoc's comments, CPlusPlusDoc comments begin with a "/**" and end with a "*/". The only comments processed are those appearing immediately before a class element is processed, so you must include all relevant information inside one comment block.

Here is a simple example of a member method declaration with CPlusPlusDoc comments:

/**
* This function deposits the number of dollars represented by
* <b>amount</b> into the bank account represented by the
* <b>accountNumber</b> argument. Continued work on this
* function is needed because no one has gotten
* it to work in real life. If you get it to work, please email
* me with the implementation so I can put it inside an infinite
* loop with my account information in it!
*
* @param accountNumber The bank account number to which the amount
* is to be deposited.
*
* @param amount The amount to be deposited.
*
* @return True if the deposit was successful, false if not.
*/
bool depositMoney(int accountNumber, float amount);

Notice the use of "<b>" and the "</b>" in the above comment. Since the documentation produced is in HTML, you are free to use HTML tags wherever you like in your comments and it will be reflected in the documentation.

 

CPlusPlusDoc comment-tags:

@param <parameter name>             
	Used to detail parameters
	Example: @param stringOne The string to search.

@return                             
	Used to detail the return value from a function
	Example: @return True if successful, false if not.

@throws <exception name>            
	Used to detail the exception a function throws
	Example: @throws URLException Throws a URLException object if the URL is invalid.

@exception <exception name>         
	Used to detail the exception a function throws (same as the above tag)
	Example: @throws URLException Throws a URLException object if the URL is invalid.

@author                             
	Used to detail the author of the class or class member
	Example: @author Ram Dass

@co-author                          
	Used to detail the co-authors of the class or class member
	Example: @co-author Erich Fromm

@version                            
	Used to detail the version of the class or class member
	Example: @version 1.00

@deprecated                         
	Used to mark a class or class member as being deprecated
	Example: @deprecated Since Version 1.00

@since                              
	Used to detail the date this class or class member first appeared
	Example: @since Version 1.00

@precondition                       
	Used to list a precondition for the class method
	Example: @precondition Just list a precondition here...I think you get how it works.

@postcondition                      
	Used to list a postcondition for the class method
	Example: @postcondition Do I need to explain?

{@link NamespaceName::ClassName}    
	Used to create an HTML link to the class within the namespace
	Example: {@link std::iostream}

{@link ClassName}                   
	Used to create an HTML link to the class
	Example: {@link ClassComponent}


*Note: If the class falls within a namespace, the {@link NamespaceName::ClassName} form must be used. 

An example of nearly every one of the above tags can be seen in the source code header files for the "CPlusPlusDoc" tool, and the documentation produced from running the tool against these header files can be found in the "docs" directory contained in the "CPlusPlusDoc" download.

 

Important Notes:

1.) This tool only works correctly for header files with proper C++ syntax.

2.) Only the first 512 characters of each line are read in from the header file.

3.) This tool considers only the first code to be included from a macro. For instance, if you declare a macro like this:

#ifdef STP_NAMESPACE
namespace STP {
#else
namespace GLL {
#endif      

then only the "namespace STP {" is included in the code to be documented.

4.) For nested classes, structures, and unions, this tool generates a temporary file using the following technique:

namespace name + "-" + directory path + "A###" + "OuterClassName" + "+" + "InnerClassName" + ".h"

For instance, if the outer class name is "Outer" and it appears in the "Test" namespace, the inner class name is "Inner" and "Outer" is located in the "C:\Header" directory, the generated file is "C:\Header\Test-A###Outer+Inner.h". These files are deleted toward the end of the tool's process. The name of the class in the documentation for the class listed above would be "Outer+Inner". If there is more than one class with the same name, CPlusPlusDoc tool will document each class and internally keep track of each class's information.

5.) Inner anonymous unions are given the name "AnonymousUnion". So, if the inner anonymous union appeared in the "Outer" class, the name of the union in the HTML documentation would be "Outer+AnonymousUnion".

6.) Memory use will vary for this program. During a test in which this tool documented 979 classes, the tool consumed up to 8MB of memory.