Skip to content

Commit

Permalink
Compiler: missing docs for new methods. FIxes #3281
Browse files Browse the repository at this point in the history
  • Loading branch information
Ary Borenszweig committed Sep 9, 2016
1 parent 7cd0fa6 commit d1883fc
Showing 2 changed files with 2 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/compiler/crystal/semantic/new.cr
Original file line number Diff line number Diff line change
@@ -129,6 +129,8 @@ module Crystal
new_def.yields = yields
new_def.visibility = Visibility::Private if visibility.private?
new_def.new = true
new_def.location = location
new_def.doc = doc

# Forward block argument if any
if uses_block_arg?
21 changes: 0 additions & 21 deletions src/compiler/crystal/tools/doc/type.cr
Original file line number Diff line number Diff line change
@@ -196,33 +196,12 @@ class Crystal::Doc::Type
next
end

# Skip auto-generated new methods from initialize
if a_def.name == "new" && !a_def.location
next
end

if @generator.must_include? a_def
class_methods << method(a_def, true)
end
end
end
class_methods.sort_by! &.name.downcase

# Also get `initialize` methods from instance type,
# but show them as `new`
@type.metaclass.defs.try &.each_value do |defs_with_metadata|
defs_with_metadata.each do |def_with_metadata|
a_def = def_with_metadata.def
if a_def.name == "initialize" && @generator.must_include?(a_def)
initialize = a_def.clone
initialize.doc = a_def.doc
initialize.name = "new"
class_methods << method(initialize, true)
end
end
end

class_methods
end
end

0 comments on commit d1883fc

Please sign in to comment.