@@ -115,13 +115,13 @@ defmodule Module do
115
115
116
116
### Example
117
117
118
- defmodule M do
119
- @compile {:inline, myfun: 1}
118
+ defmodule M do
119
+ @compile {:inline, myfun: 1}
120
120
121
- def myfun(arg) do
122
- to_string(arg)
123
- end
121
+ def myfun(arg) do
122
+ to_string(arg)
124
123
end
124
+ end
125
125
126
126
* `@doc`
127
127
@@ -136,19 +136,19 @@ defmodule Module do
136
136
137
137
### Example
138
138
139
- defmodule M do
140
- @doc "Hello world"
141
- def hello do
142
- "world"
143
- end
139
+ defmodule M do
140
+ @doc "Hello world"
141
+ def hello do
142
+ "world"
143
+ end
144
144
145
- @doc """
146
- Sums `a` to `b`.
147
- """
148
- def sum(a, b) do
149
- a + b
150
- end
145
+ @doc """
146
+ Sums `a` to `b`.
147
+ """
148
+ def sum(a, b) do
149
+ a + b
151
150
end
151
+ end
152
152
153
153
* `@file`
154
154
@@ -159,13 +159,13 @@ defmodule Module do
159
159
160
160
### Example
161
161
162
- defmodule M do
163
- @doc "Hello world"
164
- @file "hello.ex"
165
- def hello do
166
- "world"
167
- end
162
+ defmodule M do
163
+ @doc "Hello world"
164
+ @file "hello.ex"
165
+ def hello do
166
+ "world"
168
167
end
168
+ end
169
169
170
170
* `@moduledoc`
171
171
@@ -177,11 +177,11 @@ defmodule Module do
177
177
178
178
### Example
179
179
180
- defmodule M do
181
- @moduledoc """
182
- A very useful module
183
- """
184
- end
180
+ defmodule M do
181
+ @moduledoc """
182
+ A very useful module
183
+ """
184
+ end
185
185
186
186
187
187
* `@on_definition`
@@ -216,28 +216,28 @@ defmodule Module do
216
216
217
217
### Example
218
218
219
- defmodule H do
220
- def on_def(_env, kind, name, args, guards, body) do
221
- IO.puts "Defining #{kind} named #{name} with args:"
222
- IO.inspect args
223
- IO.puts "and guards"
224
- IO.inspect guards
225
- IO.puts "and body"
226
- IO.puts Macro.to_string(body)
227
- end
219
+ defmodule H do
220
+ def on_def(_env, kind, name, args, guards, body) do
221
+ IO.puts "Defining #{kind} named #{name} with args:"
222
+ IO.inspect args
223
+ IO.puts "and guards"
224
+ IO.inspect guards
225
+ IO.puts "and body"
226
+ IO.puts Macro.to_string(body)
228
227
end
228
+ end
229
229
230
- defmodule M do
231
- @on_definition {H, :on_def}
230
+ defmodule M do
231
+ @on_definition {H, :on_def}
232
232
233
- def hello(arg) when is_binary(arg) or is_list(arg) do
234
- "Hello" <> to_string(arg)
235
- end
233
+ def hello(arg) when is_binary(arg) or is_list(arg) do
234
+ "Hello" <> to_string(arg)
235
+ end
236
236
237
- def hello(_) do
238
- :ok
239
- end
237
+ def hello(_) do
238
+ :ok
240
239
end
240
+ end
241
241
242
242
* `@on_load`
243
243
@@ -249,31 +249,31 @@ defmodule Module do
249
249
250
250
### Example
251
251
252
- defmodule M do
253
- @on_load :load_check
252
+ defmodule M do
253
+ @on_load :load_check
254
254
255
- def load_check do
256
- if some_condition() do
257
- :ok
258
- else
259
- nil
260
- end
255
+ def load_check do
256
+ if some_condition() do
257
+ :ok
258
+ else
259
+ nil
261
260
end
261
+ end
262
262
263
- def some_condition do
264
- false
265
- end
263
+ def some_condition do
264
+ false
266
265
end
266
+ end
267
267
268
268
* `@vsn`
269
269
270
270
Specify the module version. Accepts any valid Elixir value.
271
271
272
272
### Example
273
273
274
- defmodule M do
275
- @vsn "1.0"
276
- end
274
+ defmodule M do
275
+ @vsn "1.0"
276
+ end
277
277
278
278
* `@external_resource`
279
279
@@ -301,13 +301,13 @@ defmodule Module do
301
301
302
302
### Example
303
303
304
- defmodule M do
305
- @dialyzer {:nowarn_function, myfun: 1}
304
+ defmodule M do
305
+ @dialyzer {:nowarn_function, myfun: 1}
306
306
307
- def myfun(arg) do
308
- M.not_a_function(arg)
309
- end
307
+ def myfun(arg) do
308
+ M.not_a_function(arg)
310
309
end
310
+ end
311
311
312
312
The following attributes are part of typespecs and are also reserved by
313
313
Elixir (see `Kernel.Typespec` for more information about typespecs):
@@ -323,9 +323,9 @@ defmodule Module do
323
323
also be added. A custom attribute is any valid identifier prefixed with an
324
324
`@` and followed by a valid Elixir value:
325
325
326
- defmodule M do
327
- @custom_attr [some: "stuff"]
328
- end
326
+ defmodule M do
327
+ @custom_attr [some: "stuff"]
328
+ end
329
329
330
330
For more advanced options available when defining custom attributes, see
331
331
`register_attribute/3`.
0 commit comments