Blame docs/README

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