1GStreamer documentation notes
2
3IMPORTANT
4=========
5
6Please make sure you've read and understood everything in this file
7before you try changing documentation.
8
9Some of the docbook-related bits in this README might be out of date now that
10quite a bit of the documentation has moved into the gst-docs repository.
11
12OVERVIEW
13========
14
15GStreamer has two sets of documentation that we maintain:
16* API references, using gtk-doc (gstreamer, gstreamer-libs)
17* FAQ / Application Development Manual / Plugin Writer's Guide / Tutorials -
18 these are maintained in markdown format and live in the gst-docs repository.
19
20DOCBOOK NOTES
21=============
22
23OK, I've grown so tired of having to coax the docs to build every time I
24get round to it that I've decided to note down some of the things that
25are important to know.
26
27OVERVIEW
28--------
29* Our documentation should all be Docbook/XML. No SGML.
30* The source for the documentation is:
31 - one or more .xml files, with the main one being gstreamer-(whatever).xml
32 - image files
33 - in .svg
34 - in .png (and maybe others)
35* We want to generate docs in HTML, PS and PDF
36* We want to use xml to to generate these
37
38CONVENTIONS
39-----------
40We stick to some simple conventions for writing docbook documentation.
41* id names:
42 - all id's start with chapter-, part-, section-, or misc-
43 - verify this is the case by looking at the generated file names in html/
44 - sections should also include the chapter name;
45 for example in a chapter called chapter-example, a section would be
46 called section-example-hello-world
47
48HOW IMAGES ARE HANDLED
49----------------------
50* the format of images used is:
51 - PNG for html
52 - EPS for ps
53 - PDF for pdf
54
55* images may need to be converted from their source format to the end format
56
57* a file called image.entities is generated that provides two entities:
58 ℑ and ℑ
59 ℑ is the file extension (png, ps, pdf)
60* all generated images will be put in images/
61
62HOW THE BUILD WORKS FOR EACH FORMAT
63-----------------------------------
64* HTML:
65 - xmlto html gstreamer-whatever.xml should produce the html docs.
66 - We do this in the html subdir of the doc builddir.
67 - images are copied to (builddir)/html/images
68 - PNGS should be set to all of the png's referenced for html, both
69 already there and auto-generated
70
71* PS :
72 - images are converted to .ps files in EPS format. Generated images are
73 put in images/
74 - xmlto ps gstreamer-whatever.xml generates the ps file
75
76* PDF :
77 There are two ways:
78 - ps2pdf is the easiest
79 - we specify ps, PS as the image type, but using xmlto the build will fail
80 because it uses ps2pdf internally and it fails to generate the images
81 By hand-generating .pdf images before xmlto we can make the build succeed.
82 (This is why image-pdf has file ext pdf but type EPS; this tricks xmlto in
83 doing the right thing)
84 xmlto pdf gstreamer-whatever.xml generates pdf (but seems to fail on the
85 FAQ, so for now we use ps2pdf)
86
87HOW THE BUILD SYSTEM IS SET UP
88------------------------------
89* make all should build html, ps, and pdf
90* html is built in a subdir, with the png/ps images copied there
91* ps and pdf are built in the current dir, in one file
92
93SPELL CHECKING
94--------------
95* with aspell
96 * aspell -b -c --mode=sgml --lang=en <file>.xml
97 unfortunately the curses-ui of aspell (0.50.5) has problems with the xml tags
98
99
100GTK-DOC NOTES
101=============
102
103* files under revision control:
104 - Makefile.am
105 - gstreamer-sections.txt
106 describes which symbols later appear on one api-doc page
107 configure which symbols are shown/invisible/private
108 - gstreamer.types
109 the types file lists all get_type() functions that register the GObject types
110 - gstreamer-docs.sgml
111 defines the overall structure of the api documentation
112 - tmpl/
113 - only add the file to CVS if you have at least filled the short description
114 (filename corresponds to the <FILE> tag in the sections file)
115 - document as much as possible in the source (*.c files)
116
117* what to do when adding a new piece of API:
118 - add both an entity and use the entity in gstreamer-docs.sgml
119 - add a new <SECTION> to gstreamer-sections.txt in the correct alphabetical
120 position related to the other sections (so that it is easier to locate)
121 - add all documented symbols to gstreamer-sections.txt in the proper section
122 (default),<SUBSECTION Standard>,<SUBSECTION Private>
123 - document at least the Short_Description in tmpl/.sgml
124 - document symbols where they are defined, so that when one changes the
125 definition, the chaces are good that docs are updated.
126 - document functions, signals in the .c files
127 - document structs, typedefs, enums in the .h files
128
129* checklist:
130 - make sure *-sections.txt has a <TITLE> set for each <FILE>
131 - add only *one* <TITLE> to each file, when you have multiple classes in one
132 source-file, create one <FILE> section for each class
133 - the <TITLE> *must* be named like the type of the GType, when it gets
134 registered (otherwise gtkdoc introspection fails)
135 - for clarity name the <FILE> like the <TITLE>, but all lowercase
136
137* what to do when trying to improve the docs
138 - compare the output of
139 grep "_get_type" gstreamer-sections.txt | sort
140 with the types in XXX.types to detect entries that
141 are maybe missing
142 - gtk docs does not warns about empty member docs!, run
143 find . -name "*.[c,h]" -exec egrep -Hn "^ +\* +@.*: *$" {} \;
144 in the project root to find them
145 - gtk docs does not warns about empty Returns: docs!, run
146 find . -name "*.[c,h]" -exec egrep -Hn "^ +\* +@Returns: *$" {} \;
147 in the project root to find them
148
149* what happens during a gtk-doc build ?
150 - Scan step:
151 - based on a $(MODULE).types file:
152 - gtkdoc-scangobj creates a gtkdoc-scan binary
153 - using CC, LD, CFLAGS, LDFLAGS env var
154 - using --type-init-func and --module parameters
155 - gtkdoc-scan creates
156 - $MODULE.signals.new
157 - $MODULE.hierarchy.new
158 - $MODULE.interfaces.new
159 - $MODULE.prerequisites.new
160 - $MODULE.args.new
161 - generated source and objects get deleted
162 - gtkdoc-scangobj merges changes into the original files
163 - gtkdoc-scan
164 - extracts decls of functions, macros, enums, structs, unions from headers
165 - generates
166 - $MODULE-decl.txt
167 - $MODULE-decl-list.txt
168 - $MODULE-decl-list.txt then should get copied to $MODULE-sections.txt
169 - scan-build.stamp gets created
170
171 - Template generation step:
172 - gtkdoc-mktmpl --module=$MODULE
173 - reads in tmpl/*.sgml
174 - moves them to tmpl/*.sgml.bak
175 - recreates tmpl/*.sgml according to $MODULE-sections.txt
176 - moves unused stuff to $MODULE-unused.txt
177 - tmpl-build.stamp gets generated
178
179* Possible errors and how to fix them
180 - Warning: multiple "IDs" for constraint linkend: gst-tag-register.
181 - check if gst_tag_register is listed more than once in -sections.txt
182
183STYLE GUIDE FOR GTK-DOC
184=======================
185- this is in addition to gtk-doc's style-guide.txt
186
187- when documenting signals, use "the #Gst..." for the object receiving the
188 signal; no trailing dot, and no "that received the signal"
189- function/macro descriptions are descriptive, not imperative
190 ie, it uses the third person verb
191- synopsis and description should have most-used/application functions at the
192 top
193- functions that can return FALSE/NULL or fail should describe their failure
194 conditions like this:
195 * Returns NULL if no element with the given name is found in the bin, if
196 * the frobble was stuck in the froob, or the frizzle was frazzed.
197- a line with function attributes should be added before Returns:
198 - can contain:
199 "MT safe." - the function is verified to be multithreadingsafe
200 "Caller owns returned reference" for refcounted classes
201 "Caller owns returned value" for other types (iterators, ..)
202 - we do this because, in contrast with GLib/GTK, we are more explicit
203 about threadsafety and related issues
204- link to signals from the description like this:
205 * The <link linkend="GstBin-element-added">element-added</link> signal
206
207WEBSITE DOCUMENTATION
208=====================
209
210Updating the online documentation is pretty simple.
211Make sure that you
212a) have a working freedesktop.org account
213b) $HOME/.ssh/config set up so that it has the right User for the Host
214 (for example, I have:
215Host freedesktop.org
216 User thomasvs
217c) verify this works by doing ssh freedesktop.org and being logged in without
218 a password prompt
219d) have verified your changes build documentation locally.
220
221Then, after updating any of the docs, run "make upload" from that directory.
222Or, run "make upload" from this (docs) directory.
223
224DOCUMENTING ELEMENTS
225====================
226As of september 2005 we have some system to document plugins and elements
227in the various plugin packages.
228
229- in a submodule, docs go in docs/plugins
230- template can be copied from gst-plugins-base
231- to add plugins documentation:
232 - create docs/plugins
233 - create Makefile.am and friends, add to configure.ac
234 - create docs/version.entities.in, add to configure.ac
235 - in docs/plugins:
236 - create $(module)-plugins.types with #include <gst/gst.h>
237 - run make
238 - edit the -docs.sgml
239 - add to cvs:
240 cvs add *-plugins-docs.sgml *-plugins.args *-plugins.hierarchy *-plugins.interfaces *-plugins.prerequisites *-plugins.signals *-plugins.types inspect-build.stamp inspect.stamp scanobj-build.stamp
241 cvs add inspect
242 cvs add inspect/*.xml
243 - Additional types can be added to the documentation by placing them in
244 the .types file like this:
245 type:GstPlayBaseBin
246 This is useful for documenting plugin-private types that implement
247 signals or properties. The GType is looked up by name after all the
248 element classes have been printed - so this is only useful for types
249 that are created as a consequence of loading plugins and registering
250 the element(s).
251
252- to add a plugin to be documented:
253 - make sure inspect/ has generated a inspect/plugin-xxx.xml file for it.
254 - if it has not, make sure you have pygst installed and run 'make update'.
255 and add it to CVS.
256 - add an xi:include in -docs.sgml in the Plugins chapter for that plugin
257
258- to add an element to be documented:
259 - add an xi:include in the Elements chapter for the element
260 in the main -docs.sgml
261 - add a section for it in -sections.txt with
262 <SECTION>
263 <FILE>element-(element)</FILE>
264 <TITLE>(element)</TITLE>
265 GstXxx
266 <SUBSECTION Standard>
267 GstXxxClass
268 GST_XXX
269 GST_XXX_CLASS
270 GST_IS_XXX
271 GST_IS_XXX_CLASS
272 GST_TYPE_XXX
273 gst_xxx_get_type
274 </SECTION>
275 - add a gtk-doc section to the source code like:
276/**
277 * SECTION:element-multifdsink
278
279 and fill it with documentation about the element, preferably inside
280 a <refsect2> docbook container.
281 - add an example:
282 - either a few pipelines, inside <programlisting>
283 - or a piece of code:
284 - create an example program (element)-example.c in the plugin dir
285 - add the full path (starting with $(top_srcdir)) for this example
286 to the EXAMPLE_CFILES variable in Makefile.am
287 - add an xinclude of a file named "element-(element)-example.xml"
288 to the docbook documentation piece in the element source code
289 - add the header to EXTRA_HFILES in Makefile.am to be able to document
290 signals and args; in that case, the object struct needs to be in
291 -sections.txt outside of the Standard Subsection (which is annoying,
292 but ...)
293 (FIXME: are we sure we can both do the xinclude from the tmpl/ sgml,
294 as well as an override from the source itself ? maybe we should just
295 make sure the xinclude is in the source itself instead ?)
296 - if the plugin has no public header, don't add the c-file, add entries to the
297 -overrides.txt file (see playbin docs in plugins-base).
298 - to rebuild the docs, do:
299 make clean
300 make update
301 make
302 - examples will only show up using gtk-doc 1.4 or later - it relies on
303 merging stuff from .sgml with inline docs. We might want to change
304 this to only get stuff from the source.
305 - you need to commit resulting files to git:
306 - changes to *.signals and *.args
307 - new files for your plugin created in inspect/
308 - if you get this warning:
309 " Documentation in template xxx for ./tmpl/element-yyy:Short_Description
310 being overridden by inline comments"
311 per-default the description from the GST_ELEMENT_DETAILS is put to the
312 Short_Description. This warning mean you have a different one in the section
313 docs as "@short_description:".
314
315- the plugin-doc-list on the gstreamer homepage is updated along with other
316 web site updates.
317
318- maintainer tricks:
319 - in gst-plugins-foo/docs/plugins/, run
320 make check-inspected-versions
321 to show plugins whose inspect information is not up-to-date (which is
322 usually either because they have been moved to a different module or
323 because they are not built on the maintainer's machine for some reason).
324 Whether it really makes sense to update the version number is debatable
325 (after all, the inspected information may be outdated and things may have
326 changed, in which case it would be bad to change the version number)
327 - find files that have docs
328 for file in `find . -name "*.c" -exec grep -l " * SECTION:element-" {} \; | sort`; do if [ -e ${file/.c/.h} ]; then echo ${file/.c/.h}; else echo "no header for $file"; fi; done
329 for file in `find . -name "*.cc" -exec grep -l " * SECTION:element-" {} \; | sort`; do if [ -e ${file/.cc/.h} ]; then echo ${file/.cc/.h}; else echo "no header for $file"; fi; done
330 - add those .h files to EXTRA_HFILES in Makefile.am
331 - update gst-plugins-xxx-docs.sgml
332 cd docs/plugins
333 ls -1 xml/plugin-*.xml | sort | sed -e "s/\(.*\)/ \<xi:include href=\"\1\" \/\>/"
334 ls -1 xml/element-*.xml | grep -v -- "-details.xml" | sort | sed -e "s/\(.*\)/ \<xi:include href=\"\1\" \/\>/"
335 - maybe we can generate these lists after "make update" and just xi:include
336 them in gst-plugins-xxx-docs.sgml. They should be committed to the vcs.
337
338- possible errors:
339 - "multiple constraints for linkend ID":
340 check if each section in -sections.txt actually starts and ends with
341 <SECTION> and </SECTION>
342 - if a plugin does not show up:
343 - check inspect/plugin-xxx.xml and tmpl/elements-
344
345RANDOM THINGS I'VE LEARNED
346==========================
347
348* for clean builddir != srcdir separation, I wanted to use xmlto --searchpath
349 so the source xml could find the built entity file.
350 But xmlto --searchpath is (right now) for TeX input, not xml input.
351 xsltproc has a --path option (that xmlto doesn't use yet), but it
352 resolves single files to $(specified_path)/$(srcdir)/$(file)
353 For now, we need to hack around it by copying xml to the build dir.
354
355
356DEVHELP INTEGRATION
357-------------------
358Check https://wiki.gnome.org/Apps/Devhelp
359It's a really nice development app allowing you to look up API stuff
360from various gtk-doc'd libraries. GStreamer is one of these ;)
361
362gtk-doc generates both html API docs and the matching .devhelp(2) books.
363
364IMAGES
365------
366It's important to keep the original source format for images, to be able
367to change and regenerate later on. Original files go in
368docs/images
369