Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

format-blocks-0.1.2.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

format_blocks-0.1.2-py3-none-any.whl (20.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page