Skip to content

Commit 1946feb

Browse files
author
José Valim
committed
Merge pull request #842 from happy4crazy/doc-fixes
Kernel doc fixes
2 parents 129725a + a0101bc commit 1946feb

File tree

2 files changed

+55
-57
lines changed

2 files changed

+55
-57
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ defmodule Kernel do
105105
defmacro left -- right
106106

107107
@doc """
108-
Boolean or. Arguments needs to necessarily be booleans.
108+
Boolean or. Arguments must be booleans.
109109
Allowed in guard clauses.
110110
111111
## Examples
@@ -117,7 +117,7 @@ defmodule Kernel do
117117
defmacro left or right
118118

119119
@doc """
120-
Boolean and. Arguments needs to necessarily be booleans.
120+
Boolean and. Arguments must be booleans.
121121
Allowed in guard clauses.
122122
123123
## Examples
@@ -129,7 +129,7 @@ defmodule Kernel do
129129
defmacro left and right
130130

131131
@doc """
132-
Boolean xor. Arguments needs to necessarily be booleans.
132+
Boolean xor. Arguments must be booleans.
133133
Allowed in guard clauses.
134134
135135
## Examples
@@ -141,7 +141,7 @@ defmodule Kernel do
141141
defmacro left xor right
142142

143143
@doc """
144-
Boolean not. Argument needs to necessarily be a boolean.
144+
Boolean not. Argument must be a boolean.
145145
Allowed in guard clauses.
146146
147147
## Examples
@@ -153,7 +153,7 @@ defmodule Kernel do
153153
defmacro not arg
154154

155155
@doc """
156-
It receives any argument and returns true if it is false
156+
Receives any argument and returns true if it is false
157157
or nil. Returns false otherwise. Not allowed in guard
158158
clauses.
159159
@@ -168,8 +168,8 @@ defmodule Kernel do
168168
defmacro !arg
169169

170170
@doc """
171-
Return true if left is less than right.
172-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
171+
Returns true if left is less than right.
172+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
173173
174174
## Examples
175175
@@ -180,8 +180,8 @@ defmodule Kernel do
180180
defmacro left < right
181181

182182
@doc """
183-
Return true if left is more than right.
184-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
183+
Returns true if left is more than right.
184+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
185185
186186
## Examples
187187
@@ -192,8 +192,8 @@ defmodule Kernel do
192192
defmacro left > right
193193

194194
@doc """
195-
Return true if left is less than or equal to right.
196-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
195+
Returns true if left is less than or equal to right.
196+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
197197
198198
## Examples
199199
@@ -204,8 +204,8 @@ defmodule Kernel do
204204
defmacro left <= right
205205

206206
@doc """
207-
Return true if left is more than or equal to right.
208-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
207+
Returns true if left is more than or equal to right.
208+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
209209
210210
## Examples
211211
@@ -221,7 +221,7 @@ defmodule Kernel do
221221
This operator considers 1 and 1.0 to be equal. For strict
222222
comparison, use `===` instead.
223223
224-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
224+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
225225
226226
## Examples
227227
@@ -240,7 +240,7 @@ defmodule Kernel do
240240
This operator considers 1 and 1.0 to be equal. For strict
241241
comparison, use `!==` instead.
242242
243-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
243+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
244244
245245
## Examples
246246
@@ -254,7 +254,7 @@ defmodule Kernel do
254254

255255
@doc """
256256
Returns true if the two items are strictly equal.
257-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
257+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
258258
259259
## Examples
260260
@@ -269,7 +269,7 @@ defmodule Kernel do
269269

270270
@doc """
271271
Returns true if the two items are strictly not equal.
272-
As Erlang, Elixir can compare any term. Allowed in guard clauses.
272+
Like Erlang, Elixir can compare any term. Allowed in guard clauses.
273273
274274
## Examples
275275
@@ -411,7 +411,7 @@ defmodule Kernel do
411411
end
412412

413413
@doc """
414-
As binary_to_list/1, but returns a list of integers corresponding to the bytes
414+
Like binary_to_list/1, but returns a list of integers corresponding to the bytes
415415
from position `start` to position `stop` in `binary`. Positions in the binary
416416
are numbered starting from 1.
417417
"""
@@ -466,7 +466,7 @@ defmodule Kernel do
466466
467467
## Examples
468468
469-
bit_size(<<433|16,3|3>>) #=> 19
469+
bit_size(<<433::16,3::3>>) #=> 19
470470
bit_size(<<1,2,3>>) #=> 24
471471
472472
"""
@@ -494,7 +494,7 @@ defmodule Kernel do
494494
495495
## Examples
496496
497-
byte_size(<<433|16,3|3>>) #=> 3
497+
byte_size(<<433::16,3::3>>) #=> 3
498498
byte_size(<<1,2,3>>) #=> 3
499499
500500
"""
@@ -810,10 +810,10 @@ defmodule Kernel do
810810
811811
bin1 = <<1,2,3>>
812812
bin2 = <<4,5>>
813-
bin3 = <<6,7|4>>
813+
bin3 = <<6,7::4>>
814814
815815
list_to_bitstring([bin1,1,[2,3,bin2],4|bin3])
816-
#=> <<1,2,3,1,2,3,4,5,4,6,7|4>>
816+
#=> <<1,2,3,1,2,3,4,5,4,6,7::size(4)>>
817817
818818
"""
819819
@spec list_to_bitstring(maybe_improper_list(char | binary | iolist | bitstring, binary | bitstring | [])) :: bitstring
@@ -877,7 +877,7 @@ defmodule Kernel do
877877
It should not be used in application programs.
878878
879879
## Examples
880-
list_to_pid('<0.41>') #=> <0.4.1>
880+
list_to_pid('<0.4.1>') #=> #PID<0.4.1>
881881
"""
882882
@spec list_to_pid(char_list) :: pid
883883
def list_to_pid(char_list) do
@@ -905,7 +905,7 @@ defmodule Kernel do
905905
## Examples
906906
907907
make_ref()
908-
#=> #Ref<0.0.0.135>
908+
#=> #Reference<0.0.0.135>
909909
910910
"""
911911
@spec make_ref() :: reference
@@ -955,7 +955,7 @@ defmodule Kernel do
955955
end
956956

