Add html-collect-pages event.

This commit is contained in:
Georg Brandl
2010-01-13 23:42:58 +01:00
parent 65b426b22b
commit cbbae81e8f
4 changed files with 17 additions and 2 deletions

View File

@@ -7,6 +7,8 @@ Release 1.0 (in development)
* Support for docutils 0.4 has been removed.
* Added ``html-collect-pages`` event.
* Added ``tab-width`` option to ``literalinclude`` directive.
* The ``html_sidebars`` config value can now contain patterns as

View File

@@ -360,7 +360,15 @@ registered event handlers.
.. versionadded:: 0.5
.. event:: page-context (app, pagename, templatename, context, doctree)
.. event:: html-collect-pages (app)
Emitted when the HTML builder is starting to write non-document pages. You
can add pages to write by returning an iterable from this event consisting of
``(pagename, context, templatename)``.
.. versionadded:: 1.0
.. event:: html-page-context (app, pagename, templatename, context, doctree)
Emitted when the HTML builder has created a context dictionary to render a
template with -- this can be used to add custom elements to the context.

View File

@@ -47,6 +47,7 @@ events = {
'missing-reference': 'env, node, contnode',
'doctree-resolved': 'doctree, docname',
'env-updated': 'env',
'html-collect-pages': 'builder',
'html-page-context': 'pagename, context, doctree or None',
'build-finished': 'exception',
}

View File

@@ -381,8 +381,12 @@ class StandaloneHTMLBuilder(Builder):
def finish(self):
self.info(bold('writing additional files...'), nonl=1)
# the global general index
# pages from extensions
for pagelist in self.app.emit('html-collect-pages'):
for pagename, context, template in pagelist:
self.handle_page(pagename, context, template)
# the global general index
if self.config.html_use_index:
# the total count of lines for each index letter, used to distribute
# the entries into two columns