Debian Codegraph @

ru/refpages/elements/funcsynopsis/refentry.xml

raw symbols SCIP
1 <refentry id="funcsynopsis.element">
2 <?dbhtml filename="funcsynopsis.html"?>
3 <refentryinfo>
4 <pubdate>$Date$</pubdate>
5 <releaseinfo>$Revision$</releaseinfo>
6 </refentryinfo>
7
8 <refmeta>
9 <indexterm><primary>elements</primary>
10 <secondary>funcsynopsis</secondary></indexterm>
11 <refentrytitle>funcsynopsis</refentrytitle>
12 <refmiscinfo>Element</refmiscinfo>
13 </refmeta>
14 <refnamediv>
15 <refname>funcsynopsis</refname>
16 <refpurpose>&funcsynopsis.purpose;</refpurpose>
17 </refnamediv>
18
19 &funcsynopsis.synopsis.gen;
20 <refsect1 condition='ref.description'><title>Description</title>
21
22 <para>
23 A <sgmltag>FuncSynopsis</sgmltag> contains the syntax summary of a function prototype
24 or a set of function prototypes. The content model of this element
25 was designed specifically to capture the semantics of most C-language
26 function prototypes (for use in &UNIX; reference pages).
27 </para>
28
29 <para>
30 This is one of the few places where DocBook attempts to model as well
31 as describe. Using <sgmltag>FuncSynopsis</sgmltag> for languages that are
32 unrelated to C may prove difficult.
33 </para>
34
35 <refsect2><title>Processing expectations</title>
36 <para>
37 For the most part, the processing application is expected to
38 generate all of the parenthesis, semicolons, commas,
39 and so on. required in the rendered synopsis. The exception to this
40 rule is that the spacing and other punctuation inside a
41 parameter that is a pointer to a function must be provided in
42 the source markup.
43 </para>
44
45 <para>
46 With sufficient author cooperation, it should be possible to markup
47 a function synopsis with enough clarity so that a processing system can
48 generate either <acronym>K&amp;R</acronym>-style or <acronym>ANSI</acronym>-style renderings.
49 </para>
50
51 <refsect3><title>A Note on the Use of <sgmltag>VarArgs</sgmltag></title>
52 <para>
53 The content model of <sgmltag>FuncPrototype</sgmltag> is such that you
54 cannot use <sgmltag>VarArgs</sgmltag> in a function prototype in which the
55 first few parameters to the function are given explicitly before
56 the variable arguments (generally rendered as an ellipsis).
57 </para>
58
59 <para>
60 In other words, the following synopsis cannot be rendered with
61 <sgmltag>VarArgs</sgmltag>:
62
63 <synopsis>
64 int printf(char *format, ...)
65 </synopsis>
66 </para>
67
68 <para>
69 Instead, you can enclose the ellipsis in a final <sgmltag>Parameter</sgmltag>,
70 like this:
71
72 <screen>
73 <![CDATA[
74 <funcsynopsis>
75 <funcprototype><funcdef>int <function>printf</function></funcdef>
76 <paramdef>
77 <parameter>char *format</parameter>
78 <parameter>...</parameter>
79 </paramdef>
80 </funcprototype>
81 </funcsynopsis>
82 ]]>
83 </screen>
84 </para>
85 </refsect3>
86
87 </refsect2>
88
89 <refsect2 role='fu' revision="4.0"><title>&FutureChanges;</title>
90 <para>
91 <indexterm><primary>DocBook DTD</primary><secondary>Changes for <acronym>V4.0</acronym></secondary>
92 </indexterm>
93 In DocBook <acronym>V4.0</acronym>, the content model fragment beginning with
94 <sgmltag>FuncDef</sgmltag> will be removed from the content
95 model of <sgmltag>FuncSynopsis</sgmltag>. Instead
96 <sgmltag>FuncSynopsis</sgmltag> will become a mixture of
97 <sgmltag>FuncSynopsisInfo</sgmltag>s and <sgmltag>FuncPrototype</sgmltag>s.
98 </para>
99 </refsect2>
100
101 <refsect2><title>&FutureChanges;</title>
102 <para>
103 Future versions of DocBook may provide additional environments for
104 describing the syntax summaries of functions in other programming
105 languages.
106 </para>
107 </refsect2>
108
109
110 &funcsynopsis.parents.gen;
111 &funcsynopsis.children.gen;
112 </refsect1>
113 <refsect1 condition='ref.elem.attrdesc'><title>Attributes</title>
114 <variablelist>
115 <varlistentry><term>label</term>
116 <listitem>
117 <para>
118 <sgmltag class='attribute'>Label</sgmltag> specifies an identifying number or string
119 that may be used in presentation.
120 </para>
121 </listitem>
122 </varlistentry>
123 </variablelist>
124 </refsect1>
125 <refsect1 condition='ref.elem.seealso'><title>See Also</title>
126 &funcsynopsis.seealso.gen;
127 </refsect1>
128 <refsect1><title>Examples</title>
129
130 <para>
131 The function <function>max</function> returns the larger of two integers:
132 </para>
133
134 <informalexample role="example-source">
135 <programlisting>&funcsynopsis.example.1.txt;</programlisting>
136 </informalexample>
137
138 <anchor id="ex.os.funcsynopsis.1" role="HACK-ex.out.start"/>
139 &funcsynopsis.example.1.gen;
140 <anchor id="ex.oe.funcsynopsis.1" role="HACK-ex.out.end"/>
141
142 <para>
143 One can imagine a more flexible <function>max</function> function that takes
144 any number of integer arguments and returns the largest integer in
145 the list:
146 </para>
147
148 <informalexample role="example-source">
149 <programlisting>&funcsynopsis.example.2.txt;</programlisting>
150 </informalexample>
151
152 <anchor id="ex.os.funcsynopsis.2" role="HACK-ex.out.start"/>
153 &funcsynopsis.example.2.gen;
154 <anchor id="ex.oe.funcsynopsis.2" role="HACK-ex.out.end"/>
155
156 <para>
157 The <function>rand</function> function takes no arguments and returns a
158 pseudorandom integer between 0 and 2<superscript>31</superscript>-1:
159 </para>
160
161 <informalexample role="example-source">
162 <programlisting>&funcsynopsis.example.3.txt;</programlisting>
163 </informalexample>
164
165 <anchor id="ex.os.funcsynopsis.3" role="HACK-ex.out.start"/>
166 &funcsynopsis.example.3.gen;
167 <anchor id="ex.oe.funcsynopsis.3" role="HACK-ex.out.end"/>
168
169 <para>
170 The <function>qsort</function> function takes several arguments, including
171 a pointer to a function (the function that should perform the
172 comparison between two elements in order to sort them).
173 </para>
174
175 <informalexample role="example-source">
176 <programlisting>&funcsynopsis.example.4.txt;</programlisting>
177 </informalexample>
178
179 <anchor id="ex.os.funcsynopsis.4" role="HACK-ex.out.start"/>
180 &funcsynopsis.example.4.gen;
181 <anchor id="ex.oe.funcsynopsis.4" role="HACK-ex.out.end"/>
182
183 &funcsynopsis.example.seealso.gen;
184 </refsect1>
185 </refentry>
186