@@ -100,6 +100,16 @@ defmodule Mix.Tasks.Docs do
100
100
the "assets" directory in the output path under the name "cover" and the
101
101
appropriate extension. This option has no effect when using the "html" formatter.
102
102
103
+ * `:debug_info_key` - The key to be used to decrypt debug info that was encrypted during
104
+ compilation. This option will be ignored if `:debug_info_fn` or `:debug_info_fun` is provided.
105
+ See [Encrypted debug info](`m:Mix.Tasks.Docs#module-encrypted-debug-info`).
106
+
107
+ * `:debug_info_fn` / `:debug_info_fun` - A function that will be provided to
108
+ `:beam_lib.crypto_key_fun/1` to decrypt debug info that was encrypted during compilation. If
109
+ both `:debug_info_fn` and `:debug_info_fun` are provided, `:debug_info_fun` will be ignored.
110
+ If this option is provided, `:debug_info_key` will be ignored. See
111
+ [Encrypted debug info](`m:Mix.Tasks.Docs#module-encrypted-debug-info`).
112
+
103
113
* `:deps` - A keyword list application names and their documentation URL.
104
114
ExDoc will by default include all dependencies and assume they are hosted on
105
115
HexDocs. This can be overridden by your own values. Example: `[plug: "https://myserver/plug/"]`
@@ -200,6 +210,68 @@ defmodule Mix.Tasks.Docs do
200
210
where path is either an relative path from the cwd, or an absolute path. The function
201
211
must return the full URI as it should be placed in the documentation.
202
212
213
+ ## Encrypted debug info
214
+
215
+ If a module is compiled with [encrypted debug info](`:compile.file/2`), ExDoc will not be able to
216
+ extract its documentation without first setting a decryption function or utilizing
217
+ `.erlang.crypt` as prescribed by `m::beam_lib#module-encrypted-debug-information`. Two
218
+ convenience options (see below) are provided to avoid having to call `:beam_lib.crypto_key_fun/1`
219
+ out-of-band and/or to avoid using `.erlang.crypt`.
220
+
221
+ If you prefer to set the key out-of-band, follow the instructions provided in the
222
+ `m::beam_lib#module-encrypted-debug-information` module documentation.
223
+
224
+ > ### Key exposure {: .warning}
225
+ >
226
+ > Avoid adding keys directly to your `mix.exs` file. Instead, use an environment variable, an
227
+ > external documentation config file, or a
228
+ > [closure](https://erlef.github.io/security-wg/secure_coding_and_deployment_hardening/sensitive_data#wrapping).
229
+
230
+ ### `:debug_info_key`
231
+
232
+ This option can be provided if you only have one key for all encrypted modules. A `t:charlist/0`,
233
+ `t:String.t/0`, or tuple of `{:des3_cbc, charlist() | String.t()}` can be used.
234
+
235
+ ### `:debug_info_fn` / `:debug_info_fun`
236
+
237
+ This option can be provided if you have multiple keys, want more control over key retrieval, or
238
+ would like to wrap your key(s) in a closure. `:debug_info_key` will be ignored if this option is
239
+ also present. `:debug_info_fun` will be ignored if `:debug_info_fn` is already present.
240
+
241
+ While a module can be encrypted using a tuple key such as `{:des3_cbc, ~c"secret"}`, the function
242
+ that provides the key must return a regular charlist. In other words, the function should return
243
+ `~c"secret"`, not `{:des3_cbc, ~c"secret"}`.
244
+
245
+ A basic function that provides the decryption key `SECRET`:
246
+
247
+ <!-- tabs-open -->
248
+
249
+ ### Elixir
250
+
251
+ ⚠️ The key returned must be a `t:charlist/0`!
252
+
253
+ ```elixir
254
+ fn
255
+ :init -> :ok,
256
+ {:debug_info, _mode, _module, _filename} -> ~c"SECRET"
257
+ :clear -> :ok
258
+ end
259
+ ```
260
+
261
+ ### Erlang
262
+
263
+ ```erlang
264
+ fun
265
+ (init) -> ok;
266
+ ({debug_info, _Mode, _Module, _Filename}) -> "SECRET";
267
+ (clear) -> ok
268
+ end.
269
+ ```
270
+
271
+ <!-- tabs-close -->
272
+
273
+ See `:beam_lib.crypto_key_fun/1` for more information.
274
+
203
275
## Groups
204
276
205
277
ExDoc content can be organized in groups. This is done via the `:groups_for_extras`
0 commit comments