Skip to content

Commit 9eb53ea

Browse files
author
Troy Melhase
committed
Better attempt.
1 parent e66e86e commit 9eb53ea

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

doc/customization.md

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,35 @@ handlers defined within configuration files. These configuration files,
55
directories, and modules are supplied to the `j2py` script on the command
66
line. See the [usage][] page for instructions on specifying additional configs.
77

8-
The default configuration module is `java2python.config.default`. Refer to [the source
9-
of that module][1] for its values and additional descriptions.
8+
The default configuration module is `java2python.config.default`. Refer to
9+
[the source of that module][1] for details and additional descriptions.
1010

1111

1212
### Usage
1313

14-
To change the behavior of some or all of the config items, create a Python
15-
file, define the items you want, and specify that file when invoking `j2py`.
14+
To change the behavior of some or all of these config items, create a Python
15+
file, define in it the items you want, and specify that file when invoking
16+
`j2py`.
1617

1718
For example, if you would like to change the comment prefix to `##`, you might
1819
do this:
1920

20-
$ echo "indentPrefix = '##'" >> myconfig.py
21+
$ echo "indentPrefix = '##'" >> ./myconfig.py
2122

2223
Then run the script:
2324

24-
$ j2py SomeJavaSource.java -c myconfig.py
25+
$ j2py SomeJavaSource.java -c ./myconfig.py
2526

2627
The config files are Python modules, so you can use the full power of Python
27-
when writing your configurations.
28+
when writing them.
29+
30+
31+
### Defaults
32+
33+
Many of the defaults are built using values imported from the
34+
`java2python.mod.basic` module. Refer to the [source of that module][2] for
35+
details. The `java2python.mod` subpackage contains other modules with
36+
additional config handlers.
2837

2938

3039
### A Note About Some of the Names: Prologue, Base, Head, and Epilogue
@@ -46,8 +55,8 @@ item. For example:
4655

4756
Finally, when a config point contains `Epilogue`, it means that the item will
4857
be responsible for generating code after the body of the item. The only
49-
recognized epilogue config point is `moduleEpilogueHandlers`, which generates a
50-
main script stanza if necessary.
58+
recognized epilogue config point is `moduleEpilogueHandlers`, which (by
59+
default) generates a main script stanza if necessary.
5160

5261

5362
### Override vs. Replace
@@ -65,7 +74,7 @@ in your config:
6574
6675
modulePrologueHandlers.append(myPrologue)
6776

68-
Values can be remove in a similar way:
77+
Values can be removed in a similar way:
6978

7079
from java2python.config.default import modulePrologueHandlers
7180
from java2python.mod import basic
@@ -85,16 +94,16 @@ and their default values.
8594

8695
#### <a name="indentPrefix"></a>indentPrefix
8796

88-
Leading indent character or characters. Four spaces are used because that is
89-
the recommendation of PEP 8.
97+
Leading indent character or characters. Four spaces are the default because
98+
that is the recommendation of [PEP 8][].
9099

91100
Default: ` ` (four spaces)
92101

93102

94103
#### <a name="commentPrefix"></a>commentPrefix
95104

96105
Prefix character or characters for comments. The hash+space is recommended by
97-
PEP 8.
106+
[PEP 8][].
98107

99108
Default: `# ` (hash + space)
100109

@@ -112,7 +121,12 @@ Default: `basic.globalNameCounter`
112121
These values are strings or generators that yield strings for a module
113122
prologue.
114123

115-
Default: `[basic.shebangLine, basic.simpleDocString, basic.maybeBsr, basic.maybeSyncHelpers]`
124+
Default:
125+
```[basic.shebangLine,
126+
basic.simpleDocString,
127+
basic.maybeBsr,
128+
basic.maybeSyncHelpers
129+
]```
116130
117131
118132
#### <a name="moduleEpilogueHandlers"></a>moduleEpilogueHandlers
@@ -124,7 +138,9 @@ Default: `[basic.scriptMainStanza]`
124138
125139
#### <a name="moduleOutputHandlers"></a>moduleOutputHandlers
126140
127-
These generators yield (possibly modified) source strings for a module.
141+
These generators yield (possibly modified) source strings for a module. The
142+
default handler uses values defined elsewhere in the config, e.g.,
143+
`moduleOutputSubs`.
128144
129145
Default: `[basic.outputSubs]`
130146
@@ -198,8 +214,8 @@ Default: `[basic.simpleDocString]`
198214
199215
#### <a name="enumValueHandler"></a>enumValueHandler
200216
201-
This handler is responsible for creating enum values on enum classes after
202-
they've been defined.
217+
This handler is responsible for creating enum values on classes after they've
218+
been defined.
203219
204220
Default: `basic.enumConstStrings`
205221
@@ -208,7 +224,7 @@ Default: `basic.enumConstStrings`
208224
209225
This handler is responsible for constructing method parameters.
210226
211-
Default: `basic.defaultParams`
227+
Default: `[basic.defaultParams]`
212228
213229
214230
#### <a name="methodLockFunctionName"></a>methodLockFunctionName
@@ -231,12 +247,13 @@ Default: `[basic.simpleDocString]`
231247
These generators yield values for the module prologue.
232248
233249
Default:
234-
```[basic.maybeAbstractMethod,
235-
basic.maybeClassMethod,
236-
basic.maybeSynchronizedMethod,
237-
basic.overloadedClassMethods,
250+
251+
```[basic.maybeAbstractMethod,
252+
basic.maybeClassMethod,
253+
basic.maybeSynchronizedMethod,
254+
basic.overloadedClassMethods,
238255
]
239-
```
256+
```
240257

241258
#### <a name="astTransforms"></a>astTransforms
242259

@@ -252,5 +269,7 @@ mapping is used to convert them when found. Note that this mapping is now
252269
unnecessary and will be folded into the `astTransforms` sequence in future
253270
releases.
254271

255-
[usage]: https://github.com/natural/java2python/tree/master/doc/usage.md
256272
[1]: https://github.com/natural/java2python/blob/master/java2python/config/default.py
273+
[2]: https://github.com/natural/java2python/blob/master/java2python/mod/basic.py
274+
[PEP 8]: http://www.python.org/dev/peps/pep-0008/
275+
[usage]: https://github.com/natural/java2python/tree/master/doc/usage.md

0 commit comments

Comments
 (0)