Skip to content

Commit cca4ac9

Browse files
author
José Valim
committed
Merge pull request #1502 from jwarwick/code_formatting
Fixed docs typos and added code markers around functions in docs
2 parents eee8880 + a700e23 commit cca4ac9

File tree

4 files changed

+61
-61
lines changed

4 files changed

+61
-61
lines changed

lib/elixir/lib/path.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Path do
99
1010
The majority of the functions in this module do not
1111
interact with the file system, except for a few functions
12-
that require it (like `Path.wildcard` and `Path.expand`).
12+
that require it (like `wildcard/1` and `expand/1`).
1313
"""
1414

1515
alias :filename, as: FN
@@ -19,7 +19,7 @@ defmodule Path do
1919

2020
@doc """
2121
Converts the given path to an absolute one. Unlike
22-
`Path.expand/1`, no attempt is made to resolve `..`, `.` or `~`.
22+
`expand/1`, no attempt is made to resolve `..`, `.` or `~`.
2323
2424
## Unix examples
2525
@@ -43,9 +43,9 @@ defmodule Path do
4343

4444
@doc """
4545
Builds a path from `relative_to` to `path`. If `path` is already
46-
an absolute path, `relative_to` is ignored. See also `Path.relative/2`.
46+
an absolute path, `relative_to` is ignored. See also `relative/2`.
4747
48-
Unlike `Path.expand/2`, no attempt is made to
48+
Unlike `expand/2`, no attempt is made to
4949
resolve `..`, `.` or `~`.
5050
5151
## Examples
@@ -80,7 +80,7 @@ defmodule Path do
8080
expanding any `.` and `..` characters. If the path is already an
8181
absolute path, `relative_to` is ignored.
8282
83-
Note, that this function treats `path` with leading `~` as
83+
Note, that this function treats `path` with a leading `~` as
8484
an absolute one.
8585
8686
The second argument is first expanded to an absolute path.
@@ -461,7 +461,7 @@ defmodule Path do
461461
462462
Imagine you have a directory called `projects` with three Elixir projects
463463
inside of it: `elixir`, `ex_doc` and `dynamo`. You can find all `.beam` files
464-
inside the ebin directory of each project as follows:
464+
inside the `ebin` directory of each project as follows:
465465
466466
Path.wildcard("projects/*/ebin/**/*.beam")
467467

lib/elixir/lib/string.ex

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ defmodule String do
66
77
The functions in this module act according to the
88
Unicode Standard, version 6.2.0. For example,
9-
`titlecase`, `downcase`, `strip` are provided by this
9+
`capitalize/1`, `downcase/1`, `strip/1` are provided by this
1010
module.
1111
1212
Besides this module, Elixir provides more low-level
13-
operations that works directly with binaries. Some
13+
operations that work directly with binaries. Some
1414
of those can be found in the `Kernel` module, as:
1515
16-
* `binary_part/2` and `binary_part/3` - retrieves part of the binary
17-
* `bit_size/1` and `byte_size/1` - size related functions
18-
* `is_bitstring/1` and `is_binary/1` - type checking function
19-
* Plus a bunch of conversion functions, like `binary_to_atom/2`,
20-
`binary_to_integer/2`, `binary_to_term/1` and their opposite
21-
like `integer_to_binary/2`
16+
* `Kernel.binary_part/2` and `Kernelbinary_part/3` - retrieves part of the binary
17+
* `Kernel.bit_size/1` and `Kernel.byte_size/1` - size related functions
18+
* `Kernel.is_bitstring/1` and `Kernel.is_binary/1` - type checking function
19+
* Plus a number of conversion functions, like `Kernel.binary_to_atom/2`,
20+
`Kernel.binary_to_integer/2`, `Kernel.binary_to_term/1` and their opposite
21+
like `Kernel.integer_to_binary/2`
2222
23-
Finally, [the `:binary` module](http://erlang.org/doc/man/binary.html)
24-
provides a couple other functions that works on the byte level.
23+
Finally, the [`:binary` module](http://erlang.org/doc/man/binary.html)
24+
provides a few other functions that work on the byte level.
2525
2626
## Codepoints and graphemes
2727
@@ -93,7 +93,7 @@ defmodule String do
9393
codepoint needs to be rejected.
9494
9595
This module relies on this behaviour to ignore such invalid
96-
characters. For example, `String.length` is going to return
96+
characters. For example, `length/1` is going to return
9797
a correct result even if an invalid codepoint is fed into it.
9898
9999
In other words, this module expects invalid data to be detected
@@ -108,7 +108,7 @@ defmodule String do
108108

109109
@doc """
110110
Checks if a string is printable considering it is encoded
111-
as UTF-8. Returns true if so, false otherwise.
111+
as UTF-8. Returns `true` if so, `false` otherwise.
112112
113113
## Examples
114114
@@ -200,7 +200,7 @@ defmodule String do
200200
end
201201

