Skip to content

Commit 7805f2a

Browse files
committed
SwiftFormat -> swift-format
1 parent 369bef0 commit 7805f2a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Documentation/PrettyPrinter.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
# SwiftFormat Pretty Printer
1+
# swift-format Pretty Printer
2+
3+
> :warning: **NOTE:** Some of the information in this document is out of date
4+
> and needs to be rewritten.
25
36
## Introduction
47

5-
The algorithm used in the SwiftFormat pretty printer is based on the "simple"
8+
The algorithm used in the swift-format pretty printer is based on the "simple"
69
version of the algorithm described by Derek Oppen in his paper [*Pretty
710
Printing*](http://i.stanford.edu/pub/cstr/reports/cs/tr/79/770/CS-TR-79-770.pdf)
811
(1979). It employs two functions: *scan* and *print*. The *scan* function
912
accepts a stream of tokens and calculates the lengths of these tokens. It then
1013
passes the tokens and their computed lengths to *print*, which handles the
1114
actual printing of the tokens, automatically inserting line breaks and indents
1215
to obey a given maximum line length. We describe in detail how these functions
13-
have been implemented in SwiftFormat.
16+
have been implemented in swift-format.
1417

1518
## Tokens
1619

@@ -434,7 +437,7 @@ value is appended to the length array, and added to `total`.
434437
## Print
435438

436439
The purpose of the *print* phase is to print the contents of a syntax node to
437-
the console or to append it to a string buffer as we do in SwiftFormat. It
440+
the console or to append it to a string buffer as we do in swift-format. It
438441
tracks the remaining space left on the line, and it decides whether or not to
439442
insert a line break based on the length of the token. It uses the following
440443
variables to track state in between calls to `print`:
@@ -551,14 +554,14 @@ equivalent to the maximum line width.
551554
## Differences from Oppen's Algorithm
552555

553556
For those who might already be familiar with Oppen's pretty-printing algorithm,
554-
described below are ways in which SwiftFormat's pretty-printer differs from
557+
described below are ways in which swift-format's pretty-printer differs from
555558
Oppen's.
556559

557560
### Absence of a "stream"
558561

559562
Oppen's algorithm was designed to run like a server. It accepts tokens one at a
560563
time ad infinitum, so it requires a buffer to accumulate tokens. It prints them
561-
out as it goes along. All of SwiftFormat's tokens are already available as an
564+
out as it goes along. All of swift-format's tokens are already available as an
562565
array in memory, so we don't need a buffer. We access the token array directly,
563566
rather than using a separate `stream`.
564567

0 commit comments

Comments
 (0)