Metadata-Version: 2.5
Name: rainbow-fmt
Version: 0.1.0
Summary: A highly configurable, pluggable code formatter: every formatting decision is an option.
Project-URL: Repository, https://gitlab.com/thebjorn/rainbow-fmt
Project-URL: Documentation, https://gitlab.com/thebjorn/rainbow-fmt/-/tree/main/docs
Project-URL: Changelog, https://gitlab.com/thebjorn/rainbow-fmt/-/blob/main/CHANGELOG.md
Author: Bjørn Pettersen
License-Expression: MIT
License-File: LICENSE
Keywords: code-style,formatter,pretty-printer,tree-sitter
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: ruamel-yaml>=0.18
Requires-Dist: tomlkit>=0.13
Requires-Dist: tree-sitter-json>=0.24
Requires-Dist: tree-sitter<0.26,>=0.25
Provides-Extra: dev
Requires-Dist: mypy>=1.13; extra == 'dev'
Requires-Dist: pytest-cov>=6.0; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

<p align="center"><img src="https://gitlab.com/thebjorn/rainbow-fmt/-/raw/main/docs/assets/logo.svg" alt="rainbow-fmt logo" width="128"></p>

# rainbow-fmt

> Every shade of style. A code formatter that formats code *your* way.

`rainbow-fmt` is a highly configurable, pluggable code formatter for HTML,
CSS, SCSS, JavaScript, TypeScript, Svelte, Python, and any other language or
DSL someone cares to describe.

It is deliberately the *anti*-Prettier / anti-Black. Those tools end style
debates by removing choice. `rainbow-fmt` ends them by letting a team write
its decisions down once — and then enforcing them consistently, for every
language in the repository.

## Status

Alpha (0.1.0). JSON and JSONC can be formatted from the command line; other
languages are planned ([`docs/roadmap.md`](docs/roadmap.md)). See
[`STATUS.md`](STATUS.md) and [`CHANGELOG.md`](CHANGELOG.md).

## Quick start

```sh
pip install rainbow-fmt            # Python 3.12 or newer

rainbow-fmt format src/            # rewrite files in place
rainbow-fmt check .                # exit 1 if any file would change
rainbow-fmt diff config.json       # show the changes
rainbow-fmt options config.json    # the options for a file, and where each comes from
```

Every formatted file is verified before it is written: the syntax tree and
the comments must be unchanged, and formatting the result again must change
nothing ([`docs/cli.md`](docs/cli.md#verification)).

Write your decisions down in `rainbow.toml` (or `pyproject.toml`
`[tool.rainbow]`, YAML, or `package.json`), in the project root:

```toml
preset = "rainbow:balanced"        # start from a preset (optional)

[core]
max_width = 100
indent_size = 2

[language.json]
object_wrap = "always"             # "preserve" | "fit" | "always"
align_values = true

[[override]]
files = ["legacy/**"]
core.indent_size = 4
```

`.editorconfig` is read too. All options and the resolution order are in
[`docs/configuration.md`](docs/configuration.md).

## Documentation

| Document | Contents |
| --- | --- |
| [`docs/overview.md`](docs/overview.md) | Vision, principles, non-goals, comparison with existing tools |
| [`docs/architecture.md`](docs/architecture.md) | The major pieces and how they fit together |
| [`docs/cli.md`](docs/cli.md) | The `format`, `check`, `diff` and `options` commands |
| [`docs/configuration.md`](docs/configuration.md) | Configuration model: options, cascading, presets, `preserve` |
| [`docs/extending.md`](docs/extending.md) | How new languages and DSLs are added |
| [`docs/doc-ir.md`](docs/doc-ir.md) | Reference for the Doc IR builders and the printer |
| [`docs/benchmark.md`](docs/benchmark.md) | `python -m rainbow_fmt.benchmark` and the CI baseline |
| [`docs/releasing.md`](docs/releasing.md) | Publishing a release to PyPI |
| [`docs/roadmap.md`](docs/roadmap.md) | High-level, phased plan and open decisions |
| [`docs/adr/`](docs/adr/README.md) | Architecture Decision Records |

## Development

Requires Python 3.12 or newer.

```sh
python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install -e '.[dev]'

pytest                             # tests + coverage report
ruff check . && ruff format --check .
mypy                               # strict; configured in pyproject.toml
```

The same checks, plus a package build and a benchmark
(`python -m rainbow_fmt.benchmark`, [`docs/benchmark.md`](docs/benchmark.md)),
run in GitLab CI on every push and merge request (`.gitlab-ci.yml`).
Pushing a tag `vX.Y.Z` that matches `__version__` publishes the package to
PyPI ([`docs/releasing.md`](docs/releasing.md)).

New features are developed tests-first: the tests describing the intended
API are written and reviewed before the implementation. Architectural
decisions are recorded in [`docs/adr/`](docs/adr/README.md).

## License

MIT — see [`LICENSE`](LICENSE).

## Project tracking

[`TODO.md`](TODO.md) (high-level tasks),
[`TASKS.md`](TASKS.md) (detailed next tasks), [`STATUS.md`](STATUS.md)
(current state).
