@@ -35,11 +35,13 @@ Docs.formatdoc(buf::IOBuffer, doc::Docs.DocStr, part::Abbreviation) = format(par
35
35
#
36
36
37
37
"""
38
- The singleton type for [`FIELDS`](@ref) abbreviations.
38
+ The type for [`FIELDS`](@ref) abbreviations.
39
39
40
40
$(:FIELDS )
41
41
"""
42
- struct TypeFields <: Abbreviation end
42
+ struct TypeFields <: Abbreviation
43
+ types:: Bool
44
+ end
43
45
44
46
"""
45
47
An [`Abbreviation`](@ref) to include the names of the fields of a type as well as any
@@ -64,9 +66,33 @@ attached.
64
66
Another documented field.
65
67
```
66
68
"""
67
- const FIELDS = TypeFields ()
69
+ const FIELDS = TypeFields (false )
70
+
71
+ """
72
+ Identical to [`FIELDS`](@ref) except that it includes the field types.
73
+
74
+ # Examples
75
+
76
+ The generated markdown text should look similar to to following example where
77
+ a type has three fields; `x` of type `String`, `y` of type `Int`, and `z` of
78
+ type `Vector{Any}`.
79
+
80
+ ```markdown
81
+
82
+ - `x::String`
83
+
84
+ - `y::Int`
68
85
69
- function format (:: TypeFields , buf, doc)
86
+ Unlike the `x` field this field has been documented.
87
+
88
+ - `z::Array{Any, 1}`
89
+
90
+ Another documented field.
91
+ ```
92
+ """
93
+ const TYPEDFIELDS = TypeFields (true )
94
+
95
+ function format (abbrv:: TypeFields , buf, doc)
70
96
local docs = get (doc. data, :fields , Dict ())
71
97
local binding = doc. data[:binding ]
72
98
local object = Docs. resolve (binding)
@@ -76,7 +102,11 @@ function format(::TypeFields, buf, doc)
76
102
if ! isempty (fields)
77
103
println (buf)
78
104
for field in fields
79
- print (buf, " - `" , field, " `\n " )
105
+ if abbrv. types
106
+ println (buf, " - `" , field, " ::" , fieldtype (object, field), " `" )
107
+ else
108
+ println (buf, " - `" , field, " `" )
109
+ end
80
110
# Print the field docs if they exist and aren't a `doc"..."` docstring.
81
111
if haskey (docs, field) && isa (docs[field], AbstractString)
82
112
println (buf)
0 commit comments