Blame docs/README

Packit f546b1
GStreamer documentation notes
Packit f546b1
Packit f546b1
IMPORTANT
Packit f546b1
=========
Packit f546b1
Packit f546b1
Please make sure you've read and understood everything in this file
Packit f546b1
before you try changing documentation.
Packit f546b1
Packit f546b1
Some of the docbook-related bits in this README might be out of date now that
Packit f546b1
quite a bit of the documentation has moved into the gst-docs repository.
Packit f546b1
Packit f546b1
OVERVIEW
Packit f546b1
========
Packit f546b1
Packit f546b1
GStreamer has two sets of documentation that we maintain:
Packit f546b1
* API references, using gtk-doc (gstreamer, gstreamer-libs)
Packit f546b1
* FAQ / Application Development Manual / Plugin Writer's Guide / Tutorials -
Packit f546b1
  these are maintained in markdown format and live in the gst-docs repository.
Packit f546b1
Packit f546b1
DOCBOOK NOTES
Packit f546b1
=============
Packit f546b1
Packit f546b1
OK, I've grown so tired of having to coax the docs to build every time I
Packit f546b1
get round to it that I've decided to note down some of the things that
Packit f546b1
are important to know.
Packit f546b1
Packit f546b1
OVERVIEW
Packit f546b1
--------
Packit f546b1
* Our documentation should all be Docbook/XML.  No SGML.
Packit f546b1
* The source for the documentation is:
Packit f546b1
  - one or more .xml files, with the main one being gstreamer-(whatever).xml
Packit f546b1
  - image files
Packit f546b1
    - in .svg
Packit f546b1
    - in .png (and maybe others)
Packit f546b1
* We want to generate docs in HTML, PS and PDF
Packit f546b1
* We want to use xml to to generate these
Packit f546b1
Packit f546b1
CONVENTIONS
Packit f546b1
-----------
Packit f546b1
We stick to some simple conventions for writing docbook documentation.
Packit f546b1
* id names:
Packit f546b1
  - all id's start with chapter-, part-, section-, or misc-
Packit f546b1
  - verify this is the case by looking at the generated file names in html/
Packit f546b1
  - sections should also include the chapter name;
Packit f546b1
    for example in a chapter called chapter-example, a section would be
Packit f546b1
    called section-example-hello-world
Packit f546b1
Packit f546b1
HOW IMAGES ARE HANDLED
Packit f546b1
----------------------
Packit f546b1
* the format of images used is:
Packit f546b1
  - PNG for html
Packit f546b1
  - EPS for ps
Packit f546b1
  - PDF for pdf
Packit f546b1
Packit f546b1
* images may need to be converted from their source format to the end format
Packit f546b1
Packit f546b1
* a file called image.entities is generated that provides two entities:
Packit f546b1
  ℑ and ℑ
Packit f546b1
  ℑ is the file extension (png, ps, pdf)
Packit f546b1
* all generated images will be put in images/
Packit f546b1
Packit f546b1
HOW THE BUILD WORKS FOR EACH FORMAT
Packit f546b1
-----------------------------------
Packit f546b1
* HTML:
Packit f546b1
  - xmlto html gstreamer-whatever.xml should produce the html docs.
Packit f546b1
  - We do this in the html subdir of the doc builddir.
Packit f546b1
  - images are copied to (builddir)/html/images
Packit f546b1
  - PNGS should be set to all of the png's referenced for html, both
Packit f546b1
    already there and auto-generated
Packit f546b1
Packit f546b1
* PS :
Packit f546b1
  - images are converted to .ps files in EPS format.  Generated images are
Packit f546b1
    put in images/
Packit f546b1
  - xmlto ps gstreamer-whatever.xml generates the ps file
Packit f546b1
Packit f546b1
* PDF :
Packit f546b1
  There are two ways:
Packit f546b1
  - ps2pdf is the easiest
Packit f546b1
  - we specify ps, PS as the image type, but using xmlto the build will fail
Packit f546b1
    because it uses ps2pdf internally and it fails to generate the images
Packit f546b1
    By hand-generating .pdf images before xmlto we can make the build succeed.
Packit f546b1
    (This is why image-pdf has file ext pdf but type EPS; this tricks xmlto in
Packit f546b1
     doing the right thing)
