Skip to main content

dfmt: format paragraphs, comments and doc strings

https://img.shields.io/pypi/v/dfmt.svg

Overview

dfmt is a Python command line tool that can reformat text, allowing you to go from:

this is a pretty big sentence with lots of words that takes a lot of horizontal space

to:

this is a pretty big sentence with lots
of words that takes a lot of horizontal
space

It can also be used to format paragraphs in comments and doc strings.

Input:

/**
 * This is a very long line in a Doxygen comment that takes a lot of space
 */

Output:

/**
 * This is a very long line in a
 * Doxygen comment that takes a lot of
 * space
 */

Installation

The recommended way is to use pipx to install dfmt. You can also use pip directly if you know what you are doing.

Usage

Send the text to stdin, and dfmt will write the results to stdout.

By default, text is wrapped at 80 characters. You can use the -w,–width option to set a different size.

As such, dfmt can be used in a number of text editors.

How it works

dfmt contains an hard-coded list of known prefixes.

It will start by splitting the input in “regions” that start with the same prefix.

Then it will use the textwrap module from the Python standard library to wrap each region while keeping the existing prefix.

Metadata

Release files for dfmt 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dfmt 1.2.0
File Size Uploaded
dfmt-1.2.0.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dfmt 1.2.0
File Interpreter ABI Platform
dfmt-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 kB

Release files / dfmt-1.2.0.tar.gz

Download URL dfmt-1.2.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7af6360ca8d556f1cfe82b97f03b8d1ea5a9d6de1fa3018290c844b6566d9d6e
BLAKE2b-256 checksum
How to use checksums
37e8c5e57fe74e89ea5f3073d3cd024609c4ab96f86daf4305d8fa9322684d40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.7.1 Linux/5.7.0-1-amd64

Release files / dfmt-1.2.0-py3-none-any.whl

Download URL dfmt-1.2.0-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac88fe977cfc2fb6c77e2532cc257fc0d32847724fc73090d9e1a8ce2cec07de
BLAKE2b-256 checksum
How to use checksums
082317005458854e3b6dfaf4c7555384eb850ec8980c0838aea93f12d1370799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.7.1 Linux/5.7.0-1-amd64

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page