Metadata-Version: 2.4
Name: sable-fortran
Version: 0.2.0
Summary: An uncompromising Fortran formatter, inspired by Black
License: MIT
License-File: LICENSE
Keywords: formatter,fortran,linter
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Requires-Dist: click>=8.0
Requires-Dist: tomli>=2.0; python_version < '3.11'
Provides-Extra: dev
Requires-Dist: black>=24.0; extra == 'dev'
Requires-Dist: pre-commit>=3.7; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/eirik-kjonstad/sable/v0.1.3/assets/sable-logo.svg" alt="Sable logo" width="420">
</p>

An uncompromising Fortran formatter, inspired by [Black](https://github.com/psf/black).

> "So it goes."
> — Kurt Vonnegut, *Slaughterhouse-Five*

Sable enforces one consistent style for modern free-form Fortran, so you can
focus on code instead of formatting. It also supports code checks beyond formatting
to identify code issues.

## Installation

```bash
pip install sable-fortran
```

## Quick Start

```bash
# Format in place (default command)
sable src/

# Equivalent explicit form
sable format src/

# Check formatting only (no writes)
sable format --check src/

# Preview formatting diff
sable format --diff src/

# Safer migration pass (layout-focused)
sable format --safe src/
```

Recommended CI formatting gate:

```bash
sable format --check src/
```

## Formatting 

`format` rewrites source into Sable's canonical style. This includes:

- Relational operator normalization (`.EQ.` -> `==`, etc.)
- END keyword normalization (`endif` -> `end if`, configurable)
- Declaration normalization (`integer x` -> `integer :: x`)
- Deterministic spacing, indentation, wrapping, and trailing newline handling

Example:

```fortran
! Before
IF(A .EQ. B)THEN
CALL compute(alpha,beta,gamma)
ENDIF

! After
if (A == B) then
   call compute( &
           alpha, &
           beta, &
           gamma &
        )
end if
```

## Checking

`check` reports rule diagnostics and can apply rule fixes.

```bash
# Run all rules (style + lint)
sable check src/

# Focus on policy/lint only
sable check --rule-set lint src/

# Formatter-adjacent style rules only
sable check --rule-set style src/

# Apply safe fixes, then re-check
sable check --fix src/

# Allow unsafe fixes too
sable check --fix --unsafe-fixes src/
```

Rule-set notes:

- `--rule-set all` (default): style + lint
- `--select` takes precedence over `--rule-set`
- `--fix` applies safe fixes
- `--unsafe-fixes` enables unsafe fixes (only with `--fix`)

Current lint rules:

- `SBL101`: Program/module is missing `implicit none`
- `SBL102`: Procedure is missing `implicit none`
- `SBL103`: Dummy argument is missing `intent(in|out|inout)`

## Suppressions

Inline:

```fortran
if (a .eq. b) then ! sable: ignore SBL001
end if
```

File-wide:

```fortran
! sable: ignore-file SBL001,SBL004
```

## Configuration

Example `pyproject.toml`:

```toml
[tool.sable.check]
rule_set = "all"  # style | lint | all
select = []
ignore = []
output_format = "text"   # text | json | sarif | gitlab-codequality
baseline = ".sable-baseline.json"
fix = false
unsafe_fixes = false
generate_baseline = false
```

CLI flags override `pyproject.toml` defaults.

## License

MIT
