A library for building code formatters
Project description
Format Blocks
Format Blocks is a Python library for building code formatters.
Usage
Format Blocks provides a number of 'block' objects which know how to arrange text in various ways,
such as LineBlock
which arranges elements on one line, and StackBlock
which stacks them across
lines, and WrapBlock
which wraps inserts line breaks at the margin.
However, the most import block is ChoiceBlock
. ChoiceBlock accepts multiple formatting options,
and allows for the solver to pick the choices which minimize the overall formatting cost.
See the tests for some examples!
Origins
Format Blocks is a fork of the guts of Google's R Formatter, rfmt. Rfmt was structured as a formatting library with an R implementation, almost entirely decoupled. To create Format Blocks, I just did some final decoupling, then polished up the code and wrote some extra features and tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for format_blocks-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c226e160b2189c4789340737d9adb494a9869e4b18b7e21b20a6353e56da85 |
|
MD5 | bff379f16c70dcee7abda4967fb11f9a |
|
BLAKE2b-256 | 78d5ddeae1cc145a30b3e8aa6a15f69bb306cbc34910d375087258386456a6cf |