XML Documentation for Delphi Code
Go Up to Command Line Utilities Index
The three Delphi compilers (DCC32.EXE, DCC64.EXE and DCCOSX.EXE) can generate XML documentation for the compiled source code.
- To enable this feature from the command line, run DCC32.EXE and set the
--docoption (see the example below). - To enable this feature from the IDE, go to Project > Options > Delphi Compiler > Compiling > Other Options and set the Generate XML Documentation flag.
The compiler-generated XML documentation is created from the compiler's internal representation of classes, methods, variables, and so on. Do not confuse it with the manually written XML documentation (see XML Documentation Comments).
Note: You can generate HTML documentation for a specific Delphi (or C++) RAD Studio project: see Generating Project Documentation.
The format (schema) of the XML file is described in XML Compiler Output Global Declarations.
Contents |
Example
File "C:\file.pas" contains the definition of:
- An enumeration: TFocus
- A class: TVideoCamera
DCC32.EXE command-line invocation:
dcc32 --doc "C:\file.pas"
Enumeration
TFocus definition:
/// <summary> /// For objects located closer than 10 meters, use fcNear; /// otherwise use fcFar. /// </summary> TFocus = (fcNear, fcFar);
Generated XML documentation:
<const name="fcNear" type="TFocus" file="C:\file.pas" line="13"> <value> fcNear </value> </const> <const name="fcFar" type="TFocus" file="C:\file.pas" line="13"> <value> fcFar </value> </const> <enum name="TFocus" file="C:\file.pas" line="13"> <devnotes> <summary> For objects located closer than 10 meters, use fcNear; otherwise use fcFar. </summary> </devnotes> <element value="0" name="fcNear" file="C:\file.pas" line="13" /> <element value="1" name="fcFar" file="C:\file.pas" line="13" /> </enum>
Note that the XML documentation comments are included in the compiler-generated XML documentation (see the devnotes elements).
Class
TVideoCamera definition:
TVideoCamera = class private FFocus: TFocus; public property Focus: TFocus read FFocus write FFocus; procedure SetFocus(ADistance: Integer); end; procedure TVideoCamera.SetFocus(ADistance: Integer); begin if ADistance < 10 { meters } then FFocus := fcNear else FFocus := fcFar; end;
Generated XML documentation (some members inherited from TObject are removed for clarity):
<class name="TVideoCamera" file="C:\file.pas" line="15"> <ancestor name="TObject" namespace="System"> <methodref name="Create" visibility="public" procflags="constructor"> </methodref> <methodref name="Free" visibility="public"> </methodref> </ancestor> <members> <field name="FFocus" type="TFocus" visibility="private" size="1" offset="4" file="C:\file.pas" line="17" /> <property name="Focus" visibility="public" read="FFocus" write="FFocus" type="TFocus" file="C:\file.pas" line="19" /> <procedure name="SetFocus" visibility="public" file="C:\file.pas" line="20"> <parameters> <parameter name="ADistance" type="Integer" /> </parameters> </procedure> </members> </class>
See Also
- XML Documentation for C++ Code
- XML Documentation Comments
- Generating Project Documentation (HTML documentation)
- XML Compiler Output Global Declarations (syntax)