202202
@doc """
203-
Splits a string on sub strings at each Unicode whitespace
203+
Splits a string on substrings at each Unicode whitespace
204204
occurrence with leading and trailing whitespace ignored.
205205
206206
## Examples
@@ -217,12 +217,12 @@ defmodule String do
217217
defdelegate split(binary), to: String.Unicode
218218

219219
@doc """
220-
Divides a string into sub strings based on a pattern,
221-
returning a list of these sub string. The pattern can
220+
Divides a string into substrings based on a pattern,
221+
returning a list of these substrings. The pattern can
222222
be a string, a list of strings or a regular expression.
223223
224224
The string is split into as many parts as possible by
225-
default, unless the `global` option is set to false.
225+
default, unless the `global` option is set to `false`.
226226
227227
## Examples
228228
@@ -258,7 +258,7 @@ defmodule String do
258258
end
259259

260260
@doc """
261-
Convert all characters on the given string to upcase.
261+
Convert all characters on the given string to uppercase.
262262
263263
## Examples
264264
@@ -274,7 +274,7 @@ defmodule String do
274274
defdelegate upcase(binary), to: String.Unicode
275275

276276
@doc """
277-
Convert all characters on the given string to downcase.
277+
Convert all characters on the given string to lowercase.
278278
279279
## Examples
280280
@@ -291,11 +291,11 @@ defmodule String do
291291

292292
@doc """
293293
Converts the first character in the given string to
294-
titlecase and the remaining to downcase.
294+
uppercase and the remaining to lowercase.
295295
296296
This relies on the titlecase information provided
297297
by the Unicode Standard. Note this function makes
298-
no attempt in capitalizing all words in the string
298+
no attempt to capitalize all words in the string
299299
(usually known as titlecase).
300300
301301
## Examples
@@ -430,7 +430,7 @@ defmodule String do
430430
@doc """
431431
Returns a new binary based on `subject` by replacing the parts
432432
matching `pattern` for `replacement`. By default, it replaces
433-
all entries, except if the `global` option is set to false.
433+
all entries, except if the `global` option is set to `false`.
434434
435435
If the replaced part must be used in `replacement`, then the
436436
position or the positions where it is to be inserted must be
@@ -533,7 +533,7 @@ defmodule String do
533533
remaining of the string or `:no_codepoint` in case
534534
the string reached its end.
535535
536-
As the other functions in the String module, this
536+
As with other functions in the String module, this
537537
function does not check for the validity of the codepoint.
538538
That said, if an invalid codepoint is found, it will
539539
be returned by this function.
@@ -674,7 +674,7 @@ defmodule String do
674674

