| Line | |
|---|
| 1 | ========= |
|---|
| 2 | generator |
|---|
| 3 | ========= |
|---|
| 4 | |
|---|
| 5 | generator provides a class that execute a serie of tasks |
|---|
| 6 | to generate the website, given a configuration. A task |
|---|
| 7 | is a virtual class that provide a transformation for a given type of |
|---|
| 8 | file. It is registered at runtime and its id correspond to the |
|---|
| 9 | section 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 | |
|---|
| 28 | The generator is programmed with a sequence of keys, that |
|---|
| 29 | will 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 | |
|---|