| 1 |
## Project Overview |
| 2 |
|
| 3 |
This project is a Rust library named `textwrap` for wrapping and indenting text. |
| 4 |
It is designed to be used in command-line programs to format dynamic output. The |
| 5 |
library provides functions for wrapping text to a given width, filling text |
| 6 |
(wrapping and joining with newlines), indenting, and dedenting. |
| 7 |
|
| 8 |
The library is highly configurable and supports: |
| 9 |
|
| 10 |
- **Optimal-fit algorithm:** for finding the best line breaks. |
| 11 |
- **Hyphenation:** for about 70 languages. |
| 12 |
- **Unicode support:** for handling non-ASCII characters correctly. |
| 13 |
- **Terminal width detection:** for automatically adjusting the output to the |
| 14 |
terminal size. |
| 15 |
|
| 16 |
The library is modular, and features can be enabled or disabled via Cargo |
| 17 |
features to keep the binary size small. |
| 18 |
|
| 19 |
## Building and Running |
| 20 |
|
| 21 |
The project is a standard Rust library. It can be built and tested using |
| 22 |
`cargo`. |
| 23 |
|
| 24 |
### Building |
| 25 |
|
| 26 |
To build the library, run: |
| 27 |
|
| 28 |
```sh |
| 29 |
cargo build |
| 30 |
``` |
| 31 |
|
| 32 |
To build the library with all features, run: |
| 33 |
|
| 34 |
```sh |
| 35 |
cargo build --all-features |
| 36 |
``` |
| 37 |
|
| 38 |
### Running Examples |
| 39 |
|
| 40 |
The project includes a number of examples in the `examples` directory. To run an |
| 41 |
example, use the `cargo run --example` command. For example, to run the |
| 42 |
`interactive` example, which demonstrates most of the available features, run: |
| 43 |
|
| 44 |
```sh |
| 45 |
cargo run --example interactive |
| 46 |
``` |
| 47 |
|
| 48 |
### Running Tests |
| 49 |
|
| 50 |
To run the tests, run: |
| 51 |
|
| 52 |
```sh |
| 53 |
cargo test |
| 54 |
``` |
| 55 |
|
| 56 |
To run the tests with all features, run: |
| 57 |
|
| 58 |
```sh |
| 59 |
cargo test --all-features |
| 60 |
``` |
| 61 |
|
| 62 |
## Development Conventions |
| 63 |
|
| 64 |
The project follows standard Rust conventions. |
| 65 |
|
| 66 |
- **Formatting:** The code is formatted with `dprint fmt`. This will format all |
| 67 |
project files. |
| 68 |
- **Linting:** The project uses `clippy` for linting. |
| 69 |
- **Continuous Integration:** The project uses GitHub Actions for continuous |
| 70 |
integration. The configuration is in the `.github/workflows` directory. |
| 71 |
- **Dependencies:** The project uses `dependabot` to keep dependencies up to |
| 72 |
date. The configuration is in the `.github/dependabot.yml` file. |
| 73 |
- **Documentation:** The project has extensive documentation, which can be |
| 74 |
generated with `cargo doc`. The documentation is also available on |
| 75 |
[docs.rs](https://docs.rs/textwrap/). Do not use semicolons (`;`) in prose or |
| 76 |
docstrings. Split into separate sentences instead. |
| 77 |
- **Branch Naming:** Name git branches using kebab-case (`foo-bar-baz`), never |
| 78 |
snake_case or camelCase. |
| 79 |
- **Commit and PR Hygiene:** Every PR must focus on a single concern. When |
| 80 |
addressing review feedback or bugs on an unmerged branch, amend the original |
| 81 |
commit instead of adding new commits. Write descriptive commit messages and |
| 82 |
use `gh pr create --fill` so the PR title and description match the commit. |