675675
@doc """
676676
Returns the last grapheme from an utf8 string,
677-
nil if the string is empty.
677+
`nil` if the string is empty.
678678
679679
## Examples
680680
@@ -762,7 +762,7 @@ defmodule String do
762762
@doc """
763763
Returns a substring starting at the offset given by the first, and
764764
a length given by the second.
765-
If the offset is greater than string length, than it returns nil.
765+
If the offset is greater than string length, than it returns `nil`.
766766
767767
## Examples
768768
@@ -827,8 +827,8 @@ defmodule String do
827827

828828
@doc """
829829
Converts a string to an integer. If successful, returns a
830-
tuple of form {integer, remainder of string}. If unsuccessful,
831-
returns :error.
830+
tuple of the form `{integer, remainder of string}`. If unsuccessful,
831+
returns `:error`.
832832
833833
## Examples
834834
@@ -852,9 +852,9 @@ defmodule String do
852852

853853
@doc """
854854
Converts a string to a float. If successful, returns a
855-
tuple of form {float, remainder of string}. If unsuccessful,
856-
returns :error. If given an integer value, will return
857-
same as to_integer/1.
855+
tuple of the form `{float, remainder of string}`. If unsuccessful,
856+
returns `:error`. If given an integer value, will return
857+
the same value as `to_integer/1`.
858858
859859
## Examples
860860
@@ -885,8 +885,8 @@ defmodule String do
885885
end
886886

887887
@doc """
888-
Returns true if `string` starts with any of the prefixes given, otherwise
889-
false. `prefixes` can be either a single prefix or a list of prefixes.
888+
Returns `true` if `string` starts with any of the prefixes given, otherwise
889+
`false`. `prefixes` can be either a single prefix or a list of prefixes.
890890
891891
## Examples
892892
@@ -921,8 +921,8 @@ defmodule String do
921921
end
922922

923923
@doc """
924-
Returns true if `string` ends with any of the suffixes given, otherwise
925-
false. `suffixes` can be either a single suffix or a list of suffixes.
924+
Returns `true` if `string` ends with any of the suffixes given, otherwise
925+
`false`. `suffixes` can be either a single suffix or a list of suffixes.
926926
927927
## Examples
928928
@@ -960,7 +960,7 @@ defmodule String do
960960
end
961961

962962
@doc """
963-
Returns true if `string` contains match, otherwise false.
963+
Returns `true` if `string` contains match, otherwise `false`.
964964
`matches` can be either a single string or a list of strings.
965965
966966
## Examples

lib/elixir/lib/system.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ defmodule System do
7979
end
8080

8181
@doc """
82-
Returns the current working directory or nil if one
82+
Returns the current working directory or `nil` if one
8383
is not available.
8484
"""
8585
def cwd do
@@ -98,7 +98,7 @@ defmodule System do
9898

9999
@doc """
100100
Returns the user home (platform independent).
101-
It returns nil if no user home is set.
101+
It returns `nil` if no user home is set.
102102
"""
103103
def user_home do
104104
case :os.type() do
@@ -108,8 +108,8 @@ defmodule System do
108108
end
109109

110110
@doc """
111-
Same as `user_home` but raises `System.NoHomeError`
112-
instead of returning nil if no user home is set.
111+
Same as `user_home/0` but raises `System.NoHomeError`
112+
instead of returning `nil` if no user home is set.
113113
"""
114114
def user_home! do
115115
user_home || raise NoHomeError
@@ -139,7 +139,7 @@ defmodule System do
139139
4. `C:\TMP` on Windows or `/tmp` on Unix
140140
5. As a last resort, the current working directory
141141
142-
Returns nil if none of the above are writable.
142+
Returns `nil` if none of the above are writable.
143143
"""
144144
def tmp_dir do
145145
write_env_tmp_dir('TMPDIR') ||
@@ -151,7 +151,7 @@ defmodule System do
151151

152152
@doc """
153153
Same as `tmp_dir` but raises `System.NoTmpDirError`
154-
instead of returning nil if no temp dir is set.
154+
instead of returning `nil` if no temp dir is set.
155155
"""
156156
def tmp_dir! do
157157
tmp_dir || raise NoTmpDirError
@@ -249,7 +249,7 @@ defmodule System do
249249

