Skip to content

Commit 15d347f

Browse files
author
José Valim
committed
Merge pull request #1385 from jwarwick/inspect_docs
Fixed doc typos for Inspect
2 parents 8a9927e + c11d50e commit 15d347f

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

lib/elixir/lib/inspect.ex

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ defprotocol Inspect do
1313
followed by the inspecting options, represented by the record
1414
`Inspect.Opts`.
1515
16-
Inspection is done by using the functions available in
16+
Inspection is done using the functions available in
1717
`Inspect.Algebra` and by calling `Kernel.inspect/2` recursively
18-
passing the `Inspect.Opts` as argument. When `Kernel.inspect/2`
19-
receives a `Inspect.Opts` record as second argument, it returns
18+
passing the `Inspect.Opts` as an argument. When `Kernel.inspect/2`
19+
receives an `Inspect.Opts` record as the second argument, it returns
2020
the underlying algebra document instead of the formatted string.
2121
22-
Many times, inspecting a structure can be implemented in function
22+
Many times, inspecting a structure can be implemented using functions
2323
of the existing entities. For example, here is `HashSet`'s `inspect`
2424
implementation:
2525
@@ -33,13 +33,13 @@ defprotocol Inspect do
3333
3434
The `concat` function comes from `Inspect.Algebra` and it
3535
concatenates algebra documents together. In the example above,
36-
it is concatenating the string `"HashSet<"` (all strings are a
37-
valid algebra document that keeps their formatting when pretty
36+
it is concatenating the string `"HashSet<"` (all strings are
37+
valid algebra documents that keep their formatting when pretty
3838
printed), the document returned by `Kernel.inspect/2` and the
3939
other string `">"`.
4040
41-
Since regular strings are a valid entity in an algebra document,
42-
an implementation of inspect may as well simply return a binary,
41+
Since regular strings are valid entities in an algebra document,
42+
an implementation of inspect may simply return a binary,
4343
although that will devoid it of any pretty-printing.
4444
"""
4545

@@ -50,8 +50,8 @@ defimpl Inspect, for: Atom do
5050
require Macro
5151

5252
@doc """
53-
Represents the atom as an Elixir term. The atoms false, true
54-
and nil are simply quoted. Modules are properly represented
53+
Represents the atom as an Elixir term. The atoms `false`, `true`
54+
and `nil` are simply quoted. Modules are properly represented
5555
as modules using the dot notation.
5656
5757
Notice that in Elixir, all operators can be represented using
@@ -193,7 +193,7 @@ end
193193

194194
defimpl Inspect, for: List do
195195
@doc %B"""
196-
Represents a list checking if it can be printed or not.
196+
Represents a list, checking if it can be printed or not.
197197
If so, a single-quoted representation is returned,
198198
otherwise the brackets syntax is used. Keywords are
199199
printed in keywords syntax.
@@ -249,7 +249,7 @@ end
249249

250250
defimpl Inspect, for: Tuple do
251251
@doc """
252-
Inspect tuples. If the tuple represents a record,
252+
Represents tuples. If the tuple represents a record,
253253
it shows it nicely formatted using the access syntax.
254254
255255
## Examples
@@ -316,10 +316,10 @@ defimpl Inspect, for: Number do
316316
@doc """
317317
Represents the number as a string.
318318
319-
Floats are represented using the shorted, correctly rounded string
319+
Floats are represented using the shortened, correctly rounded string
320320
that converts to float when read back with `binary_to_float/1`. This
321-
is done via the Erlang implementation of the "Printing Floating-Point
322-
Numbers Quickly and Accurately" in Proceedings of the SIGPLAN '96
321+
is done via the Erlang implementation of _Printing Floating-Point
322+
Numbers Quickly and Accurately_ in Proceedings of the SIGPLAN '96
323323
Conference on Programming Language Design and Implementation.
324324
325325
## Examples
@@ -338,7 +338,7 @@ defimpl Inspect, for: Number do
338338
end
339339

340340
defimpl Inspect, for: Regex do
341-
@moduledoc %B"""
341+
@doc %B"""
342342
Represents the Regex using the `%r""` syntax.
343343
344344
## Examples

lib/elixir/lib/inspect/algebra.ex

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ defmodule Inspect.Algebra do
1818
iex> Inspect.Algebra.pretty(doc, 80)
1919
"foo"
2020
21-
The functions `nest/2`, `space/2` and `line/2` helps you put the
21+
The functions `nest/2`, `space/2` and `line/2` help you put the
2222
document together into a rigid structure. However, the document
2323
algebra gets interesting when using functions like `break/2`, which
24-
converts the given string into a line break depending on much space
24+
converts the given string into a line break depending on how much space
2525
there is to print. Let's glue two docs together with a break and then
2626
render it:
2727
@@ -30,28 +30,28 @@ defmodule Inspect.Algebra do
3030
"a b"
3131
3232
Notice the break was represented as is, because we haven't reached
33-
a line limit. Once we do, it is replaced by a new line:
33+
a line limit. Once we do, it is replaced by a newline:
3434
3535
iex> doc = Inspect.Algebra.glue(String.duplicate("a", 20), " ", "b")
3636
iex> Inspect.Algebra.pretty(doc, 10)
3737
"aaaaaaaaaaaaaaaaaaaa\nb"
3838
3939
Finally, this module also contains Elixir related functions, a bit
40-
tied up to Elixir formatting, namely `surround/3` and `surround_many/5`.
40+
tied to Elixir formatting, namely `surround/3` and `surround_many/5`.
4141
4242
## Implementation details
4343
4444
The original Haskell implementation of the algorithm by [Wadler][1]
4545
relies on lazy evaluation to unfold document groups on two alternatives:
46-
`:flat` (breaks as spaces) and `:broken` (breakes as newlines).
47-
Implementing the same logic on a strict language such as Elixir leads
48-
to an exponential growth of the possible documents, unless document
46+
`:flat` (breaks as spaces) and `:broken` (breaks as newlines).
47+
Implementing the same logic in a strict language such as Elixir leads
48+
to an exponential growth of possible documents, unless document
4949
groups are encoded explictly as `:flat` or `:broken`. Those groups are
5050
then reduced to a simple document, where the layout is already decided,
5151
per [Lindig][0].
5252
5353
Custom pretty printers can be implemented using the documents returned
54-
by this module and by providing its own rendenring functions.
54+
by this module and by providing their own rendering functions.
5555
5656
[0]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2200
5757
[1]: http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
@@ -76,7 +76,7 @@ defmodule Inspect.Algebra do
7676
defrecordp :doc_group, :doc_group, [doc: :doc_nil]
7777

7878
@doc """
79-
Returns :doc_nil which is a document entity used to represent
79+
Returns `:doc_nil` which is a document entity used to represent
8080
nothingness. Takes no arguments.
8181
8282
## Examples
@@ -109,7 +109,7 @@ defmodule Inspect.Algebra do
109109
def concat(docs), do: folddoc(docs, concat(&1, &2))
110110

111111
@doc """
112-
Nests document entity x positions deep. Nesting will be
112+
Nests document entity `x` positions deep. Nesting will be
113113
appended to the line breaks.
114114
115115
## Examples
@@ -132,12 +132,12 @@ defmodule Inspect.Algebra do
132132
133133
Let's glue two docs together with a break and then render it:
134134
135-
iex> doc = Inspect.Algebra.glue("a", " ", "b")
136-
iex> Inspect.Algebra.pretty(doc, 80)
137-
"a b"
135+
iex> doc = Inspect.Algebra.glue("a", " ", "b")
136+
iex> Inspect.Algebra.pretty(doc, 80)
137+
"a b"
138138
139139
Notice the break was represented as is, because we haven't reached
140-
a line limit. Once we do, it is replaced by a new line:
140+
a line limit. Once we do, it is replaced by a newline:
141141
142142
iex> doc = Inspect.Algebra.glue(String.duplicate("a", 20), " ", "b")
143143
iex> Inspect.Algebra.pretty(doc, 10)
@@ -157,8 +157,8 @@ defmodule Inspect.Algebra do
157157
def glue(x, y), do: concat(x, concat(break, y))
158158

159159
@doc """
160-
Inserts a break, passed as second argument, between two docs,
161-
the first and the third argument.
160+
Inserts a break, passed as the second argument, between two docs,
161+
the first and the third arguments.
162162
"""
163163
@spec glue(doc, binary, doc) :: :doc_cons_t
164164
def glue(x, g, y) when is_binary(g), do: concat(x, concat(break(g), y))
@@ -243,7 +243,7 @@ defmodule Inspect.Algebra do
243243
@doc %B"""
244244
Surrounds a document with characters.
245245
246-
Puts the document between left and right enclosing and nests it.
246+
Puts the document between left and right enclosing and nesting it.
247247
The document is marked as a group, to show the maximum as possible
248248
concisely together.
249249
@@ -261,8 +261,8 @@ defmodule Inspect.Algebra do
261261

262262
@doc %B"""
263263
Maps and glues a collection of items together using the given separator
264-
and surround them. A limit can be passed which, once reached, stops
265-
glueing and outputs "..." instead.
264+
and surrounds them. A limit can be passed which, once reached, stops
265+
gluing and outputs "..." instead.
266266
267267
## Examples
268268
@@ -335,7 +335,7 @@ defmodule Inspect.Algebra do
335335

336336
@doc """
337337
The pretty printing function.
338-
Takes maximum width and a document to print as its arguments and returns the string
338+
Takes the maximum width and a document to print as its arguments and returns the string
339339
representation of the best layout for the document to fit in the given width.
340340
"""
341341
@spec pretty(doc, non_neg_integer) :: binary

0 commit comments

Comments
 (0)