@@ -6,24 +6,24 @@ defmodule Code do
66 end
77
88 @ moduledoc """
9- The Code module is responsible for managing code compilation,
10- code evaluation and code loading.
9+ Utilities for managing code compilation, code evaluation and code loading.
1110
12- It complements [Erlang's code module](http://www.erlang.org/doc/man/code.html)
11+ This module complements [Erlang's code module](http://www.erlang.org/doc/man/code.html)
1312 to add behavior which is specific to Elixir.
1413
1514 """
1615
1716 @ doc """
18- Returns all loaded files.
17+ List all loaded files.
1918 """
2019 def loaded_files do
2120 :elixir_code_server . call :loaded
2221 end
2322
2423 @ doc """
25- Removes the given files from the loaded files list.
26- The modules defined in the file are not removed,
24+ Remove files from the loaded files list.
25+
26+ The modules defined in the file are not removed;
2727 calling this function only removes them from the list,
2828 allowing them to be required again.
2929 """
@@ -32,33 +32,39 @@ defmodule Code do
3232 end
3333
3434 @ doc """
35- Appends a path to the Erlang VM code path.
35+ Append a path to the Erlang VM code path.
36+
3637 The path is expanded with `Path.expand/1` before being appended.
3738 """
3839 def append_path ( path ) do
3940 :code . add_pathz ( Path . expand to_char_list ( path ) )
4041 end
4142
4243 @ doc """
43- Prepends a path to the Erlang VM code path.
44+ Prepend a path to the Erlang VM code path.
45+
4446 The path is expanded with `Path.expand/1` before being prepended.
4547 """
4648 def prepend_path ( path ) do
4749 :code . add_patha ( Path . expand to_char_list ( path ) )
4850 end
4951
5052 @ doc """
51- Deletes a path from the Erlang VM code path.
53+ Delete a path from the Erlang VM code path.
54+
5255 The path is expanded with `Path.expand/1` before being deleted.
5356 """
5457 def delete_path ( path ) do
5558 :code . del_path ( Path . expand to_char_list ( path ) )
5659 end
5760
5861 @ doc """
59- Evaluates the contents given by `string`. The second argument is
60- a keyword list of variable bindings, followed by a keyword list of
61- environment options. Those options can be:
62+ Evaluate the contents given by `string`.
63+
64+ The `binding` argument is a keyword list of variable bindings.
65+ The `opts` argument is a keyword list of environment options.
66+
67+ Those options can be:
6268
6369 * `:file` - the file to be considered in the evaluation
6470 * `:line` - the line on which the script starts
@@ -88,8 +94,7 @@ defmodule Code do
8894
8995 `binding` is a keyword list with the value of all variable bindings
9096 after evaluating `string`. The binding key is usually an atom, but it
91- may be a tuple for variables defined in another contexts that are not
92- the main one.
97+ may be a tuple for variables defined in a different context.
9398
9499 ## Examples
95100
@@ -127,7 +132,7 @@ defmodule Code do
127132 end
128133
129134 @ doc """
130- Evaluates the quoted contents.
135+ Evaluate the quoted contents.
131136
132137 See `eval_string/3` for a description of arguments and return values.
133138
@@ -200,7 +205,9 @@ defmodule Code do
200205 end
201206
202207 @ doc """
203- Converts the given string to its quoted form. Returns `{ :ok, quoted_form }`
208+ Convert the given string to its quoted form.
209+
210+ Returns `{ :ok, quoted_form }`
204211 if it succeeds, `{ :error, { line, error, token } }` otherwise.
205212
206213 ## Options
@@ -213,10 +220,10 @@ defmodule Code do
213220 * `:existing_atoms_only` - When `true`, raises an error
214221 when non-existing atoms are found by the tokenizer.
215222
216- ## Macro.to_string/1
223+ ## Macro.to_string/2
217224
218225 The opposite of converting a string to its quoted form is
219- `Macro.to_string/1 `, which converts a quoted form to a string/binary
226+ `Macro.to_string/2 `, which converts a quoted form to a string/binary
220227 representation.
221228 """
222229 def string_to_quoted ( string , opts // [ ] ) when is_list ( opts ) do
@@ -231,7 +238,9 @@ defmodule Code do
231238 end
232239
233240 @ doc """
234- Converts the given string to its quoted form. It returns the ast if it succeeds,
241+ Convert the given string to its quoted form.
242+
243+ It returns the ast if it succeeds,
235244 raises an exception otherwise. The exception is a `TokenMissingError`
236245 in case a token is missing (usually because the expression is incomplete),
237246 `SyntaxError` otherwise.
@@ -250,7 +259,9 @@ defmodule Code do
250259 defp unpack_quote ( line , forms ) , do: { :__block__ , [ line: line ] , forms }
251260
252261 @ doc """
253- Loads the given `file`. Accepts `relative_to` as an argument to tell where
262+ Load the given file.
263+
264+ Accepts `relative_to` as an argument to tell where
254265 the file is located. If the file was already required/loaded, loads it again.
255266 It returns a list of tuples `{ ModuleName, <<byte_code>> }`, one tuple for each
256267 module defined in the file.
@@ -270,9 +281,11 @@ defmodule Code do
270281 end
271282
272283 @ doc """
273- Requires the given `file`. Accepts `relative_to` as an argument to tell where
284+ Require the given `file`.
285+
286+ Accepts `relative_to` as an argument to tell where
274287 the file is located. The return value is the same as that of `load_file/2`. If
275- the file was already required/loaded, doesn't do anything and returns nil.
288+ the file was already required/loaded, doesn't do anything and returns ` nil` .
276289
277290 Notice that if `require_file` is invoked by different processes concurrently,
278291 the first process to invoke `require_file` acquires a lock and the remaining
@@ -298,16 +311,18 @@ defmodule Code do
298311 end
299312
300313 @ doc """
301- Loads the compilation options from the code server.
314+ Load the compilation options from the code server.
315+
302316 Check `compiler_options/1` for more information.
303317 """
304318 def compiler_options do
305319 :elixir_code_server . call :compiler_options
306320 end
307321
308322 @ doc """
309- Sets compilation options. These options are global
310- since they are stored by Elixir's Code Server.
323+ Set compilation options.
324+
325+ These options are global since they are stored by Elixir's Code Server.
311326
312327 Available options are:
313328
@@ -316,7 +331,7 @@ defmodule Code do
316331
317332 * `:debug_info` - when `true`, retain debug information in the compiled module.
318333 This allows a developer to reconstruct the original source
319- code, for such reasons, `false` by default;
334+ code, `false` by default;
320335
321336 * `:ignore_module_conflict` - when `true`, override modules that were already defined
322337 without raising errors, `false` by default;
@@ -329,7 +344,9 @@ defmodule Code do
329344 end
330345
331346 @ doc """
332- Compiles the given string and returns a list of tuples where
347+ Compile the given string.
348+
349+ Returns a list of tuples where
333350 the first element is the module name and the second one is its
334351 binary.
335352
@@ -340,7 +357,9 @@ defmodule Code do
340357 end
341358
342359 @ doc """
343- Compiles the quoted expression and returns a list of tuples where
360+ Compile the quoted expression.
361+
362+ Returns a list of tuples where
344363 the first element is the module name and the second one is its
345364 binary.
346365 """
@@ -349,8 +368,10 @@ defmodule Code do
349368 end
350369
351370 @ doc """
352- Ensures the given module is loaded. If the module is already
353- loaded, it works as no-op. If the module was not yet loaded,
371+ Ensure the given module is loaded.
372+
373+ If the module is already
374+ loaded, this works as no-op. If the module was not yet loaded,
354375 it tries to load it.
355376
356377 If it succeeds loading the module, it returns
@@ -391,15 +412,19 @@ defmodule Code do
391412 end
392413
393414 @ doc """
394- Similar to `ensure_loaded/1`, but returns a boolean in case
395- it could be ensured or not.
415+ Ensure the given module is loaded.
416+
417+ Similar to `ensure_loaded/1`, but returns `true` if the module
418+ is already loaded or was successfully loaded. Returns `false` otherwise.
396419 """
397420 def ensure_loaded? ( module ) do
398421 match? ( { :module , ^ module } , ensure_loaded ( module ) )
399422 end
400423
401424 @ doc """
402- Ensures the given module is compiled and loaded. If the module
425+ Ensure the given module is compiled and loaded.
426+
427+ If the module
403428 is already loaded, it works as no-op. If the module was not
404429 loaded yet, it checks if it needs to be compiled first and
405430 then tries to load it.
@@ -429,8 +454,11 @@ defmodule Code do
429454 end
430455
431456 @ doc """
432- Similar to `ensure_compiled/1`, but returns a boolean in case
433- it could be ensured or not.
457+ Ensure the given module is compiled and loaded.
458+
459+ Similar to `ensure_compiled/1`, but returns `true` if the module
460+ is already loaded or was successfully loaded and compiled.
461+ Returns `false` otherwise.
434462 """
435463 def ensure_compiled? ( module ) do
436464 match? ( { :module , ^ module } , ensure_compiled ( module ) )
0 commit comments