@@ -2,7 +2,7 @@ import Kernel, except: [to_string: 1]
22
33defmodule Macro do
44 @ moduledoc """
5- This module provides conveniences for working with macros.
5+ Conveniences for working with macros.
66 """
77
88 @ typedoc "Abstract Syntax Tree (AST) node"
@@ -49,8 +49,9 @@ defmodule Macro do
4949 end
5050
5151 @ doc """
52- Breaks a pipeline expression into a list. Raises if
53- the pipeline is ill-formed.
52+ Breaks a pipeline expression into a list.
53+
54+ Raises if the pipeline is ill-formed.
5455 """
5556 @ spec unpipe ( Macro . t ) :: [ Macro . t ]
5657 def unpipe ( { :|> , _ , [ left , right ] } ) do
@@ -62,7 +63,7 @@ defmodule Macro do
6263 end
6364
6465 @ doc """
65- Pipes the given `expr` in to the `call_expr` as the
66+ Pipes `expr` into the `call_expr` as the
6667 argument in the given `position`.
6768 """
6869 @ spec pipe ( Macro . t , Macro . t , integer ) :: Macro . t | no_return
@@ -125,7 +126,7 @@ defmodule Macro do
125126 into a syntax tree.
126127
127128 One may pass `unquote: true` to `escape/2`
128- which leaves unquote statements unescaped, effectively
129+ which leaves ` unquote` statements unescaped, effectively
129130 unquoting the contents on escape.
130131
131132 ## Examples
@@ -147,7 +148,9 @@ defmodule Macro do
147148 end
148149
149150 @ doc % S """
150- Unescape the given chars. This is the unescaping behavior
151+ Unescape the given chars.
152+
153+ This is the unescaping behavior
151154 used by default in Elixir single- and double-quoted strings.
152155 Check `unescape_string/2` for information on how to customize
153156 the escaping map.
@@ -157,7 +160,7 @@ defmodule Macro do
157160 also escaped according to the latin1 set they represent.
158161
159162 This function is commonly used on sigil implementations
160- (like `%r`, `%b ` and others) which receive a raw, unescaped
163+ (like `%r`, `%s ` and others) which receive a raw, unescaped
161164 string.
162165
163166 ## Examples
@@ -166,7 +169,7 @@ defmodule Macro do
166169 "example\n "
167170
168171 In the example above, we pass a string with `\n ` escaped
169- and we return a version with it unescaped.
172+ and return a version with it unescaped.
170173 """
171174 @spec unescape_string( String. t ) :: String . t
172175 def unescape_string ( chars ) do
@@ -175,13 +178,14 @@ defmodule Macro do
175178
176179 @ doc % S """
177180 Unescape the given chars according to the map given.
181+
178182 Check `unescape_string/1` if you want to use the same map
179183 as Elixir single- and double-quoted strings.
180184
181185 ## Map
182186
183187 The map must be a function. The function receives an integer
184- representing the number of the characters it wants to unescape.
188+ representing the codepoint of the character it wants to unescape.
185189 Here is the default mapping function implemented by Elixir:
186190
187191 def unescape_map(?a), do: ?\a
@@ -202,16 +206,16 @@ defmodule Macro do
202206 ## Octals
203207
204208 Octals will by default be escaped unless the map function
205- returns false for ?0 .
209+ returns ` false` for `?0` .
206210
207211 ## Hex
208212
209213 Hexadecimals will by default be escaped unless the map function
210- returns false for ?x .
214+ returns ` false` for `?x` .
211215
212216 ## Examples
213217
214- Using the unescape_map defined above is easy:
218+ Using the ` unescape_map` function defined above is easy:
215219
216220 Macro.unescape_string "example\\ n", &unescape_map(&1)
217221
@@ -223,12 +227,13 @@ defmodule Macro do
223227
224228 @ doc """
225229 Unescape the given tokens according to the default map.
230+
226231 Check `unescape_string/1` and `unescape_string/2` for more
227232 information about unescaping.
228233
229234 Only tokens that are binaries are unescaped, all others are
230235 ignored. This function is useful when implementing your own
231- sigils. Check the implementation of `Kernel.sigil_b `
236+ sigils. Check the implementation of `Kernel.sigil_s/2 `
232237 for examples.
233238 """
234239 @spec unescape_tokens( [ Macro . t ] ) :: [ Macro . t ]
@@ -238,6 +243,7 @@ defmodule Macro do
238243
239244 @ doc """
240245 Unescape the given tokens according to the given map.
246+
241247 Check `unescape_tokens/1` and `unescape_string/2` for more information.
242248 """
243249 @spec unescape_tokens( [ Macro . t ] , ( non_neg_integer -> non_neg_integer | false ) ) :: [ Macro . t ]
@@ -473,18 +479,19 @@ defmodule Macro do
473479 end
474480
475481 @ doc """
476- Receives a AST node and expands it once. The following contents are expanded:
482+ Receives an AST node and expands it once.
483+
484+ The following contents are expanded:
477485
478486 * Macros (local or remote);
479487 * Aliases are expanded (if possible) and return atoms;
480488 * All pseudo-variables (`__FILE__`, `__MODULE__`, etc);
481489 * Module attributes reader (`@foo`);
482490
483- In case the expression cannot be expanded, it returns the expression
491+ If the expression cannot be expanded, it returns the expression
484492 itself. Notice that `expand_once/2` performs the expansion just
485493 once and it is not recursive. Check `expand/2` for expansion
486- until the node no longer represents a macro and `expand_all/2`
487- for recursive expansion.
494+ until the node no longer represents a macro.
488495
489496 ## Examples
490497
@@ -529,7 +536,7 @@ defmodule Macro do
529536 end
530537
531538 The final module name will be `MyHelpers.Module` and not
532- `My.Module`. With `Macro.expand`, such aliases are taken
539+ `My.Module`. With `Macro.expand/2 `, such aliases are taken
533540 into consideration. Local and remote macros are also
534541 expanded. We could rewrite our macro above to use this
535542 function as:
@@ -653,9 +660,11 @@ defmodule Macro do
653660 end
654661
655662 @ doc """
656- Receives a AST node and expands it until it no longer represents
657- a macro. Check `expand_once/2` for more information on how
658- expansion works and `expand_all/2` for recursive expansion.
663+ Receives an AST node and expands it until it no longer represents
664+ a macro.
665+
666+ Check `expand_once/2` for more information on how
667+ expansion works.
659668 """
660669 def expand ( tree , env ) do
661670 elem ( expand ( tree , env , nil ) , 0 )
@@ -700,9 +709,11 @@ defmodule Macro do
700709 end
701710
702711 @ doc """
703- Recurs the quoted expression checking if all sub-terms are
704- safe (i.e. they represent data structures and don't actually
705- evaluate code) and returns `:ok` unless a given term is unsafe,
712+ Recursively traverses the quoted expression checking if all sub-terms are
713+ safe.
714+
715+ Terms are considered safe if they represent data structures and don't actually
716+ evaluate code. Returns `:ok` unless a given term is unsafe,
706717 which is returned as `{ :unsafe, term }`.
707718 """
708719 def safe_term ( terms ) do
0 commit comments