|
1 | 1 | ## java2python Customization |
2 | 2 |
|
3 | | -### Basic |
| 3 | +The java2python compiler defers a significant amount of its processing to |
| 4 | +handlers defined within configuration files. These configuration files, |
| 5 | +directories, and modules are supplied to the `j2py` script on the command |
| 6 | +line. See the [usage][] page for instructions on specifying additional configs. |
4 | 7 |
|
5 | | -### Advanced |
| 8 | +The default configuration module is `java2python.config.default`. Refer to [the source |
| 9 | +of that module][1] for its values and additional descriptions. |
| 10 | + |
| 11 | +### A Note About Some of the Names: Prologue, Base, Head, and Epilogue |
| 12 | + |
| 13 | +When a config point has `Prologue` in its name, it means that the item will be |
| 14 | +responsible for generating code before the output. For example, method |
| 15 | +prologue handlers generate decorators, while module prologue handlers generate |
| 16 | +the shebang line. |
| 17 | + |
| 18 | +When a config point has `Base` in the name, it means that the item will be |
| 19 | +responsible for generating the base classes of a class, enum, or interface. |
| 20 | + |
| 21 | + |
| 22 | +A config point with `Head` in the name means that the item will be responsible |
| 23 | +for generating code for the section between the declaration and the body of the |
| 24 | +item. For example: |
| 25 | + |
| 26 | + class X(object): |
| 27 | + """ this is a comment generated by classHeadHandlers """ |
| 28 | + |
| 29 | +Finally, when a config point contains `Epilogue`, it means that the item will |
| 30 | +be responsible for generating code after the body of the item. The only |
| 31 | +recognized epilogue config point is `moduleEpilogueHandlers`, which generates a |
| 32 | +main script stanza if necessary. |
| 33 | + |
| 34 | +### Customization Points |
| 35 | + |
| 36 | +* indentPrefix |
| 37 | +* commentPrefix |
| 38 | +* expressionVariableNamingHandler |
| 39 | + |
| 40 | +* modulePrologueHandlers |
| 41 | +* moduleEpilogueHandlers |
| 42 | +* moduleOutputHandlers |
| 43 | +* modulePackageDeclarationHandler |
| 44 | +* moduleImportDeclarationHandler |
| 45 | +* moduleOutputSubs |
| 46 | + |
| 47 | + |
| 48 | +* classHeadHandlers |
| 49 | +* classBaseHandlers |
| 50 | +* classPostWalkHandlers |
| 51 | + |
| 52 | +* interfaceBaseHandlers |
| 53 | +* interfaceHeadHandlers |
| 54 | + |
| 55 | +* enumHeadHandlers |
| 56 | +* enumValueHandler |
| 57 | + |
| 58 | + |
| 59 | +* methodParamHandlers |
| 60 | +* methodLockFunctionName |
| 61 | +* methodHeadHandlers |
| 62 | +* methodPrologueHandlers |
| 63 | + |
| 64 | +* astTransforms |
| 65 | +* typeSubs |
| 66 | + |
| 67 | + |
| 68 | +[usage]: https://github.com/natural/java2python/tree/master/doc/usage.md |
| 69 | +[1]: https://github.com/natural/java2python/blob/master/java2python/config/default.py |
0 commit comments