EDIT: Sphinx’s gone public: http://sphinx.pocoo.org/
While searching for an ideal documentation tool for build.py, i’ve checked pydoc, epydoc and many many more. Two days ago, I’ve landed on Python development version documentation site (http://docs.python.org/dev). Engine has been totally reworked (besides, new look n’ feel is simply beautiful). Now, it sits on Sphinx, which is boosted reStructuredText engine with syntax highlighting, Table of Contents generation and a bunch of another useful gadgets.
I saw it nearly perfect for my purposes, as I don’t like docstrings and I’ve had some good experiences with text markup syntax (Markdown, particularly). The only problem is, Sphinx isn’t available as a standalone package – it’s bundled with main Python branch. Hence, there’s a solution how to incorporate Sphinx into your projects.
At first, checkout python from svn server (you could checkout only Doc dir, but I’m not sure whether it breaks any internal dependencies), then cd into Doc dir and run make:
svn co http://svn.python.org/projects/python/trunk # checking out Python tree
cd trunk/Doc # moving into Documentation directory
make html
Makefile included within Doc directory with checkout proper Sphinx stuff, like syntax highlighting, reST parser etc. It will then start the documentation creation process. Stop it, cause probably you don’t need a local Python documentation mirror.
To use Sphinx in your apps, copy tools directory (in trunk/Doc) to your project and conf.py file to your documentation directory. You need to edit conf.py and edit/delete some field in order to not getting attacked by army of errors and warning.
After that, consult Sphinx usage by:
python tools/sphinx-build.py –usage
For example, you could use:
python tools/sphinx-build.py -b html mydocs myproject/docs # conf.py should be in mydocs dir
You should inspect http://docs.python.org/dev/documenting how to use reST syntax properly (and what are these additional features).
There’s also a need to take care of tools/sphinxext directory. As you can see, there are templates for main page, sidebar and etc.
Happy documenting!
Just the info I was looking for. Thanks!
Comment by Swaroop C H — March 9, 2008 @ 2:47 pm
Hi MH,
sphinx-build.py keeps looking for download.html and not finding it. I have download.html copied from tools/sphinxext to …/Doc and to …/Doc/mydocs.
I also tried
$ cd tools
$ sphinx-build -a -b html ../Doc/mydocs ../Doc/html_sphinx_output
but the error message
shinx.jinja.exceptions.TemplateNotFound: download.html
is still there.
Thanks.
Aroldo.
Comment by Aroldo Souza-Leite — March 19, 2008 @ 11:10 am
At first, thanks for your feedback:)
@Aroldo: as I can see this is an issue with latest Sphinx release.
It’s all about your conf.py file.
At first, comment these lines:
html_additional_pages = {
‘download’: ‘tools/sphinxext/download.html’,
}
So you won’t get that Exception. But, whoa, there’s another one:
TemplateNotFound: tools/sphinxext/indexcontent.html
In fact, there’s also an error with indexsidebar.html. After playing a bit with Sphinx, I’m sure that the reason of this is indeed this line:
# Content template for the index page, filename relative to this file.
It suggests as the path should be relative to conf.py location. That’s wrong! Sphinx searches for this path as relative to tools/sphinx/templates. At this moment, you’ve got two options:
1) Fix the lines to conform this:
html_index = ‘../../sphinxext/indexcontent.html’
# Custom sidebar templates, filenames relative to this file.
html_sidebars = {
‘index’: ‘../../sphinxext/indexsidebar.html’,
}
2) Put a phrase at the beginning of conf.py:
templates_path = ['tools/sphinxext']
And then simply change them as follows:
‘tools/sphinxext/indexcontent.html’ -> ‘indexcontent.html’ and so on.
I hope I’ve helped you:)
Comment by mhordecki — March 19, 2008 @ 11:19 pm
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
Comment by sandrar — September 10, 2009 @ 8:39 pm
Sign: umsun Hello!!! rcuwwymhyw and 961ssgfhphzye and 7993Sorry, what did you mean?? A??
Comment by megan fox — September 11, 2009 @ 4:52 pm