Search the Catalog
DocBook: The Definitive Guide

DocBook: The Definitive Guide

By Norman Walsh & Leonard Muellner
1st Edition October 1999
1-56592-580-7, Order Number: 5807
652 pages, $36.95 , Includes CD-ROM



FuncSynopsis -- The syntax summary for a function definition


Content Model

FuncSynopsis ::=


Common attributes





Tag Minimization

Both the start- and end-tags are required for this element.

Parameter Entities



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:

<funcprototype><funcdef>int <function>printf</function></funcdef>
  <parameter>char *format</parameter>

(4.0) Future Changes

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.

Future Changes

Future versions of DocBook may provide additional environments for describing the syntax summaries of functions in other programming languages.


The following elements occur in FuncSynopsis: FuncDef, FuncPrototype, FuncSynopsisInfo, ParamDef, VarArgs, Void.

In some contexts, the following elements are allowed anywhere: BeginPage, IndexTerm.



Label specifies an identifying number or string that may be used in presentation.

See Also

CmdSynopsis, Synopsis


The function max returns the larger of two integers:

<!DOCTYPE funcsynopsis PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
  <funcdef>int <function>max</function></funcdef>
  <paramdef>int <parameter>int1</parameter></paramdef>
  <paramdef>int <parameter>int2</parameter></paramdef>

int max(int int1, int int2);

One can imagine a more flexible max function that takes any number of integer arguments and returns the largest integer in the list:

<!DOCTYPE funcsynopsis PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
#include &lt;varargs.h&gt;
  <funcdef>int <function>max</function></funcdef>

#include <varargs.h>

int max(...);

The rand function takes no arguments and returns a psuedorandom integer between 0 and 231-1:

<!DOCTYPE funcsynopsis PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<funcdef>int <function>rand</function></funcdef>

int rand(void);

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).

<!DOCTYPE funcsynopsis PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
  <funcdef>void <function>qsort</function></funcdef>
    <paramdef>void *<parameter>dataptr</parameter>[]</paramdef>
    <paramdef>int <parameter>left</parameter></paramdef>
    <paramdef>int <parameter>right</parameter></paramdef>
    <paramdef>int <parameter>(* comp)</parameter>
      <funcparams>void *, void *</funcparams></paramdef>

void qsort(void *dataptr[], int left, int right, int (* comp) (void *, void *));

For additional examples, see also FuncDef, ParamDef, VarArgs.

Back to: DocBook: The Definitive Guide Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy

© 2001, O'Reilly & Associates, Inc.