$Date$
$Revision$
elements
funcsynopsis
funcsynopsis
Element
funcsynopsis
&funcsynopsis.purpose;
&funcsynopsis.synopsis.gen;
Description
A FuncSynopsis contains the syntax summary of a function prototype
or a set of function prototypes. The content model of this element
was designed specifically to capture the semantics of most C-language
function prototypes (for use in &UNIX; reference pages).
This is one of the few places where DocBook attempts to model as well
as describe. Using FuncSynopsis for languages that are
unrelated to C may prove difficult.
Processing expectations
For the most part, the processing application is expected to
generate all of the parenthesis, semicolons, commas,
and so on. required in the rendered synopsis. The exception to this
rule is that the spacing and other punctuation inside a
parameter that is a pointer to a function must be provided in
the source markup.
With sufficient author cooperation, it should be possible to markup
a function synopsis with enough clarity so that a processing system can
generate either K&R-style or ANSI-style renderings.
A Note on the Use of VarArgs
The content model of FuncPrototype is such that you
cannot use VarArgs in a function prototype in which the
first few parameters to the function are given explicitly before
the variable arguments (generally rendered as an ellipsis).
In other words, the following synopsis cannot be rendered with
VarArgs:
int printf(char *format, ...)
Instead, you can enclose the ellipsis in a final Parameter,
like this:
int printf
char *format
...
]]>
&FutureChanges;
DocBook DTDChanges for V4.0
In DocBook V4.0, the content model fragment beginning with
FuncDef will be removed from the content
model of FuncSynopsis. Instead
FuncSynopsis will become a mixture of
FuncSynopsisInfos and FuncPrototypes.
&FutureChanges;
Future versions of DocBook may provide additional environments for
describing the syntax summaries of functions in other programming
languages.
&funcsynopsis.parents.gen;
&funcsynopsis.children.gen;
Attributes
label
Label specifies an identifying number or string
that may be used in presentation.
See Also
&funcsynopsis.seealso.gen;
Examples
The function max returns the larger of two integers:
&funcsynopsis.example.1.txt;
&funcsynopsis.example.1.gen;
One can imagine a more flexible max function that takes
any number of integer arguments and returns the largest integer in
the list:
&funcsynopsis.example.2.txt;
&funcsynopsis.example.2.gen;
The rand function takes no arguments and returns a
pseudorandom integer between 0 and 231-1:
&funcsynopsis.example.3.txt;
&funcsynopsis.example.3.gen;
The qsort function takes several arguments, including
a pointer to a function (the function that should perform the
comparison between two elements in order to sort them).
&funcsynopsis.example.4.txt;
&funcsynopsis.example.4.gen;
&funcsynopsis.example.seealso.gen;