Skip to content

Commit 65277f5

Browse files
authored
Merge pull request #373 from mgeisler/release-0.14.0
Release 0.14.0
2 parents 85d2c1c + 1be7943 commit 65277f5

File tree

6 files changed

+121
-32
lines changed

6 files changed

+121
-32
lines changed

.github/workflows/prepare-release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,14 @@ jobs:
105105
106106
let q = [`repo:${context.repo.owner}/${context.repo.repo}`,
107107
'is:pr', 'is:merged', `merged:>${cutoff}`]
108-
// Need to use https://octokit.github.io/rest.js/v18#pagination!
109-
const prs = await github.search.issuesAndPullRequests({
108+
const prs = await github.paginate(github.search.issuesAndPullRequests, {
110109
q: q.join(' '),
111110
sort: 'created',
112111
order: 'asc',
113112
})
114-
core.info(`Found ${prs.data.items.length} merged PRs`)
113+
core.info(`Found ${prs.length} merged PRs`)
115114
116-
const changelog = prs.data.items.map(
115+
const changelog = prs.map(
117116
pr => `* [#${pr.number}](${pr.html_url}): ${pr.title}`
118117
).join('\n')
119118
core.exportVariable('CHANGELOG', changelog)

CHANGELOG.md

Lines changed: 93 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,110 @@
33
This file lists the most important changes made in each release of
44
`textwrap`.
55

6-
## Unreleased
6+
## Version 0.14.0 (2021-06-05)
77

8-
This is a major feature release which adds new generic type parameters
9-
to the `Options` struct. These parameters lets you statically
10-
configure the wrapping algorithm and the word separator:
11-
12-
* `wrap_algorithms::WrapAlgorithm`: this trait replaces the old
13-
`core::WrapAlgorithm` enum. The enum variants are now two structs:
14-
`wrap_algorithms::FirstFit` and `wrap_algorithms::OptimalFit`.
15-
16-
* `WordSeparator`: this new trait lets you specify how words are
17-
separated in the text. Until now, Textwrap would simply split on
18-
spaces. While this works okay for Western languages, it fails to
19-
take emojis and East-Asian languages into account.
20-
21-
The new `AsciiSpace` and `UnicodeBreakProperties` structs implement
22-
the trait. The latter is available if the new optional
23-
`unicode-linebreak` Cargo feature is enabled.
8+
This is a major feature release which makes Textwrap more configurable
9+
and flexible. The high-level API of `textwrap::wrap` and
10+
`textwrap::fill` remains unchanged, but low-level structs have moved
11+
around.
2412

25-
Common usages of textwrap stays unchanged, but if you previously
26-
spelled out the full type for `Options`, you now need to take the
27-
extra type parameters into account. This means that
13+
The biggest change is the introduction of new generic type parameters
14+
to the `Options` struct. These parameters lets you statically
15+
configure the wrapping algorithm, the word separator, and the word
16+
splitter. If you previously spelled out the full type for `Options`,
17+
you now need to take the extra type parameters into account. This
18+
means that
2819

2920
```rust
3021
let options: Options<HyphenSplitter> = Options::new(80);
3122
```
3223

33-
need to change to
24+
changes to
3425

3526
```rust
36-
let options: Options<wrap_algorithms::FirstFit, AsciiSpace, HyphenSplitter> = Options::new(80);
27+
let options: Options<
28+
wrap_algorithms::FirstFit,
29+
word_separators::AsciiSpace,
30+
word_splitters::HyphenSplitter,
31+
> = Options::new(80);
3732
```
3833

39-
You won’t see any chance if you call `wrap` directly with a width or
40-
with an `Options` constructed on the fly.
34+
This is quite a mouthful, so we suggest using type inferrence where
35+
possible. You won’t see any chance if you call `wrap` directly with a
36+
width or with an `Options` value constructed on the fly. Please open
37+
an issue if this causes problems for you!
38+
39+
### New `WordSeparator` Trait
40+
41+
* [#332](https://github.com/mgeisler/textwrap/pull/332): Add
42+
`WordSeparator` trait to allow customizing how words are found in a
43+
line of text. Until now, Textwrap would always assume that words are
44+
separated by ASCII space characters. You can now customize this as
45+
needed.
46+
47+
* [#313](https://github.com/mgeisler/textwrap/pull/313): Add support
48+
for using the Unicode line breaking algorithm to find words. This is
49+
done by adding a second implementation of the new `WordSeparator`
50+
trait. The implementation uses the unicode-linebreak crate, which is
51+
a new optional dependency.
52+
53+
With this, Textwrap can be used with East-Asian languages such as
54+
Chinese or Japanese where there are no spaces between words.
55+
Breaking a long sequence of emojis is another example where line
56+
breaks might be wanted even if there are no whitespace to be found.
57+
Feedback would be appreciated for this feature.
58+
59+
60+
### Indent
61+
62+
* [#353](https://github.com/mgeisler/textwrap/pull/353): Trim trailing
63+
whitespace from `prefix` in `indent`.
64+
65+
Before, empty lines would get no prefix added. Now, empty lines have
66+
a trimmed prefix added. This little trick makes `indent` much more
67+
useful since you can now safely indent with `"# "` without creating
68+
trailing whitespace in the output due to the trailing whitespace in
69+
your prefix.
70+
71+
* [#354](https://github.com/mgeisler/textwrap/pull/354): Make `indent`
72+
about 20% faster by preallocating the output string.
73+
74+
75+
### Documentation
76+
77+
* [#308](https://github.com/mgeisler/textwrap/pull/308): Document
78+
handling of leading and trailing whitespace when wrapping text.
79+
80+
### WebAssembly Demo
81+
82+
* [#310](https://github.com/mgeisler/textwrap/pull/310): Thanks to
83+
WebAssembly, you can now try out Textwrap directly in your browser.
84+
Please try it out: https://mgeisler.github.io/textwrap/.
85+
86+
### New Generic Parameters
87+
88+
* [#331](https://github.com/mgeisler/textwrap/pull/331): Remove outer
89+
boxing from `Options`.
90+
91+
* [#357](https://github.com/mgeisler/textwrap/pull/357): Replace
92+
`core::WrapAlgorithm` enum with a `wrap_algorithms::WrapAlgorithm`
93+
trait. This allows for arbitrary wrapping algorithms to be plugged
94+
into the library.
95+
96+
* [#358](https://github.com/mgeisler/textwrap/pull/358): Switch
97+
wrapping functions to use a slice for `line_widths`.
98+
99+
* [#368](https://github.com/mgeisler/textwrap/pull/368): Move
100+
`WordSeparator` and `WordSplitter` traits to separate modules.
101+
Before, Textwrap had several top-level structs such as
102+
`NoHyphenation` and `HyphenSplitter`. These implementations of
103+
`WordSplitter` now lives in a dedicated `word_splitters` module.
104+
Similarly, we have a new `word_separators` module for
105+
implementations of `WordSeparator`.
106+
107+
* [#369](https://github.com/mgeisler/textwrap/pull/369): Rename
108+
`Options::splitter` to `Options::word_splitter` for consistency with
109+
the other fields backed by traits.
41110

42111
## Version 0.13.4 (2021-02-23)
43112

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "textwrap"
3-
version = "0.13.4"
3+
version = "0.14.0"
44
authors = ["Martin Geisler <[email protected]>"]
55
description = "Powerful library for word wrapping, indenting, and dedenting strings"
66
documentation = "https://docs.rs/textwrap/"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ drawn on a [HTML5 canvas using WebAssembly][wasm-demo].
1616
To use the textwrap crate, add this to your `Cargo.toml` file:
1717
```toml
1818
[dependencies]
19-
textwrap = "0.13"
19+
textwrap = "0.14"
2020
```
2121

2222
By default, this enables word wrapping with support for Unicode

images/textwrap-0.14.0.svg

Lines changed: 21 additions & 0 deletions
Loading

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
//! The full dependency graph, where dashed lines indicate optional
125125
//! dependencies, is shown below:
126126
//!
127-
//! <img src="https://raw.githubusercontent.com/mgeisler/textwrap/master/images/textwrap-0.13.4.svg">
127+
//! <img src="https://raw.githubusercontent.com/mgeisler/textwrap/master/images/textwrap-0.14.0.svg">
128128
//!
129129
//! ## Default Features
130130
//!
@@ -177,7 +177,7 @@
177177
//! [terminal_size]: https://docs.rs/terminal_size/
178178
//! [hyphenation]: https://docs.rs/hyphenation/
179179
180-
#![doc(html_root_url = "https://docs.rs/textwrap/0.13.4")]
180+
#![doc(html_root_url = "https://docs.rs/textwrap/0.14.0")]
181181
#![forbid(unsafe_code)] // See https://github.com/mgeisler/textwrap/issues/210
182182
#![deny(missing_docs)]
183183
#![deny(missing_debug_implementations)]

0 commit comments

Comments
 (0)