DocFlex/Javadoc - Doclet
- Overview
- Running Doclet
- Doclet GUI
- Configuration Files
- Tips
1. Overview
From the user point of view,
DocFlex/Javadoc
can be considered to consist of two separate components: DocFlex Doclet and
Template Designer.
While using Template Designer to design your own documentation would require some understanding of the
DocFlex Technology,
running DocFlex Doclet would need to know little more than that described on this page.
And this may be just enough to make a real use, since DocFlex Doclet coupled with a proper set of templates
basically does the same as any other Javadoc doclet: consumes options from the Javadoc command line and
generates the output.
So, once provided with the ready templates, you could immediately start generating documentation
(programmed in those templates) in any output format supported by the DocFlex core.
Such a standard set of templates
is included in both packages available for
downloads: 'DocFlex/Javadoc' and 'DocFlex/Doclet'.
See Examples
to take a look on the output those templates produce.
| Note: |
The 'DocFlex/Doclet' edition is available for free use.
It does not include the
Template Designer.
The templates are embedded in the jar-file included in the package.
This product can be used both as a ready to use RTF doclet for Javadoc Tool
able to generate an excellent quality MS Word and OpenOffice.org
friendly documentation plus a freeware interpreter for your custom templates.
|
2. Running Doclet
To run the DocFlex Doclet, you will need to specify the doclet class on the Javadoc
command line using option:
-doclet com.docflex.javadoc.Doclet
| Note: |
If you are going to generate documentation for a big project, it is also important to ensure
that JVM will allocate enough memory for the heap (otherwise, the generator will slow down and
may run out of memory). The maximum heap size should be specified directly on the Javadoc command
line using -J-Xmx option. For example, setting
-J-Xmx256m will allocate 256 Mb for the heap.
DocFlex generator is pretty hungry for memory as it stores lots
of temporary data in hash-tables in order to boost performance!
However, according to our tests, 256 Mb heap appeared to be quite
enough to generate an RTF documentation for a project with something
close to 1000 Java classes.
|
Other options are described below.
Command Line Options
Here are all command line options specifically provided by DocFlex Doclet:
The number of options is relatively small for two reasons:
-
Since all informative content of the generated documentation is programmed entirely within templates,
it is the matter of template parameters to control this. The templates parameters are passed via
the -P option.
-
The output formats do have their specific options. But since such options are different for each
particular output format and the number of supported formats will grow, all output format options
are specified in the uniform way via -O option
(same as the template parameters).
Effectively, the number of the generator settings may be so large that the DocFlex Doclet provides
a different and more convenient way for specifying all of them -- the
Doclet GUI.
Here are option details grouped by category:
Template Options
- -template <file>
- Specifies the main template file to be executed by the generator. All documentation
generation is controlled by this template. The main template may call from itself
another templates (subtemplates) producing either a single output file or
multiple files (framed documentation).
- -P<parameter> <value>
or
-p:<parameter> <value>
- Specifies the value of a template parameter.
Notes:
Output Options
- -format <HTML | RTF | TXT>
- Specifies the output format. By default, HTML.
- -O<option> <value>
or
-o:<option> <value>
- Specifies the output format option.
Notes:
- -d <directory>
- Specifies the destination directory for the generated documentation.
By default, this is the current directory (the one designated by "." pathname).
This option works in conjunction with the -f option.
The documentation files are distributed in the following way:
-
In the case of a single-file documentation
-
The output document is placed in the destination directory under default file name
'templatename.formatextention' (for example, in the RTF output format,
template PlainDoc.tpl will produce document 'PlainDoc.rtf').
The -f option may override this name.
-
All associated files (such as images, if not included in the document) are placed
in the 'docname_files' subdirectory near the main document.
-
In the case of a framed multiple-file documentation
-
By default, all generated files and subdirectories are placed in the specified destination
directory. The frameset file produced by the main template is saved under the name 'index.html'.
This is the same as the output produced by the
Standard Javadoc doclet.
-
If a different name 'docname' is specified with the -f option,
the frameset file is saved under this name. All other files and the subdirectory tree are moved into
'docname_files' subdirectory near the frameset file.
This makes the whole documentation to look as to consist of only two file entities, which may be easier
to distribute yet during the generation, especially when different types of documentation are produced
from the same Java sources (e.g. by different templates or with the different parameters).
- Examples:
-
-template PlainDoc.tpl -format RTF -d c:\out
- generate the document file
c:\out\PlainDoc.rtf with the associated files
subdirectory c:\out\PlainDoc_files\ (if any)
-template PlainDoc.tpl -format HTML -d c:\out -f OpenAPI
- generate the document file
c:\out\OpenAPI.html with the associated files
subdirectory c:\out\OpenAPI_files\ (if any)
-template FramedDoc.tpl -format HTML -d c:\out
- generate the framed documentation located in the directory
c:\out\
with the main file index.html
-template FramedDoc.tpl -format HTML -d c:\out -f OpenAPI
- generate the framed documentation with the main file
c:\out\OpenAPI.html
and all other files located in the directory c:\out\OpenAPI_files\
- -f <file>
- Specifies the documentation output file name. This option works in conjunction with the
-d option and specifies the name of the main output file
(the one associated with the main template).
Typically, it should be used to specify a pure name associated with the generated documentation
(for example, 'DocletAPI'). However, the pathname may also be used. In that case, it is interpreted
against the initial destination directory (specified with the -d option) and may override it.
If the pathname is the absolute one, the -d option is effectively ignored.
- -launchviewer[=<true | false>]
- Tells the generator to execute a specific non-Java command to launch an external application
able to view the generated result (for instance, an Internet browser to view HTML documentation).
Precisely, this command is specified in docflex.config file found near
docflex-javadoc.jar (or docflex-doclet.jar) file in the
lib directory.
- Examples:
-
-launchviewer
- Do launch viewer
-launchviewer=false
- Do not launch viewer, no matter what's specified in the
generator.config
Configuration Options
- -config <file>
- Specifies the generator config file,
which may contain options written manually or using the
Generator Dialog. All options not provided directly
on the command line are looked for in this file.
The Generator Dialog also uses this file to store all options and parameters specified interactively.
If the config file does not exist, the Generator Dialog will try to create it by the provided pathname.
By default, the location of the generator config file is specified in the
docflex.config (located in lib directory).
If no other config file provided, it is automatically loaded from this location if exists.
- -docflexconfig <file>
- Specifies an alternative path to the DocFlex main configuration file.
By default, this file is
'docflex.config' which is searched in the directory where
the DocFlex Java library file 'docflex-javadoc.jar'
(or docflex-doclet.jar) is located.
If not found, docflex.config is created automatically with default settings.
Other Options
- -link <extdocURL>
- Creates links to existing javadoc-generated documentation of external referenced classes.
This option will work the same as the
-link
option supported by the
Standard Doclet.
Precisely, the processing of both -link and -linkoffline options
is programmed within the templates using a Javadoc-specific
FlexQuery function:
getExternalDocURL().
When DocFlex/Doclet meets either -link or
-linkoffline option on the Javadoc command line, it processes such an option
so that the content of the package-list file referred from it is loaded into a special internal
hash-table. Further, getExternalDocURL() function uses that table to translate
any Java qualified name into a possible URL of the external documentation.
- -linkoffline <extdocURL> <packagelistLoc>
- This option is a variation of -link; they both create links to javadoc-generated
documentation for external referenced classes. Use the -linkoffline option when linking to a document on
the web when the Javadoc tool itself is "offline" -- that is, it cannot access the document through
a web connection.
This option will work the same as the
-linkoffline
option provided by the
Standard Doclet.
See also -link option for more details about how it is implemented.
- -nodialog[=<true | false | quiet>]
- Do not invoke the Doclet GUI.
Parameters:
| true |
- |
if this (or no parameter) is specified, the DocFlex Doclet starts the generation
immediately according to the setting specified on the Javadoc command line and
loaded from the generator config
(see -config option). Then, the doclet exits.
|
| false |
- |
this is the same as when the -nodialog option was not specified at all.
The Generator Dialog will be invoked.
|
| quiet |
- |
start the generation immediately (without dialog) and suppress displaying most of
the generator messages to screen (see also -quiet option).
The generation progress counter will be printed.
|
- -errlog <file>
-
Specifies the error log file used when the DocFlex Doclet is executed
without the Generator Dialog
(i.e. when -nodialog option is also specified on the command line).
By default, when an unexpected error/exception occurs during the generation and no GUI is enabled,
all details about the error are printed to the standard console.
Using this option, you can assign a separate error log file, into which the detailed ERROR REPORT is dumped
each time an error happens. Only brief messages will get on the console in that case.
(See also Error Reporting for more details.)
The error log file should be specified as an absolute or relative file pathname.
When the pathname points to a directory, it will be extended with the default
“docflex_error.log” name (for example, setting "-errlog ."
will be interpreted as 'docflex_error.log' file located in the current directory).
If the error log file does not exist, it is created in the event of error.
Otherwise, the ERROR REPORT is appended to the existed file.
In the case of any I/O error related to the error log file itself, everything will be printed
to the console (along with additional the log file error message).
- -quiet[=<true | false>]
- Suppress displaying most of the generator messages to screen.
Note: Since Java 5, this option is used by Javadoc itself as one of its core options.
If you want to suppress only DocFlex Doclet messages but still see the generation progress counter,
use -nodialog=quiet option instead.
3. Doclet GUI
Besides the command line options, DocFlex Doclet provides a different more user-friendly
way to specify most of the settings used by the generator.
If no -nodialog option specified on the
Javadoc command line, when the DocFlex Doclet starts, it invokes the following dialog:
The dialog fields are initialized with the option values specified on the
command line or loaded from the generator config file
(see also -config option).
Specifying Template
In the “Template” field, you should specify the pathname of the main template
to be interpreted by the generator.
The combo-box list contains the last used templates which allows you quickly to pick
one as soon as you need.
This field duplicate -template
option specified on the generator command line.
Setting Template Parameters
For the specified template, the “Params” button invokes
the Template Parameter Inspector, like the one shown on this screenshot:
The inspector contents is constructed dynamically from the
parameter definitions
obtained from the given template (the one specified in the “Template” field in the Generator Dialog).
The parameter values are displayed and edited according to their types.
The bottom panel displays the description of the selected parameter (which is also obtained from the template).
The first line of the description (the white text) shows the internal parameter name. Use this name in the
-P option to specify the parameter value on the Javadoc command line.
Selecting Output Format
The “Output format” combo-box allows you to select the output format
of the generated documentation. Currently, the following formats are supported:
Since all document templates
are format independent, if you have specified such a template in the “Template” field
you can freely use any output format with it.
The frameset templates
are supported only by HTML output format.
Similar to the template parameters, the “Options” button near the
“Output format” combo-box invokes the Format Option Inspector
which is specific for the selected output format.
The bottom panel in the inspector dialog displays the description of the selected option.
The first line of the description (the highlighted text) shows the internal option name.
This name should be used in the -O option to specify the format
option value on the generator command line.
The following screenshots show the option inspectors for each supported output format:
HTML Option Inspector
RTF Option Inspector
TXT Option Inspector
Specifying Output Location
- Output folder
- Use this field to specify the destination directory for the generated documentation.
See -d option for more details.
- Output file
- Use this field to specify the documentation main output file name.
See -f option for more details.
Running Generator
Once all settings prepared, the generator can be started by clicking the “Run” button.
Then, the dialog transforms and the progress panel appears:
The progress bar tracks the generation progress and shows the name of the output file being
currently generated. The “Cancel” button can stop the generation at any moment.
Once the generation has finished or cancelled, the Generator Dialog
transforms itself back to the initial state.
Then, the new settings can be entered and the generation started again. At that, the Java sources
information provided by Javadoc via
Doclet API
remains the same (as Javadoc doesn't care what exactly a particular doclet is doing with it).
This allows you during the same session to generate different kinds of documentation by different
templates, in different output formats and so on.
4. Configuration Files
|
File
|
Description
|
docflex.config
|
This is the DocFlex/Javadoc main configuration file.
It contains:
-
The locations of other configuration files used by DocFlex/Javadoc. Normally,
all of them reside in the same
'config' directory.
-
The default template directory
-
The default output directory
-
An alternative location of docflex.license file
-
The external system command to open a URL which is used to launch an external viewer
for generated output files (see -launchviewer
command line option).
The main configuration file is used for reading only and never changed.
- Default Location:
-
By default, the main configuration file is
'docflex.config' and searched
in the same directory where the DocFlex/Javadoc Java library
docflex-javadoc.jar
(or docflex-doclet.jar) is located.
If not found, the docflex.config file is created automatically
with the default settings.
- Alternative Location:
-
Can be specified using -docflexconfig option
both on Template Designer
and Javadoc command line.
|
docflex.license
|
The DocFlex/Javadoc license file, which you should receive by e-mail.
- Default Location:
-
Searched near the DocFlex/Javadoc Java library file
docflex-javadoc.jar.
| Note: |
Since the version 1.5.4, the default DocFlex/Javadoc license file is
'docflex-javadoc.license'. If that file is not found, the license
is searched in 'docflex.license' file.
|
- Alternative Location:
-
Can be assigned in the main configuration file
|
designer.config
|
The Template Designer
configuration file. It stores the designer configuration for the recently edited templates.
This file is created and maintained automatically.
- Default Location:
-
config/designer.config --
assigned in the main configuration file
- Alternative Location:
-
Can be specified using -config option
on the Template Designer command line.
|
generator.config
|
The generator configuration file; used by the Generator
to obtain all settings not specified directly on the command line.
This file is created and maintained automatically by the generator dialog.
It contains:
- The last used templates
- The values of template parameters
- The output directory and file name
- The output format options
- The launch viewer setting (see -launchviewer option)
When the generator dialog is invoked next time,
those settings are restored from the generator config file, so you don't need to re-enter them again.
The values of template parameters previously specified for one template will also
be loaded into the equally named parameters of other templates.
You can use the generator dialog to quickly prepare
a config file with the specific settings you need and, then, provide only this file
on the Javadoc command line
(using -config option) instead of specifying all those settings
directly.
- Default Location:
-
config/generator.config --
assigned in the main configuration file
- Alternative Location:
-
Can be specified using -config option
on the Javadoc command line.
|
5. Tips
Here are some tips on various topics of using DocFlex Doclet
and the documentation produced with it.
Generation phases
DocFlex generates the whole documentation in two phases:
estimation phase and generation phase.
In the estimation phase, the generator quickly passes
over all the source data and partially interprets the involved templates.
During that, it collects the names and location of all documentation files
to be created and all possible hypertarget locations within them. It also
makes an estimation of the total generation time in order to graduate
the progress bar.
During the estimation phase, only the message
"Scanning data source, please wait..." is displayed on the
generator dialog's progress bar.
Please note, the estimation phase may take some time!
On a huge project (plus a slow computer), it may last several minutes.
This does not mean, the generator hangs. Please wait!
During the generation phase, all template components are
being fully interpreted and the real output generated. The progress bar is alive
and shows what's being generated at the particular moment.
Error reporting
Both the DocFlex Generator
and the Template Designer
may encounter various unexpected error situations.
During the generation, the unexpected errors and exceptions may arise
because of the following reasons:
-
I/O errors (e.g. invalid file pathnames, disk full, etc.)
-
Template errors (when something is improperly specified in templates).
-
Data source exceptions (in the case of
DocFlex/Javadoc,
these may be exceptions thrown by the
Doclet API).
-
DocFlex core exceptions (may be caused by bugs not discovered and fixed yet).
DocFlex tries to catch all such errors/exceptions and report about them along
with the full diagnostics possible (i.e. where exactly and how the error has happened).
When the Generator Dialog is enabled,
any error is reported via the error message dialog, like the one shown on the screenshot:
The error dialog shows brief information about the error.
When more details are available, a full ERROR REPORT is created and dumped to the system clipboard.
You can easily extract it (e.g. under MS Windows, just run Notepad and press Ctrl+V).
The detailed ERROR REPORT includes:
- The general info about JVM, OS, command-line arguments, etc.
- All available error messages.
-
The Template Location Trace that shows which precisely template component was being interpreted
when the error happened.
- The Java Exception Stack Trace (when the error was caused by some unexpected Java exception).
When the DocFlex Doclet is executed without GUI
(-nodialog option is specified on the Javadoc command line),
by default, all exception/error details are printed to the standard console.
However, using -errlog option, you can specify a separate error log file.
In that case, the detailed ERROR REPORT will be dumped in that file; only brief messages will get on the console.
Getting your images into RTF
Since DocFlex/Javadoc version 1.4.7, any your images embedded in Java comments
using <IMG> tags will be picked automatically from their original
locations, where you have prepared them for the standard Javadoc, and inserted into
the generated RTF.
Updating RTF fields in MS Word
The RTF documentation generated by the provided templates heavily uses document
fields (for such things like page number references,
number of pages and so on).
When you load the generated RTF in MS Word, to have the fields display the correct values,
you will need to update them. To do this, please type: Ctrl+A, then F9.
Including RTF in larger MS Word document
Your task is the following. You have prepared a certain static Word document
and need to include into it the output generated with DocFlex so as each time
your Java API documentation is regenerated, the larger Word document is updated as well.
Here is how you can do that.
You should insert into your Word document an INCLUDETEXT field.
Using the MS Word menu, it may be done like this:
Insert | Field... | Categories: Links and References | Field names: Include Text
In the Word document (when “Toggle Field Codes” switched on),
the field will look like the following:
{ INCLUDETEXT "C:\\blah\\blah\\PlainDoc.rtf" \* MERGEFORMAT }
Here, the RTF document generated with DocFlex should be found by the path:
C:\blah\blah\PlainDoc.rtf
Make sure you use double slashes in the field's pathname
(as a single slash is used to start a command or an option)!
After that, you can generate with DocFlex the JavaDoc RTF.
To prepare the result big document, open it with MS Word.
Then, press Ctrl+A (select all) and F9 (to update fields).
Generating RTF for OpenOffice.org
Since DocFlex/Javadoc version 1.4, you can launch DocFlex/Javadoc under Linux
(both Template Designer and
doclet).
The RTF generated by DocFlex/Javadoc may be open with Linux OpenOffice.org Writer, which renders
it almost the same as MS Word (see
Examples | RTF in OpenOffice.org).
To make the RTF look better under OpenOffice.org, before generating it, please uncheck
“Tune output for MS Word” option in RTF Options dialog
(or using
'-o:rtf.tuneForMSWord=false' formatting option
on the Javadoc command line).
Here are the details about this option:
|
When “Tune output for MS Word” option is selected,
the generator will adjust some RTF formatting settings specifically for MS Word.
Although Microsoft is the originator of RTF format, the MS Word itself
appears to have some oddities of rendering certain RTF settings,
even though those settings may well follow the RTF specification.
For instance, when displaying the paragraph or table borders, their
horizontal positions may be shifted (e.g. when MS Word interprets
horizontal margins of a paragraph, it draws the paragraph borders and
paddings within the specified margin space but not within the paragraph
content as it might be natural).
To overcome this, in such cases, we adjust the initial dimensions in
the opposite way so as the result formatting would look properly in MS Word
(e.g. to make the actual paragraph margin look as intended the margin width
specified in RTF is increased by the paragraph border and padding widths).
However, when you generate RTF to display it primarily not in MS Word
but rather in different viewers or editors (e.g. OpenOffice.org under Linux),
which interpret the original RTF specification more literally,
those specific adjustments may cause a visible distortion of the intended
formatting of the document.
In such cases, we recommend to uncheck this option.
|
Omitting package qualifiers
Since DocFlex/Javadoc, version 1.1, the provided
basic templates
include two additional parameters to suppress appearing package qualifiers in the generated
documentation in such places like method parameters, field types and so on:
-
Omit package qualifiers started with
-
Omit all package qualifiers
See the full description of those parameters at
Basic Templates | PlainDoc.tpl | Parameters.
Exclude classes and methods with a custom tag
Since version 1.3, a new template parameter "Exclude by tags"
(exclude.byTags)
has been introduced in the basic templates.
This parameter can be used to exclude from the generated documentation classes, fields and methods
with specified tags.
See the parameter description for more details.
Inserting "Mark of the Web" comment in HTML
When you run generated HTML documentation from a local drive using Internet Explorer with Windows XP SP2,
the Information Bar may indicate that active content (the JavaScript in the HTML) has been blocked.
To avoid this problem, according to Microsoft, a Mark of the Web (MOTW) comment should be inserted in all generated
HTML documents.
Since version 1.3, DocFlex/Doclet is able to insert the generic MOTW automatically (see code below).
This is controlled by "Add Mark of the Web" option
(see HTML Options dialog).
You may also program inserting MOTW by yourself using a special HTML pattern file.
To do so, you should create a separate HTML file with the following content:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0014)about:internet -->
<HTML>
<HEAD>
<!-- docflex-html-head -->
</HEAD>
<BODY>
<!-- docflex-html-body -->
</BODY>
</HTML>
Then, specify location of this file in the “HTML pattern file” field within the
HTML Options dialog (or using
'-o:html.documentPatternFile' formatting option
on the Javadoc command line).
DocFlex will produce all HTML documents using the specified HTML pattern file with the
lines <!-- docflex-html-head --> and
<!-- docflex-html-body --> replaced with the actual generated output.
For more information about MOTW, please refer to Microsoft MSDN web-site:
http://msdn.microsoft.com
|