957957
@doc """
958-
Returns the node where the given argmuent is located.
958+
Returns the node where the given argument is located.
959959
The argument can be a pid, a reference, or a port.
960960
If the local node is not alive, nonode@nohost is returned.
961961
@@ -1008,7 +1008,7 @@ defmodule Kernel do
10081008

10091009
@doc """
10101010
Returns the size of the given argument, which must be a tuple
1011-
or a binary. If possible, please use tuple_size or binary_size.
1011+
or a binary. If possible, please use `tuple_size` or `binary_size`.
10121012
"""
10131013
@spec size(tuple|binary) :: non_neg_integer
10141014
def size(arg) do
@@ -1026,7 +1026,7 @@ defmodule Kernel do
10261026
current = Kernel.self
10271027
child = spawn(fn -> current <- { Kernel.self, 1 + 2 } end)
10281028
1029-
receive
1029+
receive do
10301030
{ ^child, 3 } -> IO.puts "Received 3 back"
10311031
end
10321032
@@ -1064,9 +1064,8 @@ defmodule Kernel do
10641064
current = Kernel.self
10651065
child = spawn_link(fn -> current <- { Kernel.self, 1 + 2 } end)
10661066
1067-
receive
1068-
{ ^child, 3 } ->
1069-
IO.puts "Received 3 back"
1067+
receive do
1068+
{ ^child, 3 } -> IO.puts "Received 3 back"
10701069
end
10711070
10721071
"""
@@ -1093,7 +1092,7 @@ defmodule Kernel do
10931092
end
10941093

10951094
@doc """
1096-
Returns a binary data which is the result of encoding the given term
1095+
Returns a binary which is the result of encoding the given term
10971096
according to the Erlang external term format.
10981097
10991098
This can be used for a variety of purposes, for example, writing a term
@@ -1108,8 +1107,8 @@ defmodule Kernel do
11081107
@doc """
11091108
The same as `term_to_binary/1` but also supports two options:
11101109
1111-
* compressed: the level of compression to be used from 0 to 9;
1112-
* minor_version: used to control the details of encoding. Can be 0 or 1,
1110+
* `compressed`: the level of compression to be used from 0 to 9;
1111+
* `minor_version`: used to control the details of encoding. Can be 0 or 1,
11131112
please read http://www.erlang.org/doc/man/erlang.html#term_to_binary-2
11141113
for more details
11151114
@@ -1136,7 +1135,7 @@ defmodule Kernel do
11361135
end
11371136

11381137
@doc """
1139-
Returns an integer by the truncating the given number.
1138+
Returns an integer by truncating the given number.
11401139
Allowed in guard clauses.
11411140
11421141
## Examples
@@ -1518,7 +1517,7 @@ defmodule Kernel do
15181517
end
15191518

15201519
@doc """
1521-
Check if the given structure is an exception.
1520+
Checks if the given structure is an exception.
15221521

15231522
## Examples
15241523

@@ -1543,7 +1542,7 @@ defmodule Kernel do
15431542
end
15441543

