set oxdoc=c:/program files/oxdocAlso, 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 *.oxfrom 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.
/** 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 (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.
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:
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.
oxdoc -latex=c:\bin\latex.exe *.oxwould specify a value for the latex setting. The names of the command line parameters correspond exactly to the settings in oxdoc.xml.
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:
| outputdir | Specifies the directory in which oxdoc writes its output. Defaults to the current working directory. |
| tempdir | Specifies the directory that oxdoc can use for temporary files. Defaults to the current working directory. |
| projectname | Specifies the name of the project. This name will appear in the project home page. |
| windowtitle | Specifies the title that will appear in the window caption in your web browser. |
| imagepath | Specifies the directory in which oxdoc writes its images. Defaults to the specified output directory. |
| dvipng | Specifies the full path of the executable dvipng. For MiKTeX users, this can be found under the miktex\bin subdirectory of the MiKTeX installation path. |
| latex | Specifies the full path of the LaTeX compiler. For MiKTeX users, this can be found under the miktex\bin subdirectory of the MiKTeX installation path. |
| enablelatex | Turns 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. |