Skip to content

Commit

Permalink
[doc] Remove superclass from ASTNode in API docs (#10664)
Browse files Browse the repository at this point in the history
  • Loading branch information
beta-ziliani authored May 18, 2021
1 parent d7e0f70 commit b9be7ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions spec/compiler/crystal/tools/doc/type_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,25 @@ describe Doc::Type do
foo = generator.type(program.types["Foo"])
foo.node_to_html("Foo".path(global: true)).should eq(%(<a href="Foo.html">Foo</a>))
end

it "ASTNode has no superclass" do
program = semantic(<<-CODE).program
module Crystal
module Macros
class ASTNode
end
class Arg < ASTNode
end
end
end
CODE

generator = Doc::Generator.new program, [""]
macros_module = program.types["Crystal"].types["Macros"]
astnode = generator.type(macros_module.types["ASTNode"])
astnode.superclass.should eq(nil)
# Sanity check: subclasses of ASTNode has the right superclass
generator.type(macros_module.types["Arg"]).superclass.should eq(astnode)
end
end
end
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/doc/type.cr
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Crystal::Doc::Type
def superclass
case type = @type
when ClassType
superclass = type.superclass
superclass = type.superclass unless type.full_name == Crystal::Macros::ASTNode.name
when GenericClassInstanceType
superclass = type.superclass
end
Expand Down

0 comments on commit b9be7ff

Please sign in to comment.