source: trunk/third/gtk-doc/doc/style-guide.txt @ 20745

Revision 20745, 6.8 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20744, which included commits to RCS files with non-trunk default branches.
Line 
1
2NOTE: This is only a draft version. Don't make major changes to your
3      documentation until we've agreed on all this.
4
5
6GTK+ Reference Documentation Style Guide
7========================================
8
9This file describes the way the GTK+ reference documentation should be written,
10so that we produce consistent documentation.
11
12We will also designate one or two of the template files as 'model' templates,
13i.e. they are to be taken as the 'correct' way to write the documentation:
14
15  GtkFontSelectionDialog - contains example code and descriptions of enums.
16  GtkMisc - contains description of fields in a widget struct.
17
18
19Language
20========
21
22Use American spelling rather than British, i.e. color rather than colour,
23organize rather than organise etc.
24
25End all descriptions of functions & parameters with a period '.'.
26
27
28Organizing Sections
29===================
30
31The organization of the sections is determined by the glib-sections.txt,
32gdk-sections.txt and gtk-sections.txt files.
33
34Group related functions/macros/enums etc. and place a "<SUBSECTION>" tag
35(on its own line) between groups. This results in a blank line in the synopsis
36between the groups, which makes it a bit easier to read.
37
38Order the groups sections by placing the most important/commonly-used
39functions/macros etc. first. For pairs of accessor functions place them
40together with the 'get' function first and then the 'set' function.
41
42Private functions etc. should be placed at the end of the "<SECTION>",
43after a "<SUBSECTION Private>" line. They will not appear in the HTML output
44and they do not have to be documented (they will disappear form the template
45files the next time 'make templates' is run).
46
47Enumerations should appear after the first function which uses them.
48
49
50Section Descriptions
51===================
52
53For widgets, start the main description with -
54
55<!-- ##### SECTION Long_Description ##### -->
56<para>
57The #GtkFontSelectionDialog widget ...
58
59
60If you want to include subsections in the main description, to conform to
61DocBook SGML you must have 0 or more leading paragraphs (or possibly other
62DocBook tags - see the DTD), then 1 or more <refsect2> subsections, with
63nothing after. e.g.
64
65<!-- ##### SECTION Long_Description ##### -->
66<para>
67Introduction to the section....
68</para>
69<refsect2>
70  <title>First Subsection</title>
71  <para>
72    This is the first subsection.
73  </para>
74</refsect2>
75<refsect2>
76  <title>Second Subsection</title>
77  <para>
78    This is the second subsection.
79  </para>
80</refsect2>
81
82
83Functions & Macro Descriptions
84==============================
85
86Start the description with a phrase like this:
87  'Looks up a key in a GHashTable'.
88i.e. assume that 'This function' (or 'This macro') precedes it.
89
90
91Function Parameters
92===================
93
94For object-oriented code, denote the object parameter with 'a',
95e.g. 'a #GHashTable'.
96
97Use 'the' for the rest of the parameters.
98
99
100Widget Structs
101==============
102
103Some widget structs have fields which are useful to the developer, since
104there are currently no accessor functions to retrieve the particular field.
105
106These fields should be documented as follows:
107
108-----------------------------------------------------------------------
109<!-- ##### STRUCT GtkFixedChild ##### -->
110<para>
111The #GtkFixedChild-struct struct contains the following fields.
112(These fields should be considered read-only. They should never be set by
113an application.)
114</para>
115
116@widget: the child #GtkWidget.
117@x: the horizontal position of the widget within the #GtkFixed
118    container.
119@y: the vertical position of the widget within the #GtkFixed
120    container.
121-----------------------------------------------------------------------
122
123
124If a widget struct is completely private, use this:
125
126-----------------------------------------------------------------------
127<!-- ##### STRUCT GtkFontSelectionDialog ##### -->
128<para>
129The #GtkFontSelectionDialog-struct struct contains private data only, and
130should be accessed using the functions below.
131</para>
132-----------------------------------------------------------------------
133
134Note that the links to the widget names go to the top of the page,
135e.g. links to #GtkAccelLabel result in a link to the GtkAccelLabel page.
136If you want to link to the widget struct, you must append '-struct',
137e.g. #GtkAccelLabel-struct
138
139Whether a particular field in a structure is output in the
140documentation is determined by adding /*< public >*/ and
141/*< private >*/ comments into the header files. For instance,
142GtkEditable looks like:
143
144-----------------------------------------------------------------------
145struct _GtkEditable
146{
147  GtkWidget widget;
148
149  /*< public >*/
150  guint      current_pos;
151
152  guint      selection_start_pos;
153  guint      selection_end_pos;
154  guint      has_selection : 1;
155
156  /*< private >*/
157  guint      editable : 1;
158  guint      visible : 1;
159  GdkIC     *ic;
160  GdkICAttr *ic_attr;
161 
162  gchar *clipboard_text;
163};
164-----------------------------------------------------------------------
165
166You should add these as you go along. Please send these changes
167in along with your patches for the reference docs. Widget structures
168are by default all private, other structures are by default all public.
169
170
171Enumerations
172============
173
174A lot of the enumerations in GTK+ are currently placed in the "Standard
175Enumerations" section. However, some of these are specific to a particular
176widget and so should be moved to the widget's section and documented there.
177
178The enumeration values should be documented as follows:
179
180-----------------------------------------------------------------------
181<!-- ##### ENUM GtkFontFilterType ##### -->
182<para>
183A set of bit flags used to specify the filter being set
184when calling gtk_font_selection_dialog_set_filter() or
185gtk_font_selection_set_filter().
186</para>
187
188@GTK_FONT_FILTER_BASE: the base filter, which can't be changed by the user.
189@GTK_FONT_FILTER_USER: the user filter, which can be changed from within the 'Filter' page
190                       of the #GtkFontSelection widget.
191-----------------------------------------------------------------------
192
193
194See Also
195========
196
197To link to related widgets/pages, use a <variablelist> like below.
198If there aren't any related pages, simply leave the See_Also section as it is,
199and it will not be output.
200Note that ancestors of widgets may automatically be added here, so
201don't add them yourself.
202
203-----------------------------------------------------------------------
204<!-- ##### SECTION See_Also ##### -->
205<para>
206<variablelist>
207
208<varlistentry>
209<term>#GtkFontSelection</term>
210<listitem><para>the underlying widget for selecting fonts.</para></listitem>
211</varlistentry>
212
213</variablelist>
214</para>
215-----------------------------------------------------------------------
216
217
218Including Hypertext Links
219=========================
220
221Use the <ulink> tag to include hypertext links, e.g.
222
223Gnome's home page is at <ulink url="www.gnome.org">www.gnome.org</ulink>.
224
225Remember that the documentation may be printed, so it is probably best
226to repeat the URL within the link.
227
228Damon, 1 June 1999
Note: See TracBrowser for help on using the repository browser.