funcsynopsis

funcsynopsis — The syntax summary for a function definition

Synopsis

Content Model

funcsynopsis ::=

Attributes

Common attributes and common linking attributes.

Additional attributes:

  • language

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:


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

Attributes

Common attributes and common linking attributes.

language

Identifies the language (i.e. programming language) of the content.

Children

The following elements occur in funcsynopsis: funcprototype, funcsynopsisinfo, info (db.titleforbidden.info).

See Also

cmdsynopsis, synopsis

Examples

<article xmlns='http://docbook.org/ns/docbook'>
<title>Example funcsynopsis</title>

<funcsynopsis>
<funcprototype>
  <funcdef>int <function>max</function></funcdef>
  <paramdef>int <parameter>int1</parameter></paramdef>
  <paramdef>int <parameter>int2</parameter></paramdef>
</funcprototype>
</funcsynopsis>

</article>

int max(int1, int2);
int int1;
int int2;

<article xmlns='http://docbook.org/ns/docbook'>
<title>Example funcsynopsis</title>

<funcsynopsis>
<funcsynopsisinfo>
#include &lt;varargs.h&gt;
</funcsynopsisinfo>
<funcprototype>
  <funcdef>int <function>max</function></funcdef>
  <varargs/>
</funcprototype>
</funcsynopsis>

</article>
#include <varargs.h>

int max(...);

<article xmlns='http://docbook.org/ns/docbook'>
<title>Example funcsynopsis</title>

<funcsynopsis>
<funcprototype>
<funcdef>int <function>rand</function></funcdef>
  <void/>
</funcprototype>
</funcsynopsis>

</article>

int rand();

<article xmlns='http://docbook.org/ns/docbook'>
<title>Example funcsynopsis</title>

<funcsynopsis>
<funcprototype>
  <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>
</funcprototype>
</funcsynopsis>

</article>
void qsort(dataptr,  
 left,  
 right,  
 (* comp)); 
void * dataptr[];
int  left;
int  right;
int (* comp) (void *, void *);

ChangeLog

This alpha reference page is $Revision: 1.4 $ published $Date: 2005/10/30 21:59:13 $.