Skip to content

Commit a57be73

Browse files
author
José Valim
committed
Merge pull request #1087 from alco/iex-docs
Review IEx docs
2 parents 5cbe0ba + 79020c7 commit a57be73

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
lines changed

lib/iex/lib/iex/cli.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule IEx.CLI do
22
@moduledoc false
33

44
@doc """
5-
Starts IEx checking if tty is available or not.
5+
Starts IEx checking if tty (a termnial emulator) is available or not.
66
If so, invoke tty, otherwise go with the simple iex.
77
"""
88
def start do

lib/iex/lib/iex/helpers.ex

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ defmodule IEx.Helpers do
4444
to write their object code to. It returns the name
4545
of the compiled modules.
4646
47+
When compiling one file, there is no need to wrap it in a list.
48+
4749
## Examples
4850
49-
c ["foo.ex"], "ebin"
50-
#=> [Foo]
51+
c ["foo.ex", "bar.ex"], "ebin"
52+
#=> [Foo,Bar]
53+
54+
c "baz.ex"
55+
#=> [Baz]
5156
5257
"""
5358
def c(files, path // ".") do
@@ -56,7 +61,8 @@ defmodule IEx.Helpers do
5661
end
5762

5863
@doc """
59-
Returns the name and module of all modules loaded.
64+
Prints the list of all loaded modules with paths to their corresponding .beam
65+
files.
6066
"""
6167
def m do
6268
all = Enum.map :code.all_loaded, fn { mod, file } -> { inspect(mod), file } end
@@ -70,7 +76,8 @@ defmodule IEx.Helpers do
7076
end
7177

7278
@doc """
73-
Prints commands history and their result.
79+
Prints the history of expressions evaluated during the session along with
80+
their results.
7481
"""
7582
def v do
7683
history = Enum.reverse(Process.get(:iex_history))
@@ -82,14 +89,14 @@ defmodule IEx.Helpers do
8289
end
8390

8491
@doc """
85-
Shows the documentation for IEx.Helpers.
92+
Prints the documentation for IEx.Helpers.
8693
"""
8794
def h() do
8895
IEx.Introspection.h(IEx.Helpers)
8996
end
9097

9198
@doc """
92-
Shows the documentation for the given module
99+
Prints the documentation for the given module
93100
or for the given function/arity pair.
94101
95102
## Examples
@@ -136,8 +143,10 @@ defmodule IEx.Helpers do
136143
end
137144

138145
@doc """
139-
Prints all types for the given module or prints out a specified type's
140-
specification
146+
When given a module, prints specifications (or simply specs) for all the
147+
types defined in it.
148+
149+
When given a particular type name, prints its spec.
141150
142151
## Examples
143152
@@ -165,7 +174,11 @@ defmodule IEx.Helpers do
165174
end
166175

167176
@doc """
168-
Prints all specs from a given module.
177+
Similar to `t/1`, only for specs.
178+
179+
When given a module, prints the list of all specs defined in the module.
180+
181+
When given a particular spec name (with optional arity), prints its spec.
169182
170183
## Examples
171184
@@ -207,9 +220,10 @@ defmodule IEx.Helpers do
207220
end
208221

209222
@doc """
210-
Retrieves nth query's value from the history. Use negative
211-
values to lookup query's value from latest to earliest.
212-
For instance, v(-1) returns the latest result.
223+
Retrieves nth expression's value from the history.
224+
225+
Use negative values to lookup expression values relative to the current one.
226+
For instance, v(-1) returns the result of the last evaluated expression.
213227
"""
214228
def v(n) when n < 0 do
215229
history = Process.get(:iex_history)
@@ -222,8 +236,8 @@ defmodule IEx.Helpers do
222236
end
223237

224238
@doc """
225-
Reloads all modules that were already reloaded
226-
at some point with `r/1`.
239+
Reloads all modules that have already been reloaded with `r/1` at any point
240+
in the current IEx session.
227241
"""
228242
def r do
229243
Enum.map iex_reloaded, r(&1)
@@ -232,8 +246,8 @@ defmodule IEx.Helpers do
232246
@doc """
233247
Recompiles and reloads the specified module's source file.
234248
235-
Please note that all the modules defined in the specified
236-
files are recompiled and reloaded.
249+
Please note that all the modules defined in the same file as `module`
250+
are recompiled and reloaded.
237251
"""
238252
def r(module) do
239253
if source = source(module) do
@@ -245,15 +259,15 @@ defmodule IEx.Helpers do
245259
end
246260

247261
@doc """
248-
Purges and reloads specified module
262+
Purges and reloads specified module.
249263
"""
250264
def l(module) do
251265
:code.purge(module)
252266
:code.load_file(module)
253267
end
254268

255269
@doc """
256-
Flushes all messages sent to the shell and prints them out
270+
Flushes all messages sent to the shell and prints them out.
257271
"""
258272
def flush do
259273
receive do
@@ -297,7 +311,7 @@ defmodule IEx.Helpers do
297311
end
298312

299313
@doc """
300-
Changes the shell directory to the given path.
314+
Changes the current working directory to the given path.
301315
"""
302316
def cd(directory) do
303317
case File.cd(expand_home(directory)) do

lib/iex/lib/iex/remsh.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
defmodule IEx.Remsh do
22
@moduledoc """
3-
Helper function injected into connecting remote nodes
4-
to properly handle autocompletion. Elixir supports:
3+
Provides one helper function that is injected into connecting
4+
remote nodes to properly handle autocompletion. Elixir supports:
55
6-
* remsh from an elixir node to an elixir node
7-
* remsh from a plain erlang node to an elixir node (through the ^G menu)
8-
* remsh from an elixir node to a plain erlang node (and get an erl shell there)
6+
* remsh from an elixir node to an elixir node
7+
* remsh from a plain erlang node to an elixir node (through the ^G menu)
8+
* remsh from an elixir node to a plain erlang node (and get an erl shell there)
99
1010
In order to get an Elixir shell from the ^G menu,
1111
you need to use 'Elixir-IEx' as the shell name.
@@ -17,7 +17,7 @@ defmodule IEx.Remsh do
1717
fn e ->
1818
case :rpc.call node, Elixir.IEx.Autocomplete, :expand, [e] do
1919
{:badrpc, _} -> {:no, '', []}
20-
r -> r
20+
r -> r
2121
end
2222
end
2323
end

lib/iex/lib/iex/server.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
defmodule IEx.Server do
22
@moduledoc false
33

4+
@doc """
5+
Eval loop for an IEx session. Its responsibilities include:
6+
7+
* reading input
8+
* trapping exceptions in the code being evaluated
9+
* keeping input history
10+
11+
"""
412
def start(config) do
513
IO.puts "Interactive Elixir (#{System.version}) - press Ctrl+C to exit (type h() ENTER for help)"
614
Process.put :iex_history, []

0 commit comments

Comments
 (0)