Mac OS X Reference Library Apple Developer Connection spyglass button

HeaderDoc Tags

Tags, depending on type, generally require either one field of information or two:

In the tables in this chapter, the “Fields” column indicates the number of textual fields each type of tag takes.

Introduction to HeaderDoc Comments and Tags

HeaderDoc comments are of the form:

 
/*!
 This is a comment about FunctionName.
*/
char *FunctionName(int k);

In their simplest form (as above) they differ from standard C comments only by the addition of the ! character next to the opening asterisk.

In shell scripts or Perl scripts, the syntax is slightly altered because of the lack of multi-line comments and the need to avoid conflicting with the shell magic (#!) syntax. Shell script and Perl script HeaderDoc comments look like this:

# /*!
#     This is a comment about FunctionName.
#  */
sub FunctionName($$)
...

Historically, HeaderDoc tags were required to begin with an introductory tag that announces the type of API being commented (@function, below). You can find a complete list of these tags in “Top-Level HeaderDoc Tags.” Beginning in HeaderDoc 8, these top-level tags became optional. However, providing these tags can, in some cases, be used to cause HeaderDoc to document something in a different way. One example of this is the use of the @class tag to modify the markup of a typedef, as described in “Overriding the Default Data Type: C Pseudoclass Tags.”

The following example shows the historical syntax:

/*!
 @function FunctionName
 This is a comment about FunctionName.
*/
char *FunctionName(int k);

Following the optional top-level @function tag, you typically provide introductory information about the purpose of the class. You can divide this material into a summary sentence and in-depth discussion (using the @abstract and @discussion tags), or you can provided the material as an untagged block of text, as the examples below illustrate. You can also add @throws tags to indicate that the class throws exceptions or add an @namespace tag to indicate the namespace in which the class resides.

Listing 2-1  Example of documentation with @abstract and @discussion tags

/*!
 @class IOCommandGate
 @abstract Single-threaded work-loop client request mechanism.
 @discussion An IOCommandGate instance is an extremely light weight mechanism that
 executes an action on the driver's work-loop...
 @throws foo_exception
 @throws bar_exception
 @namespace I/O Kit (this is just a string)
 @updated 2003-03-15
*/
class IOCommandGate: public IOEventSource
{
...
}

Listing 2-2  Example of documentation as a single block of text

/*!
 @class IOCommandGate
 A class that defines a single-threaded work-loop client request mechanism. An IOCommandGate
 instance is an extremely light weight mechanism that executes an action on the driver's work-loop...
 @abstract Single-threaded work-loop client request mechanism.
 @throws foo_exception
 @throws bar_exception
 @updated 2003-03-15
*/
class IOCommandGate: public IOEventSource
{
...
}
Note: Once you have specified a non-inline tag such as @abstract, that tag is active until the next non-inline tag. This means that general discussion paragraphs can only occur in one of three places:

At the beginning of the comment.

Immediately following an introductory top-level tag such as @class.

Immediately following a discussion tag (@discussion).

You can also use additional JavaDoc-like tags within the HeaderDoc comment to identify specific fields of information. These tags will make the comments more amenable to conversion to HTML. For example, a more complete comment might look like this:

 
 /*!
 @function HMBalloonRect
 @abstract Reports size and location of help balloon.
 @discussion Use HMBalloonRect to get information about the size of a help balloon
 before the Help Manager displays it.
 @param inMessage The help message for the help balloon.
 @param outRect The coordinates of the rectangle that encloses the help message.
 The upper-left corner of the rectangle has the coordinates (0,0).
 */

Tags are indicated by the @ character, which must generally appear as the first non-whitespace character on a line (with a few notable exceptions). If you need to include an at sign in the output (to put your email address in a class discussion, for example), you can do this by prefixing it with a backslash, that is, \@.

The first tag in a comment announces the API type of the declaration (function, struct, enum, and so on). This tag is optional. If you leave it out, HeaderDoc will pick up this information from the declaration immediately following the comment.

The next two lines (tagged @abstract and @discussion) provide documentation about the API element as a whole. The abstract can be used in summary lists, and the discussion can be used in the detailed documentation about the API element.

The abstract and discussion tags are optional, but encouraged. Their use enables various improvements in the HTML output, such as summary pages. However, if there is untagged text following the API type tag and name (@function HMBalloonRect, above) it is assumed to be a discussion. With such untagged text, HeaderDoc assumes that the discussion extends from the end of the API-type comment to the next HeaderDoc tag or to the end of the HeaderDoc comment, whichever occurs first.

HeaderDoc understands some variants in commenting style. In particular, you can have a one-line comment like this:

 
 /*! @var settle_time Latency before next read. */
 

You can also use leading asterisks on each line of a multiline comment:

 
 /*!
 * @function HMBalloonRect
 * @abstract Reports size and location of help ballon.
 * @discussion Use HMBalloonRect to get information about the size of a help balloon
 * before the Help Manager displays it.
 * @param inMessage The help message for the help balloon.
 * @param outRect The coordinates of the rectangle that encloses the help message.
 * The upper-left corner of the rectangle has the coordinates (0,0).
 */
 

If you want to specify a line break in the HTML version of a comment, use two newline characters between lines rather than one. For example, the text of the discussion in this comment:

 
 /*!
 * @function HMBalloonRect
 * @discussion Use HMBalloonRect to get information about the size of a help balloon
 * before the Help Manager displays it.
 *
 * Always check the help balloon size before display.
 */
 

will be formatted as two paragraphs in the HTML output:

HMBalloonRect

OSErr HMBalloonRect (const HMMessageRecord *inMessage, Rect *outRect);

Use HMBalloonRect to get information about the size of a help balloon before the Help Manager displays it.

Always check the help balloon size before display.

Multiword Names

Top-level HeaderDoc tags, such as @header and @function can take multiword names. This is particularly useful for documenting anonymous types for enumerations, for example. However, HeaderDoc normally has no way to know whether a line containing multiple words is a multiword name or a name followed by a discussion.

There are two ways to get a multiword name. One way is to add a discussion tag, like this:

Listing 2-3  Example of multiword names using @discussion

 /*!
 * @enum example enum
 * @discussion This is a test, this is only a test.
 *
 * Because we included an \@discussion tag, the name of the enum is
 * "example enum".
 */

The other way is to simply add a line break after the name.

Listing 2-4  Example of multiword names using multiple lines

 /*!
 * @enum example enum
 * This is a test, this is only a test.
 *
 * Because the discussion contains multiple lines, the name of the enum is
 * "example enum".
 */

Automatic Tagging

Beginning in HeaderDoc 8, certain tags are often not needed. These include:

Numbered lists

It is no longer necessary to mark up numbered lists with <ol><li>. HeaderDoc will automatically detect numbered lists.

Declaration types

Declaration type tags such as @function, @class, and @typedef are no longer required unless you are trying to override HeaderDoc’s normal behavior (such as using @class or @interface to change the display of a typedef struct.

Availability macros

It is no longer necessary to ignore availability macros with @ignore. The file Availability.list in the HeaderDoc modules directory contains a mapping of availability macros to strings. When any macros described in this file appear in a declaration, the corresponding text will automatically be added to its documentation as an availability attribute.

You can add your own availability macros by adding them to the Availability.list file or by adding an @availabilitymacro block in your headers.

Specifying Information About Frameworks

Framework documentation should be inserted into a file ending in .hdoc. Running HeaderDoc on this file generates a documentation tree with special hidden markup that gatherHeaderDoc will insert into the appropriate place within your TOC template (or at the top of the built-in template).

Table 2-1  

Tag

Example

Identifies

Fields

@framework

@framework Kernel Framework

The name of the framework.

1

@abstract

@abstract In-kernel device driver framework

A short string that briefly describes a framework. This should not contain multiple lines (at least for the default template) for aesthetic reasons. Save the detailed descriptions for the @discussion tag.

1

@discussion

@discussion The kernel framework contains functions useful to in-kernel device drivers.

A detailed description of the framework. This may contain multiple paragraphs, and can contain HTML markup.

1

Specifying Information About an Entire Header or Source File

Often, you'll want to add a comment for the header as a whole in addition to comments for individual API elements. For example, if the header declares API for a specific manager (in Mac OS terminology), you may want to provide introductory information about the manager or discuss issues that apply to many of the functions within the manager's API. Likewise, if the header declares a C++ class, you could discuss the class in relation to its superclass or subclasses.

The value you give for the @header tag serves as the title for the HTML pages generated by headerDoc2HTML. The text you associate with the @header tag is used for the introductory page of the HTML website the script produces.

In general, however, you will not specify a filename in the @header tag, and will simply let HeaderDoc substitute the filename. Note that you must follow @header by a line break; otherwise, the first line of your documentation will be treated as if it were the name of the header.

Listing 2-5  Example of @header tag

 
/*!
 @header Repast Manager
 The Repast Manager provides a functional interface to the repast driver.
 Use the functions declared here to generate, distribute, and consume meals.
 @copyright Dave's Burger Palace
 @updated 2003-03-14
 @meta http-equiv="refresh" content="0;http://www.apple.com"
*/

Additional HeaderDoc Tags

To enhance readability of this document, the tags are organized into groups by tag level. In HeaderDoc, there are two levels of tagging: top level tags and second level tags.

Top level tags must appear at the beginning of a HeaderDoc comment. These tags represent declaration types. For example, the @function tag tells HeaderDoc that you are about to declare a function. These tags are optional.

In most cases, second level tags can appear anywhere in a HeaderDoc comment. The one exception is the @constant tag because it conflicts with a top level tag. These tags give HeaderDoc additional information about the declaration, such as specifying an abstract or a parameter description.

Note: Support for second level tags at the beginning of HeaderDoc comments was added in HeaderDoc version 8.6. For compatibility with previous versions, you should always begin comments with either a top level tag or an untagged discussion.

Top-Level HeaderDoc Tags

Top-level HeaderDoc tags tell HeaderDoc what API type to expect after the declaration. These trace their roots back to HeaderDoc 7 and prior releases in which HeaderDoc could not interpret a declaration without these hints.

In HeaderDoc 8 and later, top level tags are always optional. Some of these tags provide useful features, however, such as availability macro declarations, API element groupings, and framework-level and header-level documentation.

Most top-level HeaderDoc tags are treated as a term and definition list. This means that if you specify multiple words on a single line, the first will be treated as the name, and the remaining words will be treated as the discussion. However, if the arguments span multiple lines, the entire first line will be treated as a multi-word title. Similarly, if you specify an @discussion tag explicitly, the entire line will be treated as a multi-word title. For more information, see “Multiword Names.”

A few top-level HeaderDoc tags do not support a discussion section. These tags automatically treat the remainder of the line as a multi-word name. These tags are: @functiongroup, @group, @methodgroup

Table 2-2  Top-level HeaderDoc tags

Tag

Example

Identifies

@availabilitymacro

@availabilitymacro AVAILABLE_IN_MYAPP_1_0_AND_LATER

Available in MyApp v1.0 and later.

This tag tells HeaderDoc that whenever the named token appears in a declaration, the token should be deleted and the “Availability:“ attribute for that declaration should be set to the string that follows.

@class

@class myClass

The name of the class.

@category

@category myCat(owningClass)

The full name of the category, as declared in the header. For example, “MyClass(MyCategory)”. HeaderDoc uses the “MyClass” portion of the name to identify the associated class.

@protocol

@protocol myProtocol

The name of the protocol.

@const or @constant

@constant MyConst

Specifies the name of the constant.

@define

@defined

@define MyDefine

Name of the macro.

@function

@function myFunc

The name of the function.

Note: For historical reasons, you can also mark up function-like macros with the @function tag. However, this is not recommended.

@enum

@enum MyEnum

The name of the enumeration. This is usually enum's tag, if it has one. Otherwise, supply a name you want to have the constants grouped under in the documentation.

The member fields should be enumerated with the @constant tag.

@file

@file Filename

Discussion goes here.

See @header.

@framework

@framework Kernel Framework

The name of the framework. Must be in a file ending in .hdoc. This name is inserted as part of the master TOC (landing page) generation process wherever the $$framework@@ tag appears.

@functiongroup

@functiongroup My Function Group

The name of the function group.

@header

@header Repast Manager

The name under which the API is categorized. Leave the name blank to just use the header filename.

The following additional subtags are available:

  • @CFBundleIdentifier

  • @charset

  • @compilerflag

  • @encoding

  • @flag

  • @ignore

  • @ignorefuncmacro

  • @preprocinfo

  • @related

@method

@method myMethod:

The name of the Objective-C method.

Note: For historical reasons, you can also mark up C++ methods with the @method tag. However, this is not recommended.

@property

@property myPropName

The name of the Objective-C property.

@struct

@struct myStruct

The name of the structure. (Also known as the structure’s tag.)

@typedef

@typedef MyType

The name of the defined type.

@union

@union myUnion

The name of the union. (Also known as the union's tag.)

@var

@var myVariable

The name of a global variable or class member variable.

Examples of Top-Level Tags and Type-Specific Second-Level Tags

Availability Macro Tags

Listing 2-6  Example of @availabilitymacro tag

/*!
 @availabilitymacro AVAILABLE_IN_MYAPP_1_0_AND_LATER This function is available in version 1.0 and later of MYAPP.
*/

This is usually followed by a #define or similar, but that is not necessary. This HeaderDoc comment is a standalone comment—that is, it does not cause the code after it to be processed in any way. If you want to mark a #define as being an availability macro, you should follow this tag with a second HeaderDoc comment for the #define itself.

Class Tags

Here are some examples of classes in different languages:

Listing 2-7  Example of @class tag in C++

/*!
 @class myClass
 @discussion This is a discussion.
 It can span many lines or paragraphs.
*/
 class myClass : public mySuperClass;
 

Listing 2-8  Example of @class tag in Objective-C

/*!
 @class myInterface
 @discussion This is a discussion.
 It can span many lines or paragraphs.
*/
@interface myInterface : NSObject
@end

Listing 2-9  Example of @protocol tag in Objective-C

/*!
 @protocol myProtocol
 @discussion This is a discussion.
 It can span many lines or paragraphs.
*/
@protocol myProtocol
@end
 

Listing 2-10  Example of @category tag in Objective-C

/*!
 @category myCategory(myMainClass)
 @discussion This is a discussion.
 It can span many lines or paragraphs.
*/
@interface myCategory(myMainClass)
@end
 

Classes have many special tags associated with them for convenience. These include:

Table 2-3  

Tag

Description

Usage

@classdesign

Description of any common design considerations that apply to this class, such as consistent ways of handling locking or threading.

block

@coclass

Class with which this class was designed to work.

attribute (term & definition)

@dependency

External resource that this class depends on (such as a class or file).

attribute

@helper or @helperclass

A helper class used by this class.

attribute (term & definition)

@helps

If this is a helper class, a short description of classes that this class was designed to help.

attribute

@instancesize

The typical size of each instance of the class.

attribute

@ownership

Describes the ownership model to which this class conforms. For example, “MyClass objects are owned by the MyCreatorClass object that created them.“

block

@performance

Describes special performance characteristics for this class. For example, “This class is optimized for the Velocity Engine,“ or “This class is strongly discouraged in high-performance contexts.“

block

@security

Describes security considerations associated with the use of this class

block

@superclass

Overrides superclass name—see note below.

attribute

The tag types are described in more detail in “Second Level HeaderDoc Tags.”

Note: The @superclass tag is not generally required for superclass information to be included. The @superclass tag has two purposes:

To add "superclass" info to a C pseudo-classes such as a COM interface (a typedef struct containing function pointers).

To enable inclusion of superclass functions, types, etc. in the subclass docs. The superclass MUST be processed before the subclass (earlier on the command line or higher up in the same file), or this may not work correctly.

Tags for C++ Classes

Within a C++ class declaration, HeaderDoc allows some additional tags, as describe below.

Additional Tags for C++ Class Declarations

Within a C++ class comment, HeaderDoc understands all the tags for C header comments. It also adds the @templatefield tag.

Table 2-4  

Tag

Identifies

Fields

@templatefield

The name of the parameter followed by the description.

2

For C++ template classes, if you want to document the template type parameters, you should use the @templatefield tag. You should also be sure to define the class using @template instead of @class.

The @templatefield tag can also be used to document template parameters for C++ template functions.

Listing 2-11  Example of @templatefield tag

/*! @class mystackclass
 @templatefield Tthe data type stored in this stack */
 
 template <T> class mystackclass
 

For more usage examples, see the ExampleHeaders folder that accompanies the HeaderDoc distribution.

Constant Tags

Listing 2-12  Example of @const tag

 /*!
 @const kCFTypeArrayCallBacks
 @abstract Predefined CFArrayCallBacks structure containing a set of callbacks appropriate...
 @discussion Extended discussion goes here.
 Lorem ipsum....
 */
 const CFArrayCallBacks kCFTypeArrayCallBacks;

#define Tags
Table 2-5  Second-level tags specific to #define declarations

Tag

Identifies

Fields

@parseOnly

Marks macro as “hidden”. The macro will be parsed and used by the C preprocessor, but will not be included as a separate #define entry in the resulting documentation.

0

Listing 2-13  Example of @defined tag

 /*!
 @defined TRUE
 @abstract Defines the boolean true value.
 @parseOnly
 @discussion Extended discussion goes here.
 Lorem ipsum....
 */
 #define TRUE 1
 

For more usage examples, see the ExampleHeaders folder that accompanies the HeaderDoc distribution.

Enum Tags
Table 2-6  Second-level tags specific to enum declarations

Tag

Identifies

Fields

@constant

@const

A constant within the enumeration.

2

Note: The @constant and @const tags are also top-level tags. If you are using them to describe a field within an enumeration, they cannot be the first thing in the comment. If you place them at the beginning of the comment, you will get unexpected behavior.

Listing 2-14  Example of @enum tag

/*!
 @enum Beverage Categories
 @abstract Categorizes beverages into groups of similar types.
 @constant kSoda Sweet, carbonated, non-alcoholic beverages.
 @constant kBeer Light, grain-based, alcoholic beverages.
 @constant kMilk Dairy beverages.
 @constant kWater Unflavored, non-sweet, non-caloric, non-alcoholic beverages.
 @discussion Extended discussion goes here.
 Lorem ipsum....
*/
enum {
 kSoda = (1 << 6),
 kBeer = (1 << 7),
 kMilk = (1 << 8),
 kWater = (1 << 9)
}
Function and Method Tags

For C functions, use the @function tag. For methods declared in an Objective-C class, protocol, or category, use the @method tag. For C++ methods, you can use either tag.

Table 2-7  Second-level tags specific to function and method declarations

Tag

Identifies

Fields

@param

Each of the function's parameters.

2

@result

The return value of the function. Don't include if the return value is void or OSERR

1

@templatefield

Each of the function’s template fields (C++).

2

@throws

Include one @throws tag for each exception thrown by this function (in languages that support exceptions).

1

Listing 2-15  Example of @function tag

/*!
 @function ConstructBLT
 @abstract Creates a Sandwich structure from the supplied arguments.
 @param b Top ingredient, typically protein-rich.
 @param l Middle ingredient.
 @param t Bottom ingredient, controls tartness.
 @param mayo A flag controlling addition of condiment. Use YES for condiment,
 HOLDTHE otherwise.
 @throws peanuts
 @templatefield K The type of BLT to be generated (I want a BLT float)
 @result A pointer to a Sandwich structure. Caller is responsible for
 disposing of this structure.
 @discussion Extended discussion goes here.
 Lorem ipsum....
*/
Sandwich *ConstructBLT<K>(Ingredient b, Ingredient l, Ingredient t, Boolean mayo);

Listing 2-16  Example of @method tag

/*!
 @method dateWithString:calendarFormat:
 @abstract Creates and returns a calendar date initialized with the date
 specified in the string description.
 @discussion [An extended description of the method...]
 @param description A string specifying the date.
 @param format Conversion specifiers similar to those used in strftime().
 @result Returns the newly initialized date object or nil on error.
*/
+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format;
 

For more usage examples, see the ExampleHeaders folder that accompanies the HeaderDoc distribution.

Grouping Tags

Listing 2-17  Example of @functiongroup tag

/*!
 @functiongroup Core Functions
*/
/*!
 @methodgroup Core Methods
*/
/*!
 @group Core API
*/
 

API groups are not required, but they allow you to organize a large number of functions into near groupings. Grouping tags remain in effect until the next grouping tag of the same type.

The @group tag provides grouping for all API elements except for methods and functions. In addition, until HeaderDoc encounters the @functiongroup or @methodgroup tag, functions and methods are also grouped by @group tag. In effect, the @functiongroup or @methodgroup tag provides a way to override the @group tag in a way that only affects functions and methods.

Note: The @functiongroup and @methodgroup tags modify the groupings for both functions and methods. The two names are provided strictly for naming consistency; both tags behave identically.

If you need to put functions or other API elements in different parts of the header into the same group, simply give them the same name (with the same capitalization, punctuation, spacing, etc.), and it will merge the two function groups into one.

Any functions or other API elements encountered before the first @group or @functiongroup are considered part of the “empty” group. These functions will be listed before any grouped functions or API elements.

Struct and Union Tags

Table 2-8  Second-level tags specific to struct and union declarations

Tag

Identifies

Fields

@field

A field in the structure.

2

Listing 2-18  Example of @struct tag

/*!
 @struct TableOrigin
 @abstract Locates lower-left corner of table in screen coordinates.
 @field x Point on horizontal axis.
 @field y Point on vertical axis
 @discussion Extended discussion goes here.
 Lorem ipsum....
*/
struct TableOrigin {
 int x;
 int y;
}
Typedef Tags

The tags that can appear after a “@typedef” tag depend on the type that you are defining, and are inherited from the valid tags for that enclosed type. The tags can include any of the following:

Listing 2-19  Typedef for a simple struct

/*!
 @typedef TypedefdSimpleStruct
 @abstract Abstract for this API.
 @field firstField Description of first field
 @field secondField Description of second field
 @discussion Discussion that applies to the entire typedef'd simple struct.
 Lorem ipsum....
*/
 
typedef struct _structTag {
 short firstField;
 unsigned long secondField
} TypedefdSimpleStruct;

Listing 2-20  Typedef for an enumeration

/*!
 @typedef TypedefdEnum
 @abstract Abstract for this API.
 @constant kCFCompareLessThan Description of first constant.
 @constant kCFCompareEqualTo Description of second constant.
 @constant kCFCompareGreaterThan Description of third constant.
 @discussion Discussion that applies to the entire typedef'd enum.
 Lorem ipsum....
*/
typedef enum {
 kCFCompareLessThan = -1,
 kCFCompareEqualTo = 0,
 kCFCompareGreaterThan = 1
} TypedefdEnum;

Listing 2-21  Typedef for a simple function pointer

/*!
 @typedef simpleCallback
 @abstract Abstract for this API.
 @param inFirstParameter Description of the callback's first parameter.
 @param outSecondParameter Description of the callback's second parameter.
 @result Returns what it can when it is possible to do so.
 @discussion Discussion that applies to the entire callback.
 Lorem ipsum...
*/
typedef long (*simpleCallback)(short inFirstParameter, unsigned long long *outSecondParameter);

Listing 2-22  Typedef for a struct containing function pointers

/*! @typedef TypedefdStructWithCallbacks
 @abstract Abstract for this API.
 @discussion Defines the basic interface for Command DescriptorBlock (CDB) commands.
 
 @field firstField Description of first field.
 
 @callback setPointers Specifies the location of the data buffer. The setPointers function has the following parameters:
 @param cmd A pointer to the CDB command interface.
 @param sgList A pointer to a scatter/gather list.
 @result An IOReturn structure which returns the return value in the structure returned.
 
 @field lastField Description of the struct's last field.
*/
typedef struct _someTag {
 short firstField;
 IOReturn (*setPointers)(void *cmd, IOVirtualRange *sgList);
 unsigned long lastField
} TypedefdStructWithCallbacks;

Variable Tags

The @var tag should be used when marking up global variables, class variables, and instance variables (as opposed to actual declaration of new data types).

Listing 2-23  Example of @var tag

/*! @var we_are_root
    @abstract Tells whether this device is the root power domain
    @discussion TRUE if this device is the root power domain.
    For more information on power domains....
 */
 
 bool we_are_root;

Second Level HeaderDoc Tags

The tags in the table below (except as noted)) can be used in any comment for any data type, function, header, or class.

The different types of tags are:

In addition, some attribute tags are labeled as “term & definition” style. This means that they behave just like top level tags in terms of their format. This format is described in “Multiword Names.”

Table 2-9  

Tag

Example

Identifies

Usage

@abstract

@abstract write the track to disk

A short string that briefly describes a function, data type, and so on. This should not contain multiple lines (because it will look odd in the mini-TOCs). Save the detailed descriptions for the discussion tag.

block

(single short sentence recommended)

@availability

@availability 10.3 and later

A string that describes the availability of a function, class, and so on.

attribute

@brief

@brief write the track to disk

Equivalent to @abstract. Provided for better Doxygen compatibility.

block

(single short sentence recommended)

@callback

@callback testFunc The test function to call.

Specifies the name and description of a callback field in a structure.

attribute (term & definition)

in struct declaration only

@classdesign

@classdesign Multiple paragraphs go here.

Description of any common design considerations that apply to this class, such as consistent ways of handling locking or threading.

block

in class declarations only

@coclass

@coclass myCoClass Description of how class is used

Class with which this class was designed to work.

attribute (term & definition)

in class declarations only

@charset

@charset utf-8

Sets the character encoding for generated HTML files (same as @encoding).

HTML tagging

in @header only

@constant

@const

@const kSilly A silly return value.

A constant within an enumeration.

attribute (term & definition)

enum declarations only

@copyright

@copyright Apple

Copyright info to be added to each page. This overrides the config file value and may not span multiple lines.

page footer

in @header only

@compilerflag

@compilerflag -lssl

Compiler flag that should be set when using functions and types in this header.

attribute (term & definition)

in @header only

@CFBundleIdentifier

@CFBundleIdentifier org.mklinux.driver.test

Which kernel subcomponent, loadable extension, or application bundle contains this header

attribute

in @header only

@dependency

@dependency This depends on the FooFramework framework.

External resource that this class depends on (such as a class or file).

attribute

in class declarations only

@deprecated

@deprecated in version 10.4

String telling when the function, data type, etc. was deprecated.

attribute

in class declarations only

@discussion

@discussion This is what this function does. @some_other_tag

A block of text that describes a function, class, header, or data type in detail. This may contain multiple paragraphs. @discussion may be omitted, as described above.

@discussion must be present if you have a multiword name for a data type, function, class, or header.

An @discussion block ends only when another block begins, such as an @param tag.

block

@encoding

@encoding utf-8

Sets the character encoding for generated HTML files (same as @charset).

HTML Tagging

in @header only

@field

@field isOpen Specifies whether the file descriptor is open.

A field in a structure declaration.

attribute (term & definition)

@flag

@flag -lssl

The SSL Library

Same as @compilerflag.

attribute (term & definition)

in @header only

@helper or @helperclass

@helper myHelperClass

Description of how class is used.

A helper class used by this class.

attribute (term & definition)

in class declarations only

@helps

@helps This class provides additional stuff that does something.

If this is a helper class, a short description of classes that this class was designed to help.

attribute

in class declarations only

@ignore

@ignore API_EXPORT

Tells HeaderDoc to delete the specified token.

parsing

in @header only

@ignorefuncmacro

@ignorefuncmacro __P

Tells HeaderDoc to unwrap occurrences of the specified function-like macro.

parsing

in @header only

@indexgroup

@indexgroup Name of Group

Provides grouping information within the master TOC (landing page).

In the absence of an @indexgroup tag, the index group is inherited from the enclosing class or header.

block (short strings, please)

@instancesize

@instancesize Eight hundred megabytes and constantly swapping.

The typical size of each instance of the class.

attribute

in class declarations only

@link

@link //apple_ref/c/func/function_name link text goes here @/link

or

@link function_name link text goes here @/link

Allows you to insert a link request for an API ref. If the link target is part of the same .h file, you can do this by using only the name of the function or data type. If it is in a separate file (or if there are multiple matches for a given name), you must explicitly specify which API ref to use.

Because the headerDoc2HTML script does not know the actual target for these links, it inserts comments into the output. You must then run gatherHeaderDoc to actually turn those comments into working links.

inline

@meta

@meta robots index,nofollow

or

@meta http-equiv="refresh" content="0;http://www.apple.com"

Meta tag info to be added to each page. This can be either in the form @meta <name> <content> or @meta <complete tag contents>, and may not span multiple lines.

HTML tagging

in @header only

@namespace

@namespace BSD Kernel

String describing the namespace in which the function, data type, etc. exists.

attribute

@noParse

@noParse

Disables C preprocessor parsing of a macro. The macro will still be included as a #define entry in the resulting documentation.

parsing

in #define declarations only

@ownership

@ownership MyClass objects are owned by the MyCreatorClass object that created them.

Describes the ownership model to which this class conforms.

block

in class declarations only

@param

@param myValue The value to process.

The name and description of a parameter to a function or callback.

attribute (term & definition)

in function, method, and callback declarations only

@parseOnly

@parseOnly

Marks macro as “hidden”. The macro will be parsed and used by the C preprocessor, but will not be included as a separate #define entry in the resulting documentation.

parsing

in #define declarations only

@performance

@performance This class is strongly discouraged in high-performance contexts.

Describes special performance characteristics for this class.

block

in class declarations only

@preprocinfo

@preprocinfo This header uses the DEBUG macro to enable additional debugging.

Description of behavior when preprocessor macros are set (-DDEBUG, for example).

block

in @header only

@related

@related Sixth cousin of Kevin Bacon.

Indicates another header that is related to this one. You may use multiple @related tags.

Similar to the @seealso tag.

attribute (term & definition)

in @header only

@result

@result Returns 1 on success, 0 on failure..

Describes the return values expected from this function.

attribute (term & definition)

in function, method, and callback declarations only

@return

@return Returns 1 on success, 0 on failure..

Same as @result.

attribute (term & definition)

in function, method, and callback declarations only

@security

@security This class is feeling insecure today.

Describes security considerations associated with the use of this class

block

in class and header declarations only

@see

@see apple_ref Title for link

Adds a “See:” entry to the attributes. Arguments are the same as @link.

attribute

@seealso

@seealso apple_ref Title for link

Adds a “See Also:” entry to the attributes. Arguments are the same as @link.

attribute

@superclass

@superclass fasterThanASpeedingRuntime

Overrides superclass name—see note below.

attribute

in class declarations only

@textblock

@textblock My text goes here @/textblock

Treat everything until the trailing @/textblock as raw text, preserving initial spaces and line breaks, and converting “<” and “>” to “&lt;” and “&gt;”.

Note that this tag does not automatically insert <pre> or <tt>. You may wrap it with whatever formatting you choose.

inline

@templatefield

@templatefield base_type The base type to store in the linked list.

Each of the function’s template fields (C++).

attribute (term & definition)

in C++ class and method declarations only

@throws

@throws bananas

Include one @throws tag for each exception thrown by this function (in languages that support exceptions).

attribute

in function and method declarations only

@updated

@updated 2003-03-14

The date at which the header was last updated.

attribute

@version

@version 2.3.1

the version number to which this documentation applies.

attribute

in @header only

Overriding the Default Data Type: C Pseudoclass Tags

There are three tags provided for C pseudoclasses, such as COM interfaces. The @class tag is used for generic pseudoclasses. The @interface tag is used for COM interfaces. The @superclass tag can be added to an @class or @interface declaration to modify its behavior.

Table 2-10  

Tag

Identifies

Fields

@superclass

The name of the superclass.

1

You should mark up any C pseudoclasses in the same way you would mark up a C++ class. Apart from the unusual form of function declarations (in the form of function pointers), the resulting output should be similar to that of a C++ class.

The @superclass tag can be used when you have a superclass-like relationship between two C pseudoclasses or COM interfaces. Using this tag will cause the documentation for the specified pseudo-superclass to be injected into the documentation for the current pseudoclass.

The primary purpose for this feature is to reduce the amount of bloat in headers, allowing you to document function pointers in the top level pseudoclass and then only document the additional function pointers in pseudoclasses that expand upon them.

Note: In order for this feature to work, the super-pseudoclasses must be processed first. If it is in the same header, it must appear before the child pseudoclass. If it is in a separate header, it must appear in a header that the child’s header includes, and both headers must be processed at the same time.

Listing 2-24  Example of @class tag

/*!
 @class IOFireWireDeviceInterface_t
 @superclass IOFireWireDevice
*/
 typedef struct IOFireWireDeviceInterface_t
{
    IUNKNOWN_C_GUTS;
.
.
.
}
 

The @class tag causes the typedef structthat follows the HeaderDoc comment to be treated as a class. This is a frequently-used technique in kernel programming. A slight variation of this tag, @interface, is provided for COM interfaces so that they can be identified as such in the TOC. An example of this tag follows:

Listing 2-25  Example of @interface tag

/*!
 @interface IOFireWireDeviceInterface_t
 @superclass IOFireWireDevice
*/
 typedef struct IOFireWireDeviceInterface_t
{
    IUNKNOWN_C_GUTS;
.
.
.
}
 

Unknown Tag Handling

To avoid warnings and unexpected output, if you need to use an at sign (@) outside the scope of a HeaderDoc tag, you should quote it by preceding it with a backslash. For example:

/*! @header
        For more information, contact myemail\@myaddress.top.
 */

If you do not quote the at sign, it will be treated as the start of a tag name, and you may get unexpected behavior.

Beginning in HeaderDoc 8.6 and later, a warning is generated when an unknown tag is encountered, and the tag is converted into text.

Prior to version 8.6, unknown tags were partially removed. The initial at sign (@) was deleted, leaving only the content following it.



Last updated: 2009-11-17

Did this document help you? Yes It's good, but... Not helpful...