Skip to content

Commit 7962ebe

Browse files
Merge pull request #136 from alyst/condensed_fields
Condense $FIELDS template
2 parents a060e87 + 2cafbdc commit 7962ebe

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/abbreviations.jl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,9 @@ type `Vector{Any}`.
8181
8282
- `x::String`
8383
84-
- `y::Int`
84+
- `y::Int`: Unlike the `x` field this field has been documented.
8585
86-
Unlike the `x` field this field has been documented.
87-
88-
- `z::Array{Any, 1}`
89-
90-
Another documented field.
86+
- `z::Array{Any, 1}`: Another documented field.
9187
```
9288
"""
9389
const TYPEDFIELDS = TypeFields(true)
@@ -96,22 +92,20 @@ function format(abbrv::TypeFields, buf, doc)
9692
local docs = get(doc.data, :fields, Dict())
9793
local binding = doc.data[:binding]
9894
local object = Docs.resolve(binding)
99-
# On 0.7 fieldnames() on an abstract type throws an error. We then explicitly return
100-
# an empty vector to be consistent with the behaviour on v0.6.
10195
local fields = isabstracttype(object) ? Symbol[] : fieldnames(object)
10296
if !isempty(fields)
10397
println(buf)
10498
for field in fields
105-
if abbrv.types
106-
println(buf, " - `", field, "::", fieldtype(object, field), "`")
107-
else
108-
println(buf, " - `", field, "`")
109-
end
99+
print(buf, " - `", field)
100+
abbrv.types && print(buf, "::", fieldtype(object, field))
101+
println(buf, "`")
110102
# Print the field docs if they exist and aren't a `doc"..."` docstring.
111103
if haskey(docs, field) && isa(docs[field], AbstractString)
112-
println(buf)
104+
print(buf, ": ")
105+
indented = true
113106
for line in split(docs[field], "\n")
114-
println(buf, isempty(line) ? "" : " ", rstrip(line))
107+
println(buf, indented || isempty(line) ? "" : " ", rstrip(line))
108+
indented = false
115109
end
116110
end
117111
println(buf)

0 commit comments

Comments
 (0)