1 | |
---|
2 | NOTE: This is only a draft version. Don't make major changes to your |
---|
3 | documentation until we've agreed on all this. |
---|
4 | |
---|
5 | |
---|
6 | GTK+ Reference Documentation Style Guide |
---|
7 | ======================================== |
---|
8 | |
---|
9 | This file describes the way the GTK+ reference documentation should be written, |
---|
10 | so that we produce consistent documentation. |
---|
11 | |
---|
12 | We will also designate one or two of the template files as 'model' templates, |
---|
13 | i.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 | |
---|
19 | Language |
---|
20 | ======== |
---|
21 | |
---|
22 | Use American spelling rather than British, i.e. color rather than colour, |
---|
23 | organize rather than organise etc. |
---|
24 | |
---|
25 | End all descriptions of functions & parameters with a period '.'. |
---|
26 | |
---|
27 | |
---|
28 | Organizing Sections |
---|
29 | =================== |
---|
30 | |
---|
31 | The organization of the sections is determined by the glib-sections.txt, |
---|
32 | gdk-sections.txt and gtk-sections.txt files. |
---|
33 | |
---|
34 | Group 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 |
---|
36 | between the groups, which makes it a bit easier to read. |
---|
37 | |
---|
38 | Order the groups sections by placing the most important/commonly-used |
---|
39 | functions/macros etc. first. For pairs of accessor functions place them |
---|
40 | together with the 'get' function first and then the 'set' function. |
---|
41 | |
---|
42 | Private functions etc. should be placed at the end of the "<SECTION>", |
---|
43 | after a "<SUBSECTION Private>" line. They will not appear in the HTML output |
---|
44 | and they do not have to be documented (they will disappear form the template |
---|
45 | files the next time 'make templates' is run). |
---|
46 | |
---|
47 | Enumerations should appear after the first function which uses them. |
---|
48 | |
---|
49 | |
---|
50 | Section Descriptions |
---|
51 | =================== |
---|
52 | |
---|
53 | For widgets, start the main description with - |
---|
54 | |
---|
55 | <!-- ##### SECTION Long_Description ##### --> |
---|
56 | <para> |
---|
57 | The #GtkFontSelectionDialog widget ... |
---|
58 | |
---|
59 | |
---|
60 | If you want to include subsections in the main description, to conform to |
---|
61 | DocBook SGML you must have 0 or more leading paragraphs (or possibly other |
---|
62 | DocBook tags - see the DTD), then 1 or more <refsect2> subsections, with |
---|
63 | nothing after. e.g. |
---|
64 | |
---|
65 | <!-- ##### SECTION Long_Description ##### --> |
---|
66 | <para> |
---|
67 | Introduction 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 | |
---|
83 | Functions & Macro Descriptions |
---|
84 | ============================== |
---|
85 | |
---|
86 | Start the description with a phrase like this: |
---|
87 | 'Looks up a key in a GHashTable'. |
---|
88 | i.e. assume that 'This function' (or 'This macro') precedes it. |
---|
89 | |
---|
90 | |
---|
91 | Function Parameters |
---|
92 | =================== |
---|
93 | |
---|
94 | For object-oriented code, denote the object parameter with 'a', |
---|
95 | e.g. 'a #GHashTable'. |
---|
96 | |
---|
97 | Use 'the' for the rest of the parameters. |
---|
98 | |
---|
99 | |
---|
100 | Widget Structs |
---|
101 | ============== |
---|
102 | |
---|
103 | Some widget structs have fields which are useful to the developer, since |
---|
104 | there are currently no accessor functions to retrieve the particular field. |
---|
105 | |
---|
106 | These fields should be documented as follows: |
---|
107 | |
---|
108 | ----------------------------------------------------------------------- |
---|
109 | <!-- ##### STRUCT GtkFixedChild ##### --> |
---|
110 | <para> |
---|
111 | The #GtkFixedChild-struct struct contains the following fields. |
---|
112 | (These fields should be considered read-only. They should never be set by |
---|
113 | an 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 | |
---|
124 | If a widget struct is completely private, use this: |
---|
125 | |
---|
126 | ----------------------------------------------------------------------- |
---|
127 | <!-- ##### STRUCT GtkFontSelectionDialog ##### --> |
---|
128 | <para> |
---|
129 | The #GtkFontSelectionDialog-struct struct contains private data only, and |
---|
130 | should be accessed using the functions below. |
---|
131 | </para> |
---|
132 | ----------------------------------------------------------------------- |
---|
133 | |
---|
134 | Note that the links to the widget names go to the top of the page, |
---|
135 | e.g. links to #GtkAccelLabel result in a link to the GtkAccelLabel page. |
---|
136 | If you want to link to the widget struct, you must append '-struct', |
---|
137 | e.g. #GtkAccelLabel-struct |
---|
138 | |
---|
139 | Whether a particular field in a structure is output in the |
---|
140 | documentation is determined by adding /*< public >*/ and |
---|
141 | /*< private >*/ comments into the header files. For instance, |
---|
142 | GtkEditable looks like: |
---|
143 | |
---|
144 | ----------------------------------------------------------------------- |
---|
145 | struct _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 | |
---|
166 | You should add these as you go along. Please send these changes |
---|
167 | in along with your patches for the reference docs. Widget structures |
---|
168 | are by default all private, other structures are by default all public. |
---|
169 | |
---|
170 | |
---|
171 | Enumerations |
---|
172 | ============ |
---|
173 | |
---|
174 | A lot of the enumerations in GTK+ are currently placed in the "Standard |
---|
175 | Enumerations" section. However, some of these are specific to a particular |
---|
176 | widget and so should be moved to the widget's section and documented there. |
---|
177 | |
---|
178 | The enumeration values should be documented as follows: |
---|
179 | |
---|
180 | ----------------------------------------------------------------------- |
---|
181 | <!-- ##### ENUM GtkFontFilterType ##### --> |
---|
182 | <para> |
---|
183 | A set of bit flags used to specify the filter being set |
---|
184 | when calling gtk_font_selection_dialog_set_filter() or |
---|
185 | gtk_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 | |
---|
194 | See Also |
---|
195 | ======== |
---|
196 | |
---|
197 | To link to related widgets/pages, use a <variablelist> like below. |
---|
198 | If there aren't any related pages, simply leave the See_Also section as it is, |
---|
199 | and it will not be output. |
---|
200 | Note that ancestors of widgets may automatically be added here, so |
---|
201 | don'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 | |
---|
218 | Including Hypertext Links |
---|
219 | ========================= |
---|
220 | |
---|
221 | Use the <ulink> tag to include hypertext links, e.g. |
---|
222 | |
---|
223 | Gnome's home page is at <ulink url="www.gnome.org">www.gnome.org</ulink>. |
---|
224 | |
---|
225 | Remember that the documentation may be printed, so it is probably best |
---|
226 | to repeat the URL within the link. |
---|
227 | |
---|
228 | Damon, 1 June 1999 |
---|