Packit f546b1
    xmlto pdf gstreamer-whatever.xml generates pdf (but seems to fail on the
Packit f546b1
    FAQ, so for now we use ps2pdf)
Packit f546b1
Packit f546b1
HOW THE BUILD SYSTEM IS SET UP
Packit f546b1
------------------------------
Packit f546b1
* make all should build html, ps, and pdf
Packit f546b1
* html is built in a subdir, with the png/ps images copied there
Packit f546b1
* ps and pdf are built in the current dir, in one file
Packit f546b1
Packit f546b1
SPELL CHECKING
Packit f546b1
--------------
Packit f546b1
* with aspell
Packit f546b1
  * aspell -b -c --mode=sgml --lang=en <file>.xml
Packit f546b1
    unfortunately the curses-ui of aspell (0.50.5) has problems with the xml tags
Packit f546b1
Packit f546b1
Packit f546b1
GTK-DOC NOTES
Packit f546b1
=============
Packit f546b1
Packit f546b1
* files under revision control:
Packit f546b1
  - Makefile.am
Packit f546b1
  - gstreamer-sections.txt
Packit f546b1
    describes which symbols later appear on one api-doc page
Packit f546b1
    configure which symbols are shown/invisible/private
Packit f546b1
  - gstreamer.types
Packit f546b1
    the types file lists all get_type() functions that register the GObject types
Packit f546b1
  - gstreamer-docs.sgml
Packit f546b1
    defines the overall structure of the api documentation
Packit f546b1
  - tmpl/
Packit f546b1
    - only add the file to CVS if you have at least filled the short description
Packit f546b1
      (filename corresponds to the <FILE> tag in the sections file)
Packit f546b1
    - document as much as possible in the source (*.c files)
Packit f546b1
Packit f546b1
* what to do when adding a new piece of API:
Packit f546b1
  - add both an entity and use the entity in gstreamer-docs.sgml
Packit f546b1
  - add a new <SECTION> to gstreamer-sections.txt in the correct alphabetical
Packit f546b1
    position related to the other sections (so that it is easier to locate)
Packit f546b1
  - add all documented symbols to gstreamer-sections.txt in the proper section
Packit f546b1
    (default),<SUBSECTION Standard>,<SUBSECTION Private>
Packit f546b1
  - document at least the Short_Description in tmpl/.sgml
Packit f546b1
  - document symbols where they are defined, so that when one changes the
Packit f546b1
    definition, the chaces are good that docs are updated.
Packit f546b1
    - document functions, signals in the .c files
Packit f546b1
    - document structs, typedefs, enums in the .h files
Packit f546b1
Packit f546b1
* checklist:
Packit f546b1
  - make sure *-sections.txt has a <TITLE> set for each <FILE>
Packit f546b1
  - add only *one* <TITLE> to each file, when you have multiple classes in one
Packit f546b1
    source-file, create one <FILE> section for each class
Packit f546b1
  - the <TITLE> *must* be named like the type of the GType, when it gets
Packit f546b1
    registered (otherwise gtkdoc introspection fails)
Packit f546b1
  - for clarity name the <FILE> like the <TITLE>, but all lowercase
Packit f546b1
Packit f546b1
* what to do when trying to improve the docs
Packit f546b1
  - compare the output of
Packit f546b1
    grep "_get_type" gstreamer-sections.txt | sort
Packit f546b1
    with the types in XXX.types to detect entries that
Packit f546b1
    are maybe missing
Packit f546b1
  - gtk docs does not warns about empty member docs!, run
Packit f546b1
    find . -name "*.[c,h]" -exec egrep -Hn "^ +\* +@.*: *$" {} \;
Packit f546b1
    in the project root to find them
Packit f546b1
  - gtk docs does not warns about empty Returns: docs!, run
Packit f546b1
    find . -name "*.[c,h]" -exec egrep -Hn "^ +\* +@Returns: *$" {} \;
Packit f546b1
    in the project root to find them
Packit f546b1
Packit f546b1
* what happens during a gtk-doc build ?
Packit f546b1
  - Scan step:
Packit f546b1
    - based on a $(MODULE).types file:
Packit f546b1
      - gtkdoc-scangobj creates a gtkdoc-scan binary
