5 nitpretty - pretty print Nit code from Nit source files.
9 nitpretty [*options*]... FILE
14 : Working directory (default is '.nitpretty')
17 : Output name (default is pretty.nit)
20 : Show diff between source and output
23 : Show diff between source and output using meld
26 : Check format of Nit source files
30 The specification of the pretty printing is described here.
32 * Default indentation level is one `'\t'` character and is increased by one for
33 each indentation level.
34 * Default line max-size is 80.
38 There is many categories of comments:
40 `Licence comments` are attached to the top of the file no blank line before,
44 # This is a licence comment
46 # Documentation for module `foo`
50 `ADoc` are documentation comments attached to a `AModule`, `AClassdef`, `APropdef`.
52 They are printed before the definition with a blank line before and no after
53 at the same indentation level than the definition.
56 # Documentation for module `foo`
59 # Documentation for class `Bar`
61 # Documentation for method `baz`
66 `Block comments` are comments composed of one or more line rattached to nothing.
67 They are displayed with one blank line before and after at current indent level.
76 `Attached comments` are comments attached to a production.
77 They are printed as this.
80 fun foo do # attached comment
84 `nitpretty` automatically remove multiple blanks between comments:
95 Productions are automatically inlined when possible.
99 * The production must be syntactically inlinable
100 * The inlined production length is less than `PrettyPrinterVisitor::max-size`
101 * The production do not contains any comments
105 * There is a blank between the module declaration and its imports
106 * There is no blank between imports and only one after
107 * There is a blank between each extern block definition
108 * There is a blank between each class definition
109 * There is no blank line at the end of the module
112 # Documentation for module `foo`
119 # Documentation for class `Bar`
122 class Baz end # not a `ADoc` comment
127 * There is no blank between the class definition and its super-classes declarations
128 * There is no blank between two inlined property definition
129 * There is a blank between each block definition
130 * There no blank line at the end of the class definition
133 # Documentation for class `Bar`
148 Generic types have no space after or before brackets and are separated by a comma and a space:
151 class A[E: Type1, F: Type1] end
156 * Inlined productions have no blank lines between them
157 * Block productions have a blank before and after
171 ### CALLS AND BINARY OPS
173 Arguments are always printed separated with a comma and a space:
179 Binary ops are always printed wrapped with spaces:
185 Calls and binary ops can be splitted to fit the `max-size` constraint.
186 Breaking priority is given to arguments declaration after the comma.
189 return foo("aaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbb",
190 "cccccccccccccccccccccccccc")
193 Binary ops can also be broken to fit the `max-size` limit:
196 return "aaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbb" +
197 "cccccccccccccccccccccccccc"
202 The Nit language documentation and the source code of its tools and libraries may be downloaded from <http://nitlanguage.org>