-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
) (#15337)
- Loading branch information
1 parent
1c03dfa
commit 0da1746
Showing
7 changed files
with
154 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Crystal::Doc::Generator do | ||
context ":nodoc:" do | ||
it "hides documentation from being generated for methods" do | ||
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program | ||
class Foo | ||
# :nodoc: | ||
# | ||
# Some docs | ||
def foo | ||
end | ||
end | ||
CRYSTAL | ||
|
||
generator = Doc::Generator.new program, [""] | ||
generator.type(program.types["Foo"]).lookup_method("foo").should be_nil | ||
end | ||
|
||
it "hides documentation from being generated for classes" do | ||
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program | ||
# :nodoc: | ||
class Foo | ||
end | ||
CRYSTAL | ||
|
||
generator = Doc::Generator.new program, [""] | ||
generator.must_include?(program.types["Foo"]).should be_false | ||
end | ||
end | ||
|
||
context ":showdoc:" do | ||
it "shows documentation for private methods" do | ||
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program | ||
class Foo | ||
# :showdoc: | ||
# | ||
# Some docs | ||
private def foo | ||
end | ||
end | ||
CRYSTAL | ||
|
||
generator = Doc::Generator.new program, [""] | ||
a_def = generator.type(program.types["Foo"]).lookup_method("foo").not_nil! | ||
a_def.doc.should eq("Some docs") | ||
a_def.visibility.should eq("private") | ||
end | ||
|
||
it "does not include documentation for methods within a :nodoc: namespace" do | ||
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program | ||
# :nodoc: | ||
class Foo | ||
# :showdoc: | ||
# | ||
# Some docs | ||
private def foo | ||
end | ||
end | ||
CRYSTAL | ||
|
||
generator = Doc::Generator.new program, [""] | ||
|
||
# If namespace isn't included, don't need to check if the method is included | ||
generator.must_include?(program.types["Foo"]).should be_false | ||
end | ||
|
||
it "does not include documentation for private and protected methods and objects in a :showdoc: namespace" do | ||
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program | ||
# :showdoc: | ||
class Foo | ||
# Some docs for `foo` | ||
private def foo | ||
end | ||
# Some docs for `bar` | ||
protected def bar | ||
end | ||
# Some docs for `Baz` | ||
private class Baz | ||
end | ||
end | ||
CRYSTAL | ||
|
||
generator = Doc::Generator.new program, [""] | ||
|
||
generator.type(program.types["Foo"]).lookup_method("foo").should be_nil | ||
generator.type(program.types["Foo"]).lookup_method("bar").should be_nil | ||
|
||
generator.must_include?(generator.type(program.types["Foo"]).lookup_path("Baz")).should be_false | ||
end | ||
|
||
it "doesn't show a method marked :nodoc: within a :showdoc: namespace" do | ||
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program | ||
# :showdoc: | ||
class Foo | ||
# :nodoc: | ||
# Some docs for `foo` | ||
def foo | ||
end | ||
end | ||
CRYSTAL | ||
|
||
generator = Doc::Generator.new program, [""] | ||
generator.type(program.types["Foo"]).lookup_method("foo").should be_nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,10 @@ class Crystal::Doc::Macro | |
false | ||
end | ||
|
||
def visibility | ||
@type.visibility | ||
end | ||
|
||
def kind | ||
"macro " | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters