oxdoc user's manual

Table of contents

1. Introduction

oxdoc is a tool for generating API documentation in HTML format from comments in ox source code. It is inspired by Sun Microsystems' Javadoc.

2. Installation

Installation is rather easy. Unzip the package oxdoc.zip into a suitable folder, e.g. c:\program files\oxdoc. Next, edit the file oxdoc.bat and alter the path variable in this file. For example, you may want change the path definition into:

set oxdoc=c:/program files/oxdoc
Also, it may be helpful to copy the oxdoc.bat file into a folder in your path, e.g. c:\windows. this way, it's possible to run oxdoc from any folder in the command prompt.

Finally, you may want to edit oxdoc.xml in the bin directory. This file contains general settings for oxdoc. See the Configuration section for more information.

3. Using oxdoc

3.1. Running oxdoc

Using oxdoc is rather easy. Generating documentation for an ox project requires running oxdoc and specifying the names of the files you want to generate documentation from. For example, suppose you have a number of ox files in a folder. From there, run

oxdoc *.ox
from the command prompt in that folder. oxdoc generates a bunch of HTML files, of which default.html is the project home file. It also creates a new style sheet file oxdoc.css. It is advisable to specify an output directory for your project. This can be done by creating a new oxdoc.xml file in your project directory. See Configuration for more information on that.

3.2. Writing documentation

Now you know how to run oxdoc, it's time to write some comments in your code. Documentation comments consist of the normal ox comments, but instead of using /* and */, we use /** and **/. Documentation comments must be placed directly above class definitions and function definitions. For example:
/** This file provides the class `Lumberjack`, an abstract representation
of a lumber jack **/

/** The Lumberjack class represents a lumber jack.  A lumber jack can sleep
by using the `Lumberjack::sleep` method.

@example <pre>
decl L = new Lumberjack();
L.sleep(5);
</pre>

@author Y. Zwols **/
class Lumberjack {
   decl wearsWomensClothes;
   isOk();
   sleep(const hours);
};

/** Checks whether this lumber jack is okay
   @returns TRUE if this lumber jack is okay, FALSE if not.
   @comments In the current implementation, lumber jacks are okay if and only
   if they wear women's clothing.
   @see Lumberjack **/
Lumberjack::isOk() {
   if (this.wearsWomensClothes) 
      return TRUE;
   else
      return FALSE;
}

/** Make the lumber jack sleep for a specified number of hours. A message
is printed to show that he has slept.
   @param hours Number of hours to sleep. Has to be integer.
   @comments The lumber jack cannot sleep more than 24 hours a day. **/
Lumberjack::sleep(const hours) {
   println("The lumber jack is asleep");
   println("(", hours, " hours later...)");
   println("The lumber jack wakes up");
}
This example shows most of the features. Every documentation block is written between /** and **/ signs; HTML tags can be used, e.g. to add markup, or include images. Also, documentation blocks are divided into small sections by @ commands. For example, parameters can be described in the @param section, and extra comments are given in the @comments section.

Also, the first sentence of the comment block is taken as a summary of the documentation block. This first sentence appears in e.g. the project home page and the methods table. oxdoc recognizes the first sentence by scanning for a period followed by a white space. This may have some undesired effects when a period in the first sentence doesn't indicate the end of a sentence, e.g. in the sentence This class implements Prof. John's algorithm, where the part This class implements Prof. will be taken as a summary. This can be avoided by placing &nbsp; (a non-breaking space) just after Prof. Moreover, it is possible to include any HTML tag. This may be useful for inclusing of images, or adding more intricate mark up.

3.3. Types of documentation blocks

There are different types of documentation blocks. Depending on the position of the blocks, they are treated differently. Although most sections are straightforward text blocks, there are two sections with special features:

3.4. Using LaTeX formulas in your documentation

If you have a version of LaTeX installed on your computer, it's extremely easy to add LaTeX formulas to your documentation. If you don't have LaTeX, you can download a version for Windows from www.miktex.org. oxdoc uses a program called dvipng to generate PNG (Portable Network Graphics) files from LaTeX code. The full installation of MiKTeX comes with a version of this programs, but other distributions may not have it readily available. If you use a non-full installation of MiKTeX, make sure to select dvipng during the installation.

Be sure to read the configuration chapter to set up oxdoc so it can find the programs required for this (latex and dvipng).

Once you've set up the connection with LaTeX, adding formules is done by putting them between single or double dollar ($) signs. For example:

/** Calculate the OLS estimates for the model $y = X\beta$.
 @returns The OLS estimate $\hat\beta = (X'X)^{-1}X'y$.
 **/
regression(X, y) {
   return invert(X'X)*X'y;
}
Single dollar signs can be used for inline formulae, whereas double dollar signs can be used for equations on separate lines, analogously to LaTeX.

Note: dvipng generates partially transparent graphics files. These files are currently not supported by Internet Explorer 6.0. Supposedly, this will be fixed in version 7.0. For the time being, I recommended using Mozilla Firefox to view documentation files that include formulae at this point. At some later point, I will add a switch to turn of transparent PNG files.

3.5. Cross-referencing

Making cross references within comments is done by placing a symbol between ` signs. It is important to specify the whole name of the item to be referenced. Global functions and classes are identified by their full names (this is case sensitive!) without arguments, and class methods are identified by the form classname::method. For example, if there is a method isOk() in the class Lumberjack, this method is referenced to by `Lumberjack::isOk`. The same holds for the @see sections. Note that in @see sections, no ` signs are to be used.

3.6. Customizing lay-out

The lay-out of oxdoc's output can be controlled by editing the oxdoc.css file in your output directory. Oxdoc creates a default lay-out file if it is not present, but it won't overwrite changes you make to that file.

4. Configuration

4.1. Location of configuration files

oxdoc is configured by means of the file oxdoc.xml. oxdoc looks for this file at two locations:
  1. the directory in which oxdoc.jar is located (e.g. c:\program files\oxdoc\bin);
  2. the current working directory.
Whenever available, settings are loaded from these files in that order. Parameters set in the current working directory configuration file override the general settings in the oxdoc folder.

It is a good idea to put computer-specific settings in the bin directory and project-specific settings in project directories.

4.2. Lay-out of oxdoc.xml

A configuration file looks something like this:
<oxdoc>
	<option name="latex"     value="c:\texmf\miktex\bin\latex.exe" />
	<option name="dvipng"    value="c:\texmf\miktex\bin\dvipng.exe" />
	<option name="tempdir"   value="c:\temp\" />
</oxdoc>
This file specifies values for three options. More option values can be added to this file as required. See Overview of available settings.

4.3. Command line configuration

It is also possible to specify settings through command line arguments by adding -<parameter>=<value> to the command line. For example,
oxdoc -latex=c:\bin\latex.exe *.ox
would specify a value for the latex setting. The names of the command line parameters correspond exactly to the settings in oxdoc.xml.

4.4. LaTeX settings

oxdoc uses LaTeX in combination with dvipng to generate PNG (Portable Network Graphics) files from formulae within comments. In order to get this working, you'll need a working distribution of LaTeX (e.g. MiKTeX if you're using Windows) and dvipng (which comes with MiKTeX). It is then important to set the paths to the latex and dvipng executables. It is recommended to do this is the oxdoc.xml file in the bin directory of your oxdoc installation.

At startup, oxdoc checks whether it can find the executables required for LaTeX support. If it can't find one or more of these executables, it automatically turns off LaTeX support. In that case, formulae are literally written in the output. Turning off LaTeX support can also be done manually by setting the enablelatex setting to no.

It is also possible to specify extra LaTeX packages to be included within formulae. This can be done by specifying the desired packages, separated by commas, in the option latexpackages.

4.5. Overview of available settings

The following parameters can be set in a configuration file:
outputdirSpecifies the directory in which oxdoc writes its output. Defaults to the current working directory.
tempdirSpecifies the directory that oxdoc can use for temporary files. Defaults to the current working directory.
projectnameSpecifies the name of the project. This name will appear in the project home page.
windowtitleSpecifies the title that will appear in the window caption in your web browser.
imagepathSpecifies the directory in which oxdoc writes its images. Defaults to the specified output directory.
dvipngSpecifies the full path of the executable dvipng. For MiKTeX users, this can be found under the miktex\bin subdirectory of the MiKTeX installation path.
latexSpecifies the full path of the LaTeX compiler. For MiKTeX users, this can be found under the miktex\bin subdirectory of the MiKTeX installation path.
enablelatexTurns on or off LaTeX support. Possible values: yes, no. Default to yes if the required executables can be found.
latexpackages Specifies what LaTeX packages should be loaded for inline LaTeX formulas. These packages are loaded in LaTeX files through the usual \usepackage{...} command. Multiple packages can be specified by separating them by commas.