Skip to content

Commit e7a5ab7

Browse files
committed
Try harder to preserve information on structs
1 parent f3174eb commit e7a5ab7

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/docurium.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,24 @@ def update_globals!(data, recs)
503503

504504
when :struct, :fnptr
505505
data[:types][r[:name]] ||= {}
506+
known = data[:types][r[:name]]
506507
r[:value] ||= r[:name]
507-
wanted[:types].each do |k|
508-
next unless r.has_key? k
509-
if k == :comments
510-
data[:types][r[:name]][k] = md.render r[k]
511-
else
512-
data[:types][r[:name]][k] = r[k]
508+
# we don't want to override "opaque" structs with typedefs or
509+
# "public" documentation
510+
unless r[:tdef].nil? and known[:fields] and known[:comments] and known[:description]
511+
wanted[:types].each do |k|
512+
next unless r.has_key? k
513+
if k == :comments
514+
data[:types][r[:name]][k] = md.render r[k]
515+
else
516+
data[:types][r[:name]][k] = r[k]
517+
end
518+
end
519+
else
520+
# We're about to skip that type. Just make sure we preserve the
521+
# :fields comment
522+
if r[:fields] and known[:fields].empty?
523+
data[:types][r[:name]][:fields] = r[:fields]
513524
end
514525
end
515526
if r[:type] == :fnptr

0 commit comments

Comments
 (0)