Skip to content

Commit 3f3e86d

Browse files
committed
Document __info__/1
1 parent 15bf0fb commit 3f3e86d

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

lib/elixir/lib/module.ex

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,38 @@ defmodule Module do
266266
267267
## Runtime information about a module
268268
269-
__info__
270-
271-
... (as yet unwritten content) ...
269+
It is possible to query a module at runtime to find out which functions and
270+
macros it defines, extract its docstrings, etc. See `__info__/1`.
272271
273272
'''
274273

274+
@doc """
275+
Provides runtime information about functions and macros defined by the
276+
module, enables docstring extraction, etc.
277+
278+
Each module gets an `__info__/1` function when it's compiled. The function
279+
takes one of the following atoms:
280+
281+
* `:functions` - keyword list of public functions along with their arities
282+
283+
* `:macros` - keyword list of public macros along with their arities
284+
285+
* `:docs` - list of all docstrings attached to functions and macros
286+
using the `@doc` attribute
287+
288+
* `:moduledoc` - tuple `{ <line>, <doc> }` where `line` is the line on
289+
which module definition starts and `doc` is the string
290+
attached to the module using the `@moduledoc` attribute
291+
292+
* `:module` - module name (`Module == Module.__info__(:module)`)
293+
294+
In addition to the above, you may also pass to `__info__/1` any atom supported
295+
by Erlang's `module_info` function which also gets defined for each compiled
296+
module. See http://erlang.org/doc/reference_manual/modules.html#id74571 for
297+
more information.
298+
"""
299+
def __info__(kind)
300+
275301
@doc """
276302
Check if a module is open, i.e. it is currently being defined
277303
and its attributes and functions can be modified.

0 commit comments

Comments
 (0)