Roman schrieb:
> Hello. I hope the following recipe will be found useful.
>
> Since Sphinx uses regular Python file, it is possible to use "regular"
> Python modules :-). To be specific, you can use :mod:atexit and
> sitemap_gen module
>
> @atexit.register
> def generate_sitemap():
> if 'www' not in outdir:
> return
> try:
> import sitemap_gen
>
> config = <<<your site xml configuration>>>
> <<<write file to the disk>>>
>
> sitemap = sitemap_gen.CreateSitemapFromFile(<<<path to the
> file>>>, True)
> if not sitemap:
> print 'ERROR(SITEMAP): configuration file errors'
> else:
> sitemap.Generate()
> print 'ERRORS(SITEMAP): %d' %
> sitemap_gen.output.num_errors
> print 'WARNINGS(SITEMAP): %d' %
> sitemap_gen.output.num_warns
> except Exception, error:
> print "ERROR(SITEMAP): sitemap file was not generated - ", str
> (error)
>
> Thus, every time you update the documentation, sitemap will be updated
> to.
I'd recommend using not atexit, but Sphinx' "build-finished" event, like this:
def setup(app)
app.connect('build-finished', generate_sitemap)
The function generate_sitemap will then be called at the end of each build.
(It needs to take an additional parameter, which will be the exception if
one happened during building, or None. In your case, I'd skip building the
sitemap if the exception parameter is not None.)
cheers,
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
-~----------~----~----~----~------~----~------~--~---