File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ accessible information.
8
8
Below is the final code generated by the plugin, which includes comprehensive
9
9
documentation for the ` User ` struct:
10
10
11
- ```
11
+ ``` elixir
12
12
defmodule User do
13
13
@typedoc """
14
14
@type t(age) :: %User{age: age | nil, name: String.t() | nil}
33
33
```
34
34
35
35
## Implement
36
+
36
37
``` elixir
37
38
defmodule Guides .Plugins .DocFields do
38
39
@moduledoc """
@@ -115,11 +116,12 @@ defmodule Guides.Plugins.DocFields do
115
116
fields =
116
117
Enum .map (definition.fields, fn field ->
117
118
name = Keyword .fetch! (field, :name )
118
-
119
119
type = Keyword .fetch! (field, :type )
120
120
121
+ enforce = Keyword .get (definition.options, :enforce , false )
122
+
121
123
type =
122
- if Keyword .get (field, :enforce , false ) or Keyword .has_key? (field, :default ) do
124
+ if Keyword .get (field, :enforce , enforce ) or Keyword .has_key? (field, :default ) do
123
125
Macro .to_string (type)
124
126
else
125
127
# escape `|`
164
166
```
165
167
166
168
## Usage
169
+
167
170
``` elixir
168
171
defmodule User do
169
172
@moduledoc false
You can’t perform that action at this time.
0 commit comments