fortran-lang / fprettify

auto-formatter for modern fortran source code
https://pypi.python.org/pypi/fprettify
Other
370 stars 76 forks source link

whitespace around decleration not working as intendet #107

Closed JHenneberg closed 3 years ago

JHenneberg commented 3 years ago

Hello.

I discovered following scenario:

fprettify -i 2 --enable-decl true

before:

program demo
  integer::endif, if, elseif
end program

expected result:

program demo
  integer :: endif, if, elseif
end program

I would expect spaces around ::.

but what I am actually getting is an empty document.

I think changing --enable-decl true to --whitespace-decleration true would be benefical because of more consistency in the nameing sheme.

Edit: Ok i realized it is already implemented and that I need to change my command to: -i 2 --whitespace-decl true --enable-decl

nbehrnd commented 3 years ago

With release 0.3.7, an instruction in line of

fprettify probe.f95 --enable-decl

will yield the intended space prior and after the :: operator. By default, this parameter is set to F. (Because this option possibly is influenced by a feature request of mine in the fall of 2020, I recognized the toggle right away.) Note, release 0.3.7 of fprettify is the first to drop the support for (legacy) Python 2.

A separate note, though. The implicit none statement might not be necessary for a MWE to document the formatting problem here (but is very useful for a real Fortran program). Yet, I highly recommend to preserve the words of if, endif (or its equivalent end if), elseif (or equivalent else if) to the construction of the loops and not to use as a variable.

JHenneberg commented 3 years ago

Thanks for the note. I am aware of those, I just took this example from the README.md in this repository.