Michele Simionato schrieb:
> I would like to use Sphinx to process my "Adventures of a Pythonista
> in Schemeland"
> (http://www.artima.com/weblogs/viewpost.jsp?thread=251474) and collect them in
> a nice hyperlinked document with search capabilities.
> Each Adventure is a Scheme file (extension .ss) which contains a big
> docstring with
> the text of the Adventure, in ReST format. Currently I have a function
> scheme2rst(schemefilename) which takes in input the filename of the Scheme
> file
> (for instance adventure1.ss) and returns the filename of the corresponding
> .rst
> file (i.e. adventure1.rst), which is written on the file system as a
> side effect.
> I could very well write a preprocessor script that converts all the Scheme
> files
> to rst files and run Sphinx after that, but I would rather prefer to
> integrate my
> scheme2rst utility in Sphinx, so that I can avoid errors like
> forgetting to regenerate
> the .rst files. What's the suggested way to do something like that?
> I assume there are hooks in Sphinx such that I can preprocess the files
> automatically.
You can connect to the "builder-inited" event in a Sphinx extension.
This may look like this::
def generate(app):
# generate the source files, using app.srcdir as the base dir.
# if you only write them if they have changed, Sphinx won't
# re-read them as well
def setup(app):
app.connect('builder-inited', generate)
Thankfully, conf.py is processed like an extension, so you can put these
functions there.
Georg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---