Fetchez le Python

September 11, 2008

zc.buildout recipe to build your Sphinx doc

Filed under: documentation, plone, python, zope — Tarek Ziadé @ 11:41 am
Tags: ,

Sphinx is now used by quite a few communities : Python, Django, Pylons, Grok (not sure about the current status), …

No wonder, it’s a blast.

We are now starting to use it to produce customer documentation for our buildout-based applications. Basically, a Sphinx structure is created in the buildout using sphinx-quickstart, and a few tweaks are made so the HTML and PDF outputs have a custom look.

Managing the documentation like the code makes life easier. This is one of the basic rule of agile documentation : separate the content from the layout, so you can provide documentation in any shape (html, pdf) with a single source.

To make things easier, I have released collective.recipe.sphinxbuilder.

This recipe:

  • creates for you a Sphinx-based documentation in your buildout
  • creates a single script in the bin folder to build the documentation with one command
  • provides an extensive set of options to drive Sphinx from buildout

Adding it in your buildout is as simple as :

[buildout]
parts =
  sphinx

[sphinx]
recipe = collective.recipe.sphinxbuilder

I have also customized the look and feel of the output so it uses the Plone logo and a custom css. This is configurable from the buildout configuration file of course. By the way, if someone from the Plone community wants to improve the CSS, please dot it ! (I am not good at this :) )

Notice that if you use LaTex or PDF rendering, you will need to install pdflatex. Furthermore, the recipe script will not work under Windows unless you install a Linux-like environment, since it uses the Makefile provided by Sphinx. I guess MSYS+MinGW should make it work, but I didn’t try.

8 Comments »

  1. Tarek, i can confirm that pylons use sphinx for the documentation:
    http://docs.pylonshq.com/

    Comment by RAGE2000 — September 11, 2008 @ 12:31 pm | Reply

  2. @RAGE2000, a ok thanks, I will update my post so it links to it.

    Comment by Tarek Ziadé — September 11, 2008 @ 12:41 pm | Reply

  3. I wrote a simple Windows batch file to build my doc.

    sphinx-build -b html source build

    The sphinx-build.exe will be in Scripts folder. e.g
    C:\Python24\Scripts\sphinx-build.exe

    Comment by Michaelangelo — September 11, 2008 @ 3:06 pm | Reply

  4. @Michaelangelo: yes, I think the best pick is to drop the Makefile and write a pure Python script, using sphinx-build. I’ll try that.

    In the meantime, sphinx-build.exe will be created under Windows as well by the recipe, and present in the bin folder of the buildout, so you can do:

    $ bin/sphinx-build -b html docs/source docs/build

    Comment by Tarek Ziadé — September 11, 2008 @ 3:30 pm | Reply

  5. Add to the list of project the scientific-Python-related projects. Matplotlib has a 500-pages-long documentation with Sphinx, including some very interesting addons to Sphinx, there a big documentation effort for numpy that uses Sphinx, ( http://sd-2116.dedibox.fr/pydocweb/wiki/Front Page/ ), Mayavi and Traits are using it, and at the SciPy conference a score of new projects (Sage, NetworkX) decided to move to it.

    Comment by Gael Varoquaux — September 12, 2008 @ 5:03 am | Reply

  6. Hi,

    Thanks for your work on this. I’ve been trying to keep decent documentation of my work and this will go a long way. And special thanks for making sure that it works under Windows. I was even able to use make to build a LaTeX version.

    Cheers,
    shurik

    Comment by Aleksandr Vladimirskiy — September 25, 2008 @ 10:46 pm | Reply

  7. A good site, good short contents of the good work. Congratulations !,

    Comment by Jonie — November 27, 2008 @ 9:38 am | Reply

  8. You may want to update the sphinx dependency – I am getting version conflict (between 0.6 and 0.6.1) during buildout.

    Comment by Sridhar Ratnakumar — April 6, 2009 @ 5:42 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.