xqDoc
(1Q18)
xqDoc comments (see xqdoc.org) are used to document XQuery library and main modules in a manner similar to how Javadoc comments are used to document Java classes and packages. With the documentation close to the source, documentation maintenance is easier. From this, xqDoc can generate useful documentation quickly and easily.
An XQuery module does not need to contain xqDoc style comments in order for the xqDoc tools to produce useful output. Even without any xqDoc documentation style comments, a cross reference (for modules, functions, and variables) and XQuery code browser (for modules and functions) will be created by xqDoc.
xqDoc comments are extracted when eXist-db parses an XQuery. It keeps them with the function signature.
To speed up parsing, xqDoc uses "lazy evaluation". Comments are stored as plain strings first. This is parsed and merged into the function signature when needed. It allows tools like eXide to display up to date documentation while working on a module.
Comment Style
xqDoc style comments begin with (:~
and end with :)
.
An xqDoc style comment can be specified for each of the following:
Library Modules:
-
Module Declaration
-
Module Import
-
Variable Definition
-
Function Definition
Main Modules:
-
Main Module
-
Module Import
-
Variable Definition
-
Function Definition
An xqDoc comment contains specials strings, called tags Tags
start with an @
character. The text up to the first tag is assumed to be
the general description for the component being documented.
The following tags are recognized and handled:
-
@author
-
Author of this component. Occurrences: zero or more.
(:~ @author Darin McBeath :) -
@version
-
Version of the component. Occurrences: zero or more, but only a single
@version
makes sense.(:~ @version 1.0 :) -
@since
-
Identifies the version of the module since when this component is supported. Occurrences: zero or more, but only a single
@since
makes sense. -
@see
-
Adds a hypertext link to an external site, a library or main module, a specific function or variable, or arbitrary text. Occurrences: zero or more.
-
To link to an external site, use a complete URL such as
http://www.xquery.com
. -
To link to a library or main module (contained in xqDoc), provide the URI for this (see example below).
-
To link to a specific function or variable (contained in xqDoc), provide the URI for the library or main module, followed by a semicolon
;
and the function or variable name. -
To provide a name for a link, add a semicolon
;
, followed by the name -
Anything else will be interpreted as just text.
(:~ @see http://www.xquery.com @see xqdoc/xqdoc-display @see xqdoc/xqdoc-display;build-link @see xqdoc/xqdoc-display;$months @see xqdoc/xqdoc-display;$months;month variable @see http://www.xquery.com;;xquery @see some text :) -
-
@param
-
Describes the parameters associated with a function. Append the parameter name and its description.
(:~ @param $name The username :) -
@return
-
Describes the return value from a function. Occurrences: zero or more.
(:~ @return Sequence of names matching the search criteria :) -
@deprecated
-
Identifies the component as deprecated. Its text should indicate the reason and its optional replacement.
-
@error
-
Identifies an error raised by the function. Occurrences: zero or more.
(:~ @error The requested URI does not exist :)
Values provided for each of the tags can contain embedded XHTML markup to enhance or emphasize the xqDoc presentation. However, make sure the content is well formed and that entities are used (for instance & instead of &).