root / pycommunity / pycommunity / doc / generator.txt

Revision 68:83208f451b91, 1.0 kB (checked in by Tarek Ziad?? <tarek@…>, 17 months ago)

moving around

Line 
1=========
2generator
3=========
4
5generator provides a class that execute a serie of tasks
6to generate the website, given a configuration. A task
7is a virtual class that provide a transformation for a given type of
8file. It is registered at runtime and its id correspond to the
9section it covers::
10
11    >>> from generator import BaseTask
12    >>> class MyTask(BaseTask):
13    ...     def _getName(self):
14    ...         return 'glossary'
15    ...     def _run(self, configuration):
16    ...         print 'glossary processed'
17    ...
18    >>> from generator import registerTask
19    >>> registerTask(MyTask)
20    >>> class MyTask2(BaseTask):
21    ...     def _getName(self):
22    ...         return 'dummy'
23    ...     def _run(self, configuration):
24    ...         print 'dummy processed'
25    ...
26    >>> registerTask(MyTask2)
27
28The generator is programmed with a sequence of keys, that
29will call the task in order, with arguments::
30
31    >>> from generator import run
32    >>> run(['glossary', 'dummy'], None)
33    glossary processed
34    dummy processed
35
36
37   
Note: See TracBrowser for help on using the browser.