Packit f546b1
        - using CC, LD, CFLAGS, LDFLAGS env var
Packit f546b1
        - using --type-init-func and --module parameters
Packit f546b1
        - gtkdoc-scan creates
Packit f546b1
          - $MODULE.signals.new
Packit f546b1
          - $MODULE.hierarchy.new
Packit f546b1
          - $MODULE.interfaces.new
Packit f546b1
          - $MODULE.prerequisites.new
Packit f546b1
          - $MODULE.args.new
Packit f546b1
        - generated source and objects get deleted
Packit f546b1
        - gtkdoc-scangobj merges changes into the original files
Packit f546b1
    - gtkdoc-scan
Packit f546b1
      - extracts decls of functions, macros, enums, structs, unions from headers
Packit f546b1
      - generates
Packit f546b1
        - $MODULE-decl.txt
Packit f546b1
        - $MODULE-decl-list.txt
Packit f546b1
      - $MODULE-decl-list.txt then should get copied to $MODULE-sections.txt
Packit f546b1
    - scan-build.stamp gets created
Packit f546b1
  
Packit f546b1
  - Template generation step:
Packit f546b1
    - gtkdoc-mktmpl --module=$MODULE
Packit f546b1
      - reads in tmpl/*.sgml
Packit f546b1
      - moves them to tmpl/*.sgml.bak
Packit f546b1
      - recreates tmpl/*.sgml according to $MODULE-sections.txt
Packit f546b1
      - moves unused stuff to $MODULE-unused.txt
Packit f546b1
    - tmpl-build.stamp gets generated
Packit f546b1
Packit f546b1
* Possible errors and how to fix them
Packit f546b1
  - Warning: multiple "IDs" for constraint linkend: gst-tag-register.
Packit f546b1
    - check if gst_tag_register is listed more than once in -sections.txt
Packit f546b1
Packit f546b1
STYLE GUIDE FOR GTK-DOC
Packit f546b1
=======================
Packit f546b1
- this is in addition to gtk-doc's style-guide.txt
Packit f546b1
Packit f546b1
- when documenting signals, use "the #Gst..." for the object receiving the
Packit f546b1
  signal; no trailing dot, and no "that received the signal"
Packit f546b1
- function/macro descriptions are descriptive, not imperative
Packit f546b1
  ie, it uses the third person verb
Packit f546b1
- synopsis and description should have most-used/application functions at the
Packit f546b1
  top
Packit f546b1
- functions that can return FALSE/NULL or fail should describe their failure
Packit f546b1
  conditions like this:
Packit f546b1
  * Returns NULL if no element with the given name is found in the bin, if
Packit f546b1
  * the frobble was stuck in the froob, or the frizzle was frazzed.
Packit f546b1
- a line with function attributes should be added before Returns:
Packit f546b1
  - can contain:
Packit f546b1
    "MT safe." - the function is verified to be multithreadingsafe
Packit f546b1
    "Caller owns returned reference" for refcounted classes
Packit f546b1
    "Caller owns returned value" for other types (iterators, ..)
Packit f546b1
  - we do this because, in contrast with GLib/GTK, we are more explicit
Packit f546b1
    about threadsafety and related issues
Packit f546b1
- link to signals from the description like this:
Packit f546b1
  * The <link linkend="GstBin-element-added">element-added</link> signal
Packit f546b1
Packit f546b1
WEBSITE DOCUMENTATION
Packit f546b1
=====================
Packit f546b1
Packit f546b1
Updating the online documentation is pretty simple.
Packit f546b1
Make sure that you
Packit f546b1
a) have a working freedesktop.org account
Packit f546b1
b) $HOME/.ssh/config set up so that it has the right User for the Host
Packit f546b1
   (for example, I have:
Packit f546b1
Host freedesktop.org
Packit f546b1
  User thomasvs
Packit f546b1
c) verify this works by doing ssh freedesktop.org and being logged in without
Packit f546b1
   a password prompt
Packit f546b1
d) have verified your changes build documentation locally.
Packit f546b1
Packit f546b1
Then, after updating any of the docs, run "make upload" from that directory.
Packit f546b1
Or, run "make upload" from this (docs) directory.
Packit f546b1
Packit f546b1
DOCUMENTING ELEMENTS
Packit f546b1
====================
Packit f546b1
As of september 2005 we have some system to document plugins and elements
Packit f546b1
in the various plugin packages.
Packit f546b1
Packit f546b1
- in a submodule, docs go in docs/plugins
Packit f546b1
- template can be copied from gst-plugins-base
Packit f546b1
- to add plugins documentation:
Packit f546b1
  - create docs/plugins
Packit f546b1
  - create Makefile.am and friends, add to configure.ac
Packit f546b1
  - create docs/version.entities.in, add to configure.ac
Packit f546b1
  - in docs/plugins:
Packit f546b1
    - create $(module)-plugins.types with #include <gst/gst.h>
Packit f546b1
    - run make
Packit f546b1
    - edit the -docs.sgml
Packit f546b1
    - add to cvs:
Packit f546b1
      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
Packit f546b1
      cvs add inspect
Packit f546b1
      cvs add inspect/*.xml
Packit f546b1
    - Additional types can be added to the documentation by placing them in
Packit f546b1
      the .types file like this:
Packit f546b1
        type:GstPlayBaseBin
Packit f546b1
      This is useful for documenting plugin-private types that implement
Packit f546b1
      signals or properties. The GType is looked up by name after all the
Packit f546b1
      element classes have been printed - so this is only useful for types
Packit f546b1
      that are created as a consequence of loading plugins and registering
Packit f546b1
      the element(s).
Packit f546b1
Packit f546b1
- to add a plugin to be documented:
Packit f546b1
  - make sure inspect/ has generated a inspect/plugin-xxx.xml file for it.
Packit f546b1
    - if it has not, make sure you have pygst installed and run 'make update'.
Packit f546b1
      and add it to CVS.
Packit f546b1
  - add an xi:include in -docs.sgml in the Plugins chapter for that plugin
Packit f546b1
Packit f546b1
- to add an element to be documented:
Packit f546b1
  - add an xi:include in the Elements chapter for the element
Packit f546b1
    in the main -docs.sgml
Packit f546b1
  - add a section for it in -sections.txt with
Packit f546b1
      <SECTION>
Packit f546b1
      <FILE>element-(element)</FILE>
Packit f546b1
      <TITLE>(element)</TITLE>
Packit f546b1
      GstXxx
Packit f546b1
      <SUBSECTION Standard>
Packit f546b1
      GstXxxClass
Packit f546b1
      GST_XXX
Packit f546b1
      GST_XXX_CLASS
Packit f546b1
      GST_IS_XXX
Packit f546b1
      GST_IS_XXX_CLASS
Packit f546b1
      GST_TYPE_XXX
Packit f546b1
      gst_xxx_get_type
Packit f546b1
      </SECTION>
Packit f546b1
  - add a gtk-doc section to the source code like:
Packit f546b1
/**
Packit f546b1
 * SECTION:element-multifdsink
Packit f546b1
Packit f546b1
  and fill it with documentation about the element, preferably inside
Packit f546b1
  a <refsect2> docbook container.
Packit f546b1
  - add an example:
Packit f546b1
    - either a few pipelines, inside <programlisting>
Packit f546b1
    - or a piece of code:
Packit f546b1
      - create an example program (element)-example.c in the plugin dir
Packit f546b1
      - add the full path (starting with $(top_srcdir)) for this example
Packit f546b1
        to the EXAMPLE_CFILES variable in Makefile.am
Packit f546b1
      - add an xinclude of a file named "element-(element)-example.xml"
Packit f546b1
        to the docbook documentation piece in the element source code
Packit f546b1
  - add the header to EXTRA_HFILES in Makefile.am to be able to document
Packit f546b1
    signals and args; in that case, the object struct needs to be in
Packit f546b1
    -sections.txt outside of the Standard Subsection (which is annoying,
Packit f546b1
    but ...)
Packit f546b1
    (FIXME: are we sure we can both do the xinclude from the tmpl/ sgml,
Packit f546b1
     as well as an override from the source itself ? maybe we should just
Packit f546b1
     make sure the xinclude is in the source itself instead ?)
Packit f546b1
  - if the plugin has no public header, don't add the c-file, add entries to the
Packit f546b1
    -overrides.txt file (see playbin docs in plugins-base).
Packit f546b1
  - to rebuild the docs, do:
Packit f546b1
    make clean
Packit f546b1
    make update
Packit f546b1
    make
Packit f546b1
  - examples will only show up using gtk-doc 1.4 or later - it relies on
Packit f546b1
    merging stuff from .sgml with inline docs.  We might want to change
Packit f546b1
    this to only get stuff from the source.
Packit f546b1
  - you need to commit resulting files to git:
Packit f546b1
    - changes to *.signals and *.args
Packit f546b1
    - new files for your plugin created in inspect/
Packit f546b1
  - if you get this warning:
Packit f546b1
    " Documentation in template xxx for ./tmpl/element-yyy:Short_Description
Packit f546b1
      being overridden by inline comments"
Packit f546b1
    per-default the description from the GST_ELEMENT_DETAILS is put to the
Packit f546b1
    Short_Description. This warning mean you have a different one in the section
Packit f546b1
    docs as "@short_description:".
Packit f546b1
Packit f546b1
- the plugin-doc-list on the gstreamer homepage is updated along with other
Packit f546b1
  web site updates.
Packit f546b1
Packit f546b1
- maintainer tricks:
Packit f546b1
  - in gst-plugins-foo/docs/plugins/, run
Packit f546b1
        make check-inspected-versions
Packit f546b1
    to show plugins whose inspect information is not up-to-date (which is
Packit f546b1
    usually either because they have been moved to a different module or
Packit f546b1
    because they are not built on the maintainer's machine for some reason).
Packit f546b1
    Whether it really makes sense to update the version number is debatable
Packit f546b1
    (after all, the inspected information may be outdated and things may have
Packit f546b1
    changed, in which case it would be bad to change the version number)
Packit f546b1
  - find files that have docs
Packit f546b1
    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
Packit f546b1
    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
Packit f546b1
    - add those .h files to EXTRA_HFILES in Makefile.am
Packit f546b1
  - update gst-plugins-xxx-docs.sgml
Packit f546b1
    cd docs/plugins
Packit f546b1
    ls -1 xml/plugin-*.xml | sort | sed -e "s/\(.*\)/    \<xi:include href=\"\1\" \/\>/"
Packit f546b1
    ls -1 xml/element-*.xml | grep -v -- "-details.xml" | sort | sed -e "s/\(.*\)/    \<xi:include href=\"\1\" \/\>/"
Packit f546b1
    - maybe we can generate these lists after "make update" and just xi:include
Packit f546b1
      them in gst-plugins-xxx-docs.sgml. They should be committed to the vcs.
Packit f546b1
Packit f546b1
- possible errors:
Packit f546b1
  - "multiple constraints for linkend ID":
Packit f546b1
    check if each section in -sections.txt actually starts and ends with
Packit f546b1
    <SECTION> and </SECTION>
Packit f546b1
  - if a plugin does not show up:
Packit f546b1
    - check inspect/plugin-xxx.xml and tmpl/elements-
Packit f546b1
Packit f546b1
RANDOM THINGS I'VE LEARNED
Packit f546b1
==========================
Packit f546b1
Packit f546b1
* for clean builddir != srcdir separation, I wanted to use xmlto --searchpath
Packit f546b1
  so the source xml could find the built entity file.
Packit f546b1
  But xmlto --searchpath is (right now) for TeX input, not xml input.
Packit f546b1
  xsltproc has a --path option (that xmlto doesn't use yet), but it
Packit f546b1
  resolves single files to $(specified_path)/$(srcdir)/$(file)
Packit f546b1
  For now, we need to hack around it by copying xml to the build dir.
Packit f546b1
Packit f546b1
Packit f546b1
DEVHELP INTEGRATION
Packit f546b1
-------------------
Packit f546b1
Check https://wiki.gnome.org/Apps/Devhelp
Packit f546b1
It's a really nice development app allowing you to look up API stuff
Packit f546b1
from various gtk-doc'd libraries.  GStreamer is one of these ;)
Packit f546b1
Packit f546b1
gtk-doc generates both html API docs and the matching .devhelp(2) books.
Packit f546b1
Packit f546b1
IMAGES
Packit f546b1
------
Packit f546b1
It's important to keep the original source format for images, to be able
Packit f546b1
to change and regenerate later on.  Original files go in
Packit f546b1
docs/images