250250
@doc """
251251
Returns the value of the environment variable
252-
`varname` as a binary, or nil if the environment
252+
`varname` as a binary, or `nil` if the environment
253253
variable is undefined.
254254
"""
255255
@spec get_env(binary) :: binary | nil
@@ -317,7 +317,7 @@ defmodule System do
317317
318318
For integer status, Erlang runtime system closes all ports and allows async
319319
threads to finish their operations before exiting. To exit without such
320-
flushing, pass options [flush: false] instead.
320+
flushing, pass options `[flush: false]` instead.
321321
322322
For more information, check: http://www.erlang.org/doc/man/erlang.html#halt-2
323323

lib/elixir/lib/uri.ex

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ defmodule URI do
3131

3232
@doc """
3333
Returns the default port for a given scheme.
34-
If the scheme is unknown to URI, returns nil.
35-
Any scheme may be registered via `URI.default_port/2`.
34+
If the scheme is unknown to URI, returns `nil`.
35+
Any scheme may be registered via `default_port/2`.
3636
"""
3737
def default_port(scheme) when is_binary(scheme) do
3838
{ :ok, dict } = :application.get_env(:elixir, :uri)
3939
Dict.get(dict, scheme)
4040
end
4141

4242
@doc """
43-
Registers a scheme with a default port into Elixir.
43+
Registers a scheme with a default port.
4444
"""
4545
def default_port(scheme, port) when is_binary(scheme) and port > 0 do
4646
{ :ok, dict } = :application.get_env(:elixir, :uri)
@@ -49,10 +49,10 @@ defmodule URI do
4949

5050
@doc """
5151
Takes an enumerable (containing a sequence of two-item tuples)
52-
and returns a string of k=v&k2=v2... where keys and values are
53-
URL encoded as per encode. Keys and values can be any term
54-
that implements the Binary.Chars protocol (i.e. can be converted
55-
to binary).
52+
and returns a string of the form "k=v&k2=v2..." where keys and values are
53+
URL encoded as per `encode/1`. Keys and values can be any term
54+
that implements the `Binary.Chars` protocol (i.e. can be converted
55+
to a binary).
5656
"""
5757
def encode_query(l), do: Enum.map_join(l, "&", pair(&1))
5858

@@ -61,7 +61,7 @@ defmodule URI do
6161
orddict with one entry for each key-value pair. Each key and value will be a
6262
binary. It also does percent-unescaping of both keys and values.
6363
64-
Use decoder/1 if you want to customize or iterate each value manually.
64+
Use `query_decoder/1` if you want to iterate over each value manually.
6565
"""
6666
def decode_query(q, dict // HashDict.new) when is_binary(q) do
6767
Enum.reduce query_decoder(q), dict, fn({ k, v }, acc) -> Dict.put(acc, k, v) end
@@ -150,14 +150,14 @@ defmodule URI do
150150
have different default ports. Sometimes the parsing
151151
of portions themselves are different. This parser
152152
is extensible via behavior modules. If you have a
153-
module named URI.MYSCHEME with a function called
154-
'parse' that takes a single argument, the generically
153+
module named `URI.MYSCHEME` with a function called
154+
`parse` that takes a single argument, the generically
155155
parsed URI, that function will be called when this
156156
parse function is passed a URI of that scheme. This
157157
allows you to build on top of what the URI library
158-
currently offers. You also need to define default_port
159-
which takes 0 arguments and returns the default port
160-
for that particular scheme. Take a look at URI.HTTPS for an
158+
currently offers. You also need to define `default_port`
159+
which takes no arguments and returns the default port
160+
for that particular scheme. Take a look at `URI.HTTPS` for an
161161
example of one of these extension modules.
162162
"""
163163
def parse(s) when is_binary(s) do

0 commit comments

Comments
 (0)