Skip to content

Commit e4ddfc2

Browse files
committed
Fixed doc typos in OptionParser
1 parent befa36c commit e4ddfc2

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/elixir/lib/option_parser.ex

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
defmodule OptionParser do
2+
@moduledoc """
3+
This module contains functions to parse command line arguments.
4+
"""
5+
26
@doc """
3-
Parses the argv and returns one tuple with parsed options
4-
and the arguments.
7+
Parses `argv` and returns a tuple with parsed options
8+
and arguments.
59
610
## Examples
711
@@ -16,22 +20,22 @@ defmodule OptionParser do
1620
1721
## Aliases
1822
19-
A set of aliases can be given as second argument:
23+
A set of aliases can be given as the second argument:
2024
2125
iex> OptionParser.parse(["-d"], aliases: [d: :debug])
2226
{ [debug: true], [] }
2327
2428
## Switches
2529
26-
Extra information about switches can be given as argument too.
27-
This is useful in order to say a switch must behave as a boolean
30+
Extra information about switches can be given as arguments, too.
31+
This is useful when a switch must behave as a boolean
2832
or if duplicated switches should be kept, overriden or accumulated.
2933
3034
The following types are supported:
3135
32-
* `:boolean` - Marks the given switch as boolean. Boolean switches
33-
never consumes the following value unless it is
34-
true or false;
36+
* `:boolean` - Marks the given switch as a boolean. Boolean switches
37+
never consume the following value unless it is
38+
`true` or `false`;
3539
* `:integer` - Parses the switch as an integer;
3640
* `:float` - Parses the switch as a float;
3741
@@ -61,16 +65,18 @@ defmodule OptionParser do
6165
end
6266

6367
@doc """
64-
Similar to parse but only parses the head of the argv.
65-
I.e. as soon as it finds a non switch, it stops parsing.
68+
Similar to `parse/2` but only parses the head of `argv`;
69+
as soon as it finds a non-switch, it stops parsing.
6670
67-
Check `parse/2` for more info.
71+
See `parse/2` for more information.
6872
6973
## Example
7074
7175
iex> OptionParser.parse_head(["--source", "lib", "test/enum_test.exs", "--verbose"])
7276
{ [source: "lib"], ["test/enum_test.exs", "--verbose"] }
7377
78+
iex> OptionParser.parse_head(["--verbose", "--source", "lib", "test/enum_test.exs", "--unlock"])
79+
{[verbose: true, source: "lib"], ["test/enum_test.exs", "--unlock"]}
7480
"""
7581
def parse_head(argv, opts // []) when is_list(argv) and is_list(opts) do
7682
parse(argv, opts, false)

0 commit comments

Comments
 (0)