views:

807

answers:

5

Sphinx is a Python library to generate nice documentation from a set of ReST formatted text files.

I wonder if any one has written Sphinx plugins to make it generate personal websites and blogs.

Especially for blogs, there needs to be a way to automatically list posts chronologically and generate a RSS feed. One needs to write a Sphinx plugin to do such special page/xml generation.

Has anyone tried this before?

A: 

Not Sphinx, but several of the sites at http://codespeak.net/ are done with scripts that take ReST text, generates HTML and uploads them to the site. I didn't write those scripts though, but I've used them.

It's a reasonable way to generate sites if the sites need to contain a lot of ReST files anyway, like when generating documentation for python modules, which of course these sites are all about. It's also good if you need the site to be version controlled, because you can keep the source code in svn or hg, or something.

But if you start writing a lot of automatic menues and other extensions, what you will end up with in the end is a content management system. And there is plenty of those around already, so you might want to look at them first.

Another example is the new packages.python.org. There you can generate your documentation in anyway you want it, and then through PyPI upload a zip-file with the docs. Distribute has done this with Sphinx: http://packages.python.org/distribute . But there no particular script is needed, that's just generating HTML from Sphinx documentation.

However...

I must say that I find the idea of writing a blogging software as Sphinx extension a bit funny, especially since there is so much excellent blogging software out there already. And nothing is going to beat Wordpress anyway, and wordpress.com has been a great blogging experience for me. But as an exercise in how much you can abuse Sphinx, why not! :-)

Lennart Regebro
Using Sphinx over Wordpress has the advantage that your articles are just plain text, which can be written in your favorite editor, put under version control, can be grepped, syntax-highlighted, etc.
Roberto Bonvallet
And Wordpress code highlighting is terrible for python, in my experience, whereas in Sphinx, it works :)
Gregg Lind
+4  A: 

Doug hellmann, author of the 'Python Module of the Week' does his site using Sphinx.

http://www.doughellmann.com/PyMOTW/

He has several posts which cover sphinx topics that can probably help you on your way:

http://blog.doughellmann.com/search/label/sphinx

monkut
nice find - looks like an interesting way of going about blogging
warren
+2  A: 

I redid my personal website (http://homepage.mac.com/s_lott/steve/) in Sphinx. It works nicely. Sadly, the SO markup mangles the _ in my URL.

I also rewrote the entire Introduction to Programming for Non-Programmers (http://homepage.mac.com/s_lott/books/nonprog/html/index.html) book in Sphinx. I'm in the process of rewriting Introduction to Python in Sphinx.

I do not use Sphinx for blogs -- it's not perfectly convenient, but it would work. I use blogspot for low-graphics/high-text and relatively high-velocity blogging. I use iWeb (http://web.me.com/s_lott/Travel/Welcome.html) for high graphic and relatively low-velocity blogging.

S.Lott
The first two links are broken!
Sridhar Ratnakumar
Silly SO markup mangles the _'s. I think I have them fixed. The point is that I use Sphinx heavily.
S.Lott
+1  A: 

I've done it at http://reinout.vanrees.org/weblog . The key trick is to do add a preprocessor step. I've got my blog entries in a weblog/yyyy/mm/dd/ folder structure.

A script iterates through that folder structure, creating index.txt files in every directory, listing the subitems. The normal sphinx process then renders those index.txt files.

I added a custom sphinx processor for tags. So ".. tags:: python, buildout" somewhere at the top of my weblog entry generates the tags. And the preprocessor again collects those entries and writes out a weblog/tags/TAGNAME.txt file which sphinx again renders normally.

The preprocessor also creates the root weblog/index.txt with the latest 10 entries. And an weblog/atom.xml in (hardcoded) the output directory for the rss feed.

So: you need some custom stuff, but it is pretty much plain text, so for me it was a nice exercise. And you get to write some helper scripts to make life easy, for instance one that copies a textfile from somewhere to today's weblog directory (including creation of missing directories and an "svn add").

Reinout van Rees
+1  A: 

It's worth knowing that there is an RSS extension for sphinx in the sphinx-contrib extensions, called sphinxcontrib.feed It and many other fun Sphinx things live at http://bitbucket.org/birkenfeld/sphinx-contrib/

(Disclaimer: I wrote the feed extension.)

dan mackinlay