All Projects → pseewald → Fprettify

pseewald / Fprettify

Licence: other
auto-formatter for modern fortran source code

Programming Languages

python
139335 projects - #7 most used programming language
fortran
972 projects

Projects that are alternatives of or similar to Fprettify

Appsmith
Low code project to build admin panels, internal tools, and dashboards. Integrates with 15+ databases and any API.
Stars: ✭ 12,079 (+6158.55%)
Mutual labels:  developer-tools
Garden
Automation for Kubernetes development and testing. Spin up production-like environments for development, testing, and CI on demand. Use the same configuration and workflows at every step of the process. Speed up your builds and test runs via shared result caching.
Stars: ✭ 2,289 (+1086.01%)
Mutual labels:  developer-tools
Phantomas
Headless Chromium-based web performance metrics collector and monitoring tool
Stars: ✭ 2,191 (+1035.23%)
Mutual labels:  developer-tools
Waypoint
📍 VSCode extension for navigating JS codebases
Stars: ✭ 174 (-9.84%)
Mutual labels:  developer-tools
Powerline Go
A beautiful and useful low-latency prompt for your shell, written in go
Stars: ✭ 2,299 (+1091.19%)
Mutual labels:  developer-tools
Txeh
Go library and CLI utilty for /etc/hosts management.
Stars: ✭ 181 (-6.22%)
Mutual labels:  developer-tools
Wp Capsule
The developer's code journal (built on WordPress)
Stars: ✭ 172 (-10.88%)
Mutual labels:  developer-tools
Boostnote.next
Boost Note is a powerful, lightspeed collaborative workspace for developer teams. Forum (New!): https://github.com/BoostIO/BoostNote-App/discussions
Stars: ✭ 2,682 (+1289.64%)
Mutual labels:  developer-tools
Interrupt
A community for embedded software makers.
Stars: ✭ 178 (-7.77%)
Mutual labels:  developer-tools
Jstoolnpp
A JavaScript (JSON) tool for Notepad++ (formerly JSMinNpp) and Visual Studio Code.
Stars: ✭ 186 (-3.63%)
Mutual labels:  developer-tools
Anteater
Anteater - CI/CD Gate Check Framework
Stars: ✭ 174 (-9.84%)
Mutual labels:  developer-tools
Giraffql
Interactive GraphQL exploration tool built with React - still working on the website
Stars: ✭ 176 (-8.81%)
Mutual labels:  developer-tools
Nake
Magic script-based C# task runner for .NET Core
Stars: ✭ 183 (-5.18%)
Mutual labels:  developer-tools
Dnote
A simple command line notebook for programmers
Stars: ✭ 2,192 (+1035.75%)
Mutual labels:  developer-tools
Lighthouse Security
Runs the default Google Lighthouse tests with additional security tests
Stars: ✭ 190 (-1.55%)
Mutual labels:  developer-tools
Vscode Live Frame
Run your web app inside VS Code
Stars: ✭ 173 (-10.36%)
Mutual labels:  developer-tools
Gbt Player
A music player library for Game Boy.
Stars: ✭ 180 (-6.74%)
Mutual labels:  developer-tools
Windowsdevtools
Windows UI development tools.
Stars: ✭ 194 (+0.52%)
Mutual labels:  developer-tools
Watchexec
Executes commands in response to file modifications
Stars: ✭ 2,651 (+1273.58%)
Mutual labels:  developer-tools
Hue Debugger Ui
💡 Graphical interface for observing and interacting directly with Hue API
Stars: ✭ 186 (-3.63%)
Mutual labels:  developer-tools

fprettify

Build Status Coverage Status License: GPL v3 PyPI version

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

Features

  • Auto-indentation.
  • 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.
  • Consistent amount of whitespace around operators and delimiters.
  • Removal of extraneous whitespace and consecutive blank lines.
  • Change letter case (upper case / lower case conventions) of intrinsics
  • Tested for editor integration.
  • By default, fprettify causes whitespace changes only and thus preserves revision history.
  • fprettify can handle cpp and fypp preprocessor directives.

Limitations

  • Works only for modern Fortran (Fortran 90 upwards).
  • Feature missing? Please create an issue.

Requirements

  • Python 3 (Python 2.7 no longer supported)
  • ConfigArgParse: optional, enables use of config file

Examples

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

program demo
integer :: endif,if,elseif
integer,DIMENSION(2) :: function
endif=3;if=2
if(endif==2)then
endif=5
elseif=if+4*(endif+&
2**10)
elseif(endif==3)then
function(if)=endif/elseif
print*,endif
endif
end program

⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩ fprettify ⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩

program demo
   integer :: endif, if, elseif
   integer, DIMENSION(2) :: function
   endif = 3; if = 2
   if (endif == 2) then
      endif = 5
      elseif = if + 4*(endif + &
                       2**10)
   elseif (endif == 3) then
      function(if) = endif/elseif
      print *, endif
   endif
end program

Installation

The latest release can be installed using pip:

pip install --upgrade fprettify

Installation from source requires Python Setuptools:

./setup.py install

For local installation, use --user option.

Command line tool

Autoformat file1, file2, ... inplace by

fprettify file1, file2, ...

The default indent is 3. If you prefer something else, use --indent n argument.

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

For more options, read

fprettify -h

Editor integration

For editor integration, use

fprettify --silent

For instance, with Vim, use fprettify with gq by putting the following commands in your .vimrc:

autocmd Filetype fortran setlocal formatprg=fprettify\ --silent

Deactivation and manual formatting (experimental feature)

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:

A = [-1, 10, 0, &
     0, 1000, 0, &
     0, -1, 1]

In order to manually align the columns, fprettify needs to be deactivated by

A = [-1,   10, 0, & !&
      0, 1000, 0, & !&
      0,   -1, 1]   !&

or, equivalently by

!&<
A = [-1,   10, 0, &
      0, 1000, 0, &
      0,   -1, 1]
!&>

Contributing / Testing

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!

Code Climate

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].