You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fprettify is an auto-formatter for modern Fortran code that imposes strict whitespace formatting, written in Python.
9
+
fprettify is an auto-formatter for modern Fortran code that imposes strict
10
+
whitespace formatting, written in Python.
10
11
11
12
**NOTE:** I'm looking for help to maintain this repository, see [#127](https://github.com/pseewald/fprettify/issues/127).
12
13
13
14
## Features
14
15
15
16
- Auto-indentation.
16
-
- Line continuations are aligned with the previous opening delimiter `(`, `[` or `(/` or with an assignment operator `=` or `=>`. If none of the above is present, a default hanging indent is applied.
17
+
- Line continuations are aligned with the previous opening delimiter `(`, `[` or
18
+
`(/` or with an assignment operator `=` or `=>`. If none of the above is
19
+
present, a default hanging indent is applied.
17
20
- Consistent amount of whitespace around operators and delimiters.
18
21
- Removal of extraneous whitespace and consecutive blank lines.
19
22
- Change letter case (upper case / lower case conventions) of intrinsics
20
23
- Tested for editor integration.
21
-
- By default, fprettify causes whitespace changes only and thus preserves revision history.
22
-
- fprettify can handle cpp and [fypp](https://github.com/aradi/fypp) preprocessor directives.
24
+
- By default, fprettify causes whitespace changes only and thus preserves
25
+
revision history.
26
+
- fprettify can handle cpp and [fypp](https://github.com/aradi/fypp)
27
+
preprocessor directives.
23
28
24
29
## Limitations
25
30
@@ -29,11 +34,14 @@ fprettify is an auto-formatter for modern Fortran code that imposes strict white
29
34
## Requirements
30
35
31
36
- Python 3 (Python 2.7 no longer supported)
32
-
-[ConfigArgParse](https://pypi.org/project/ConfigArgParse): optional, enables use of config file
Compare `examples/*before.f90` (original Fortran files) with `examples/*after.f90` (reformatted Fortran files) to see what fprettify does. A quick demonstration:
42
+
Compare `examples/*before.f90` (original Fortran files) with
43
+
`examples/*after.f90` (reformatted Fortran files) to see what fprettify does. A
44
+
quick demonstration:
37
45
38
46
```Fortran
39
47
program demo
@@ -93,9 +101,11 @@ Autoformat file1, file2, ... inplace by
93
101
fprettify file1, file2, ...
94
102
```
95
103
96
-
The default indent is 3. If you prefer something else, use `--indent n` argument.
104
+
The default indent is 3. If you prefer something else, use `--indent n`
105
+
argument.
97
106
98
-
In order to apply fprettify recursively to an entire Fortran project instead of a single file, use the `-r` option.
107
+
In order to apply fprettify recursively to an entire Fortran project instead of
108
+
a single file, use the `-r` option.
99
109
100
110
For more options, read
101
111
@@ -111,15 +121,23 @@ For editor integration, use
111
121
fprettify --silent
112
122
```
113
123
114
-
For instance, with Vim, use fprettify with `gq` by putting the following commands in your `.vimrc`:
124
+
For instance, with Vim, use fprettify with `gq` by putting the following
## Deactivation and manual formatting (experimental feature)
121
132
122
-
fprettify can be deactivated for selected lines: a single line followed by an inline comment starting with `!&` is not auto-formatted and consecutive lines that are enclosed between two comment lines `!&<` and `!&>` are not auto-formatted. This is useful for cases where manual alignment is preferred over auto-formatting. Furthermore, deactivation is necessary when non-standard Fortran syntax (such as advanced usage of preprocessor directives) prevents proper formatting. As an example, consider the following snippet of fprettify formatted code:
133
+
fprettify can be deactivated for selected lines: a single line followed by an
134
+
inline comment starting with `!&` is not auto-formatted and consecutive lines
135
+
that are enclosed between two comment lines `!&<` and `!&>` are not
136
+
auto-formatted. This is useful for cases where manual alignment is preferred
137
+
over auto-formatting. Furthermore, deactivation is necessary when non-standard
138
+
Fortran syntax (such as advanced usage of preprocessor directives) prevents
139
+
proper formatting. As an example, consider the following snippet of fprettify
140
+
formatted code:
123
141
124
142
```fortran
125
143
A = [-1, 10, 0, &
@@ -147,4 +165,8 @@ A = [-1, 10, 0, &
147
165
148
166
## Contributing / Testing
149
167
150
-
The testing mechanism allows you to easily test fprettify with any Fortran project of your choice. Simply clone or copy your entire project into `fortran_tests/before` and run `python setup.py test`. The directory `fortran_tests/after` contains the test output (reformatted Fortran files). If testing fails, please submit an issue!
168
+
The testing mechanism allows you to easily test fprettify with any Fortran
169
+
project of your choice. Simply clone or copy your entire project into
170
+
`fortran_tests/before` and run `python setup.py test`. The directory
171
+
`fortran_tests/after` contains the test output (reformatted Fortran files). If
0 commit comments