Skip to content

Commit

Permalink
Add simplified constructor for Doc::Generator
Browse files Browse the repository at this point in the history
This is useful for specs where all the configuration options are
irrelevant.
  • Loading branch information
straight-shoota committed Oct 29, 2019
1 parent e759ded commit 4c39e5a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 51 deletions.
38 changes: 19 additions & 19 deletions spec/compiler/crystal/tools/doc/generator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ describe Doc::Generator do
describe "#must_include_toplevel?" do
it "returns false if program has nothing" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

generator.must_include_toplevel?(doc_type).should be_false
end

it "returns true if program has constant" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

constant = Const.new program, program, "Foo", 1.int32
Expand All @@ -24,7 +24,7 @@ describe Doc::Generator do

it "returns false if program has constant which is defined in other place" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

constant = Const.new program, program, "Foo", 1.int32
Expand All @@ -36,7 +36,7 @@ describe Doc::Generator do

it "returns true if program has macro" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo"
Expand All @@ -48,7 +48,7 @@ describe Doc::Generator do

it "returns false if program has macro which is defined in other place" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo"
Expand All @@ -60,7 +60,7 @@ describe Doc::Generator do

it "returns true if program has method" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -72,7 +72,7 @@ describe Doc::Generator do

it "returns false if program has method which is defined in other place" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -86,7 +86,7 @@ describe Doc::Generator do
describe "#collect_constants" do
it "returns empty array when constants are private" do
program = Program.new
generator = Doc::Generator.new program, ["foo"], ".", "html", nil
generator = Doc::Generator.new program, ["foo"]
doc_type = Doc::Type.new generator, program

constant = Const.new program, program, "Foo", 1.int32
Expand All @@ -102,7 +102,7 @@ describe Doc::Generator do
describe "with a Deprecated annotation, and no docs" do
it "should generate just the Deprecated tag" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -115,7 +115,7 @@ describe Doc::Generator do
describe "with a Deprecated annotation, and docs" do
it "should generate both the docs and Deprecated tag" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -129,7 +129,7 @@ describe Doc::Generator do
describe "with no annotation, and no docs" do
it "should generate nothing" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -140,7 +140,7 @@ describe Doc::Generator do

it "should generate the first sentence" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -151,7 +151,7 @@ describe Doc::Generator do

it "should generate the first line" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -165,7 +165,7 @@ describe Doc::Generator do
describe "with a Deprecated annotation, and no docs" do
it "should generate just the Deprecated tag" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -178,7 +178,7 @@ describe Doc::Generator do
describe "with a Deprecated annotation, and docs" do
it "should generate both the docs and Deprecated tag" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -192,7 +192,7 @@ describe Doc::Generator do
describe "with no annotation, and no docs" do
it "should generate nothing" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -203,7 +203,7 @@ describe Doc::Generator do

it "should generate the full document" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -214,7 +214,7 @@ describe Doc::Generator do

it "should generate the full document" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_def = Def.new "foo"
Expand All @@ -227,7 +227,7 @@ describe Doc::Generator do
describe "crystal repo" do
it "inserts pseudo methods" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."], "."
doc_type = Doc::Type.new generator, program
generator.is_crystal_repo = true

Expand Down
22 changes: 11 additions & 11 deletions spec/compiler/crystal/tools/doc/macro_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe Doc::Macro do
describe "args_to_s" do
it "shows simple args" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg, "bar".arg]
Expand All @@ -14,7 +14,7 @@ describe Doc::Macro do

it "shows splat arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg], splat_index: 0
Expand All @@ -24,7 +24,7 @@ describe Doc::Macro do

it "shows simple arg and splat arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg, "bar".arg], splat_index: 1
Expand All @@ -34,7 +34,7 @@ describe Doc::Macro do

it "shows double splat arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", double_splat: "foo".arg
Expand All @@ -44,7 +44,7 @@ describe Doc::Macro do

it "shows double splat arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", double_splat: "foo".arg
Expand All @@ -54,7 +54,7 @@ describe Doc::Macro do

it "shows simple arg and double splat arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg], double_splat: "bar".arg
Expand All @@ -64,7 +64,7 @@ describe Doc::Macro do

it "shows block arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", block_arg: "foo".arg
Expand All @@ -74,7 +74,7 @@ describe Doc::Macro do

it "shows simple arg and block arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg], block_arg: "bar".arg
Expand All @@ -84,7 +84,7 @@ describe Doc::Macro do

it "shows external name of arg" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg(external_name: "bar")]
Expand All @@ -94,7 +94,7 @@ describe Doc::Macro do

it "shows external name of arg with quotes and escaping" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg(external_name: "<<-< uouo fish life")]
Expand All @@ -104,7 +104,7 @@ describe Doc::Macro do

it "shows default value with highlighting" do
program = Program.new
generator = Doc::Generator.new program, ["."], ".", "html", nil
generator = Doc::Generator.new program, ["."]
doc_type = Doc::Type.new generator, program

a_macro = Macro.new "foo", ["foo".arg(default_value: 1.int32)]
Expand Down
Loading

0 comments on commit 4c39e5a

Please sign in to comment.