Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

python - Using Sphinx to write personal websites and blogs

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?

question from:https://stackoverflow.com/questions/1576340/using-sphinx-to-write-personal-websites-and-blogs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've done it at http://reinout.vanrees.org/weblog. The key trick is to 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 sub-items. 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").


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...