Skip to content

Commit d159e4f

Browse files
committed
Make option docs in IEx.Options visible to ExDoc
1 parent 8530694 commit d159e4f

File tree

1 file changed

+45
-27
lines changed

1 file changed

+45
-27
lines changed

lib/iex/lib/iex/options.ex

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,8 @@ defmodule IEx.Options do
3434
"""
3535

3636
@supported_options [
37-
colors: [
38-
doc: """
39-
This is an aggregate option that encapsulates all color settings used
40-
by the shell.
41-
42-
* enabled -- boolean value that allows for switching the coloring
43-
on and off
44-
45-
* eval_result -- color for an expression's resulting value
46-
* error -- color for error messages
47-
* info -- color for various informational messages
48-
* directory -- color for directory entries (ls helper)
49-
* device -- color for device entries (ls helper)
50-
51-
"""
52-
],
53-
inspect: [
54-
doc: """
55-
Control the behavior of the shell's inspecting algorithm. Inspect is
56-
used for printing results of evaluating expressions. It is also used by
57-
IO.inspect.
58-
59-
See the doc for `Kernel.inspect/2` for the full list of options.
60-
61-
"""
62-
],
37+
colors: [],
38+
inspect: [],
6339
]
6440

6541
@doc """
@@ -145,7 +121,15 @@ defmodule IEx.Options do
145121
"""
146122
def help(name) do
147123
case @supported_options[name] do
148-
kv when is_list(kv) -> kv[:doc]
124+
kv when is_list(kv) ->
125+
docs = __MODULE__.__info__(:docs)
126+
{ {_, _}, _, _, _, doc } = Enum.find docs, fn { {f, _}, _, _, _, _ } ->
127+
f == name
128+
end
129+
130+
# Strip the first paragraph
131+
String.lstrip(Regex.replace %r/\A.+?^$/ms, doc, "")
132+
149133
nil -> raise_option(name)
150134
end
151135
end
@@ -164,6 +148,40 @@ defmodule IEx.Options do
164148
Enum.map @supported_options, fn {k, _} -> k end
165149
end
166150

151+
@doc """
152+
**NOTE**: This is just a stub for documentation purposes. Use
153+
`IEx.Options.get` and `IEx.Options.set` to query and change the option's
154+
value.
155+
156+
This is an aggregate option that encapsulates all color settings used
157+
by the shell.
158+
159+
* enabled -- boolean value that allows for switching the coloring
160+
on and off
161+
162+
* eval_result -- color for an expression's resulting value
163+
* error -- color for error messages
164+
* info -- color for various informational messages
165+
* directory -- color for directory entries (ls helper)
166+
* device -- color for device entries (ls helper)
167+
168+
"""
169+
def colors
170+
171+
@doc """
172+
**NOTE**: This is just a stub for documentation purposes. Use
173+
`IEx.Options.get` and `IEx.Options.set` to query and change the option's
174+
value.
175+
176+
Control the behavior of the shell's inspecting algorithm. Inspect is
177+
used for printing results of expression evaluation. It is also used by
178+
IO.inspect.
179+
180+
See the doc for `Kernel.inspect/2` for the full list of options.
181+
182+
"""
183+
def inspect
184+
167185
defp raise_option(name) do
168186
raise ArgumentError, message: "Unknown IEx option #{inspect name}"
169187
end

0 commit comments

Comments
 (0)