15451544
@doc """
1546-
Check if the given structure is a record. It is basically
1545+
Checks if the given structure is a record. It is basically
15471546
a convenient macro that checks the structure is a tuple and
15481547
the first element matches the given kind.
15491548
@@ -1570,7 +1569,7 @@ defmodule Kernel do
15701569
end
15711570

15721571
@doc """
1573-
Check if the given argument is a record.
1572+
Checks if the given argument is a record.
15741573
"""
15751574
defmacro is_record(thing) do
15761575
case __CALLER__.in_guard? do
@@ -1587,7 +1586,7 @@ defmodule Kernel do
15871586
end
15881587

15891588
@doc """
1590-
Check if the given argument is a regex.
1589+
Checks if the given argument is a regex.
15911590
"""
15921591
defmacro is_regex(thing) do
15931592
quote do
@@ -1596,7 +1595,7 @@ defmodule Kernel do
15961595
end
15971596

15981597
@doc """
1599-
Check if the given argument is a range.
1598+
Checks if the given argument is a range.
16001599
"""
16011600
defmacro is_range(thing) do
16021601
quote do
@@ -1675,7 +1674,7 @@ defmodule Kernel do
16751674
end
16761675

16771676
If the protocol is invoked with a data type that is not an Atom,
1678-
nor Tuple, nor List, nor BitString, Elixir will now dispatch to
1677+
a Tuple, a List, or a BitString, Elixir will now dispatch to
16791678
Any. That said, the default behavior could be implemented as:
16801679
16811680
defimpl Blank, for: Any do
@@ -1702,8 +1701,8 @@ defmodule Kernel do
17021701
In the example above, we have implemented `blank?` for
17031702
`RedBlack.Tree` that simply delegates to `RedBlack.empty?` passing
17041703
the tree as argument. This implementation doesn't need to be defined
1705-
inside the `RedBlack` tree or inside the record, but anywhere in
1706-
the code.
1704+
inside the `RedBlack` tree or inside the record; it can be defined
1705+
anywhere in the code.
17071706
17081707
Finally, since records are simply tuples, one can add a default
17091708
protocol implementation to any record by defining a default
@@ -1753,8 +1752,8 @@ defmodule Kernel do
17531752
17541753
## Examples
17551754
1756-
For example, in other to write tests using the ExUnit framework,
1757-
a developers should use the `ExUnit.Case` module:
1755+
For example, in order to write tests using the ExUnit framework,
1756+
a developer should use the `ExUnit.Case` module:
17581757
17591758
defmodule AssertionTest do
17601759
use ExUnit.Case, async: true
@@ -1812,9 +1811,9 @@ defmodule Kernel do
18121811
inspect(:foo)
18131812
#=> ":foo"
18141813
1815-
Notice the inspect protocol does not necessarily return a valid Elixir
1816-
terms representation. In such cases, the inspected result must start
1817-
with `#`. For example, inspecting a function will return:
1814+
Note that the inspect protocol does not necessarily return a valid
1815+
representation of an Elixir term. In such cases, the inspected result must
1816+
start with `#`. For example, inspecting a function will return:
18181817
18191818
inspect &1 + &2
18201819
#=> #Function<...>
@@ -2003,7 +2002,7 @@ defmodule Kernel do
20032002
x * 2
20042003
end
20052004
2006-
Not only the example is shorter, it solves ambiguity issues. Since
2005+
Not only is the example shorter, it solves ambiguity issues. Since
20072006
`do/end` always matches the furthest call, if we used the `function`
20082007
macro as below:
20092008
@@ -2034,7 +2033,7 @@ defmodule Kernel do
20342033
The `function` macro can also be used to retrieve local or remote
20352034
functions:
20362035
2037-
f = function(:is_atom, 2)
2036+
f = function(:is_atom, 1)
20382037
f.(:foo) #=> true
20392038
20402039
f = function(List, :flatten, 1)
@@ -2387,11 +2386,10 @@ defmodule Kernel do
23872386
end
23882387

23892388
@doc """
2390-
Allows you to destructure two lists, assigning each
2391-
term in the right to the left. Differently from pattern
2392-
matching via `=`, if the sizes of the left and right
2393-
lists don't match,, structuring simply stops instead
2394-
of raising an error.
2389+
Allows you to destructure two lists, assigning each term in the right to the
2390+
matching term in the left. Unlike pattern matching via `=`, if the sizes of
2391+
the left and right lists don't match, destructuring simply stops instead of
2392+
raising an error.
23952393
23962394
## Examples
23972395
@@ -2401,7 +2399,7 @@ defmodule Kernel do
24012399
z #=> 3
24022400
24032401
Notice in the example above, even though the right
2404-
size has more entries than the left, structuring works
2402+
size has more entries than the left, destructuring works
24052403
fine. If the right size is smaller, the remaining items
24062404
are simply assigned to nil:
24072405

lib/elixir/lib/kernel/typespec.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ defmodule Kernel.Typespec do
7575
Elixir discourages the use of type `string()` as it might be confused
7676
with binaries which are referred to as "strings" in Elixir (as opposed to
7777
character lists). In order to use the type that is called `string()` in Erlang,
78-
one has to use the `char_list()` type which is a synonym to `string()`. If yu
78+
one has to use the `char_list()` type which is a synonym for `string()`. If you
7979
use `string()`, you'll get a warning from the compiler.
8080
8181
If you want to refer to the "string" type (the one operated by functions in the
@@ -704,4 +704,4 @@ defmodule Kernel.Typespec do
704704
defp variable({name, meta, _}) do
705705
{:var, line(meta), name}
706706
end
707-
end
707+
end

0 commit comments

Comments
 (0)