Skip to content

Commit d6d24a8

Browse files
authored
Merge pull request #131 from pseewald/feat/shields
docs: update shields and README format
2 parents f5061b5 + ec9dded commit d6d24a8

File tree

1 file changed

+39
-32
lines changed

1 file changed

+39
-32
lines changed

README.md

+39-32
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
# fprettify
22

3-
[![Build Status](https://travis-ci.com/pseewald/fprettify.svg?branch=master)](https://travis-ci.com/pseewald/fprettify) [![Coverage Status](https://coveralls.io/repos/github/pseewald/fprettify/badge.svg?branch=master)](https://coveralls.io/github/pseewald/fprettify?branch=master) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) [![PyPI version](https://badge.fury.io/py/fprettify.svg)](https://badge.fury.io/py/fprettify)
3+
[![CI](https://github.com/pseewald/fprettify/actions/workflows/test.yml/badge.svg)](https://github.com/pseewald/fprettify/actions/workflows/test.yml)
4+
[![Coverage Status](https://coveralls.io/repos/github/pseewald/fprettify/badge.svg?branch=master)](https://coveralls.io/github/pseewald/fprettify?branch=master)
5+
![PyPI - License](https://img.shields.io/pypi/l/fprettify)
6+
![PyPI](https://img.shields.io/pypi/v/fprettify)
7+
[![Code Climate](https://codeclimate.com/github/pseewald/fprettify/badges/gpa.svg)](https://codeclimate.com/github/pseewald/fprettify)
48

59
fprettify is an auto-formatter for modern Fortran code that imposes strict whitespace formatting, written in Python.
610

711
**NOTE:** I'm looking for help to maintain this repository, see [#127](https://github.com/pseewald/fprettify/issues/127).
812

9-
1013
## Features
1114

12-
* Auto-indentation.
13-
* 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.
14-
* Consistent amount of whitespace around operators and delimiters.
15-
* Removal of extraneous whitespace and consecutive blank lines.
16-
* Change letter case (upper case / lower case conventions) of intrinsics
17-
* Tested for editor integration.
18-
* By default, fprettify causes whitespace changes only and thus preserves revision history.
19-
* fprettify can handle cpp and [fypp](https://github.com/aradi/fypp) preprocessor directives.
20-
15+
- 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+
- Consistent amount of whitespace around operators and delimiters.
18+
- Removal of extraneous whitespace and consecutive blank lines.
19+
- Change letter case (upper case / lower case conventions) of intrinsics
20+
- 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.
2123

2224
## Limitations
2325

24-
* Works only for modern Fortran (Fortran 90 upwards).
25-
* Feature missing? Please create an issue.
26-
26+
- Works only for modern Fortran (Fortran 90 upwards).
27+
- Feature missing? Please create an issue.
2728

2829
## Requirements
2930

30-
* Python 3 (Python 2.7 no longer supported)
31-
* [ConfigArgParse](https://pypi.org/project/ConfigArgParse): optional, enables use of config file
32-
31+
- Python 3 (Python 2.7 no longer supported)
32+
- [ConfigArgParse](https://pypi.org/project/ConfigArgParse): optional, enables use of config file
3333

3434
## Examples
3535

3636
Compare `examples/*before.f90` (original Fortran files) with `examples/*after.f90` (reformatted Fortran files) to see what fprettify does. A quick demonstration:
3737

38-
``` Fortran
38+
```Fortran
3939
program demo
4040
integer :: endif,if,elseif
4141
integer,DIMENSION(2) :: function
@@ -50,8 +50,10 @@ print*,endif
5050
endif
5151
end program
5252
```
53+
5354
⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩ `fprettify` ⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩
54-
``` Fortran
55+
56+
```Fortran
5557
program demo
5658
integer :: endif, if, elseif
5759
integer, DIMENSION(2) :: function
@@ -67,65 +69,74 @@ program demo
6769
end program
6870
```
6971

70-
7172
## Installation
7273

7374
The latest release can be installed using pip:
74-
```
75+
76+
```sh
7577
pip install --upgrade fprettify
7678
```
7779

7880
Installation from source requires Python Setuptools:
79-
```
81+
82+
```sh
8083
./setup.py install
8184
```
8285

8386
For local installation, use `--user` option.
8487

85-
8688
## Command line tool
8789

8890
Autoformat file1, file2, ... inplace by
89-
```
91+
92+
```sh
9093
fprettify file1, file2, ...
9194
```
95+
9296
The default indent is 3. If you prefer something else, use `--indent n` argument.
9397

9498
In order to apply fprettify recursively to an entire Fortran project instead of a single file, use the `-r` option.
9599

96100
For more options, read
97-
```
101+
102+
```sh
98103
fprettify -h
99104
```
100105

101-
102106
## Editor integration
103107

104108
For editor integration, use
105-
```
109+
110+
```sh
106111
fprettify --silent
107112
```
113+
108114
For instance, with Vim, use fprettify with `gq` by putting the following commands in your `.vimrc`:
115+
109116
```vim
110117
autocmd Filetype fortran setlocal formatprg=fprettify\ --silent
111118
```
112119

113-
114120
## Deactivation and manual formatting (experimental feature)
115121

116122
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:
123+
117124
```fortran
118125
A = [-1, 10, 0, &
119126
0, 1000, 0, &
120127
0, -1, 1]
121128
```
129+
122130
In order to manually align the columns, fprettify needs to be deactivated by
131+
123132
```fortran
124133
A = [-1, 10, 0, & !&
125134
0, 1000, 0, & !&
126135
0, -1, 1] !&
127136
```
137+
128138
or, equivalently by
139+
129140
```fortran
130141
!&<
131142
A = [-1, 10, 0, &
@@ -134,10 +145,6 @@ A = [-1, 10, 0, &
134145
!&>
135146
```
136147

137-
138148
## Contributing / Testing
139149

140150
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!
141-
142-
143-
[![Code Climate](https://codeclimate.com/github/pseewald/fprettify/badges/gpa.svg)](https://codeclimate.com/github/pseewald/fprettify)

0 commit comments

Comments
 (0)