rdtool-0.6.38/0000755000004100000410000000000012057274011013142 5ustar www-datawww-datardtool-0.6.38/test/0000755000004100000410000000000012057274011014121 5ustar www-datawww-datardtool-0.6.38/test/test-search-file.rb0000755000004100000410000000124212057274011017607 0ustar www-datawww-datarequire 'test/unit' require 'rd/search-file' include RD class TestSearchFile < Test::Unit::TestCase include SearchFile def test_search_file include_path = ["test/data/sub", "test/data"] suffixes = ["xhtml", "html"] assert_equal("test/data/includee1.html", search_file("includee1", include_path, suffixes)) assert_equal("test/data/sub/includee2.html", search_file("includee2", include_path, suffixes)) assert_equal(nil, search_file("includee3", include_path, suffixes)) assert_equal("test/data/sub/includee4.html", search_file("includee4", include_path, suffixes)) end end rdtool-0.6.38/test/test-tree.rb0000755000004100000410000000377412057274011016400 0ustar www-datawww-datarequire 'test/unit' require 'rd/tree' require 'rd/element' require 'rd/rd-struct' require 'rd/loose-struct' include RD class TestTree < Test::Unit::TestCase def test_new_with_document_struct tr = Tree.new_with_document_struct(DocumentStructure::RD, ["test/data"]) assert_equal(nil, tr.root) assert_equal(["test/data"], tr.include_paths) end def test_set_root tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.set_root(de) assert_equal(de, tr.root) assert_equal(tr, de.tree) end def test_each_element tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.root = de exp = [de] i = 0 tr.each_element do |b| assert_equal(exp[i], b) end tr_emp = Tree.new_with_document_struct(DocumentStructure::RD) assert_equal(nil, tr_emp.each_element) end def test_make_root tr = Tree.new_with_document_struct(DocumentStructure::RD) res = tr.make_root assert(tr.root) assert_equal(tr.root, res) tr2 = Tree.new_with_document_struct(DocumentStructure::RD) res2 = tr2.make_root do new TextBlock end assert(tr2.root) assert_equal("\n ", tr2.root.inspect) assert_equal(tr2.root, res2) end def test_check_valid tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.root = de de.build do new Headline, 1 do new StringElement, "label" end new TextBlock do new Emphasis do new StringElement, "emphasis" end end end assert_equal(true, tr.check_valid) tr_fail = Tree.new_with_document_struct(DocumentStructure::RD) de_fail = DocumentElement.new tr_fail.root = de_fail tb_fail = TextBlock.new tb_fail.build(DocumentStructure::LOOSE) do new Headline, 1 end de_fail.add_child(tb_fail) assert_raises(RuntimeError) do tr_fail.check_valid end end end rdtool-0.6.38/test/test-methodlist-item.rb0000755000004100000410000000476512057274011020552 0ustar www-datawww-datarequire 'test/unit' require 'rd/methodlist' require 'rd/rd-struct' include RD class TestMethodListItem < Test::Unit::TestCase def test_set_term p = MethodListItem.new c = MethodListItem::Term.new p.set_term_under_document_struct(c, DocumentStructure::RD) assert_equal(c, p.term) assert_equal(p, c.parent) end def test_make_term tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.root = de di, dt = nil de.build do new MethodList do di = new MethodListItem do dt = make_term end end end assert_equal("\n ", di.inspect) assert_equal(di.term, dt) end def test_inspect mi = MethodListItem.new mt = MethodListItem::Term.new se = StringElement.new "string" tb = TextBlock.new mi.set_term_under_document_struct(mt, DocumentStructure::RD) mi.add_child_under_document_struct(tb, DocumentStructure::RD) assert_equal("\n \n" + " ", mi.inspect) mi_no_desc = MethodListItem.new mt_no_desc = MethodListItem::Term.new mi_no_desc.set_term_under_document_struct(mt_no_desc, DocumentStructure::RD) assert_equal("\n ", mi_no_desc.inspect) mi_no_term = MethodListItem.new mi_no_term.add_child_under_document_struct(TextBlock.new, DocumentStructure::RD) assert_equal("\n ", mi_no_term.inspect) assert_equal("", MethodListItem.new.inspect) end end class TestMethodListItemTerm < Test::Unit::TestCase def test_to_label assert_equal("", MethodListItem::Term.new.to_label) assert_equal("foo", MethodListItem::Term.new("foo").to_label) assert_equal("foo", MethodListItem::Term.new("foo()").to_label) assert_equal("foo", MethodListItem::Term.new("foo(arg)").to_label) assert_equal("Foo#foo", MethodListItem::Term.new("Foo#foo(arg)").to_label) assert_equal("Foo::foo", MethodListItem::Term.new("Foo::foo(arg)").to_label) assert_equal("foo", MethodListItem::Term.new("foo{|arg| ...}").to_label) assert_equal("foo", MethodListItem::Term.new("foo(arg){|arg| ...}").to_label) assert_equal("foo", MethodListItem::Term.new("foo (arg)").to_label) end end rdtool-0.6.38/test/test-desclist-item.rb0000755000004100000410000001344112057274011020177 0ustar www-datawww-datarequire 'test/unit' require 'rd/desclist' require 'rd/rd-struct' include RD class TestDescListItem < Test::Unit::TestCase def setup @flat = DescListItem.new @t1 = DescListItem::Term.new @flat.set_term_under_document_struct(@t1, DocumentStructure::RD) @c1 = TextBlock.new @c2 = ItemList.new @flat.add_children_under_document_struct([@c1, @c2], DocumentStructure::RD) @nest = DescListItem.new @t2 = DescListItem::Term.new @t21 = StringElement.new "" @t2.add_child_under_document_struct(@t21, DocumentStructure::RD) @nest.set_term_under_document_struct(@t2, DocumentStructure::RD) @d1 = TextBlock.new @d11 = StringElement.new "" @d1.add_child_under_document_struct(@d11, DocumentStructure::RD) @nest.add_children_under_document_struct([@d1], DocumentStructure::RD) end def test_set_term_under_docment_struct t = DescListItem::Term.new i = DescListItem.new i.set_term_under_document_struct(t, DocumentStructure::RD) assert_equal(t, i.term) assert_equal(i, t.parent) assert_raises(ArgumentError) do t = StringElement.new "" DescListItem.new.set_term_under_document_struct(t, DocumentStructure::RD) end end def test_assign_term desclist = DescListItem.new term = DescListItem::Term.new desclist.assign_term(term) assert_equal(term, desclist.term) assert_equal(desclist, term.parent) end def test_set_term_without_document_strcut desclist = DescListItem.new term = DescListItem::Term.new desclist.set_term_without_document_struct(term) assert_equal(term, desclist.term) assert_equal(desclist, term.parent) not_term = StringElement.new "not term" desclist.set_term_without_document_struct(not_term) assert_equal(not_term, desclist.term) assert_equal(desclist, not_term.parent) end def test_each_block_in_description exp = [@c1, @c2] i = 0 @flat.each_block_in_description do |b| assert_equal(exp[i], b) i += 1 end exp = [@d1] i = 0 @nest.each_block_in_description do |b| assert_equal(exp[i], b) i += 1 end end def test_each_element exp = [@flat, @t1, @c1, @c2] i = 0 @flat.each_element do |b| assert_equal(exp[i], b) i += 1 end exp = [@nest, @t2, @t21, @d1, @d11] i = 0 @nest.each_element do |b| assert_equal(exp[i], b) i += 1 end end def test_make_term tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.root = de di, dt = nil de.build do new DescList do di = new DescListItem do dt = make_term do new StringElement, "string" end end end end assert_equal("\n \n" + " ", di.inspect) assert_equal(di.term, dt) tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.root = de di, dt = nil de.build do new DescList do di = new DescListItem do dt = make_term end end end assert_equal(di.term, dt) end def test_inspect di = DescListItem.new dt = DescListItem::Term.new se = StringElement.new "string" tb = TextBlock.new di.set_term_under_document_struct(dt, DocumentStructure::RD) di.add_child_under_document_struct(tb, DocumentStructure::RD) dt.add_child_under_document_struct(se, DocumentStructure::RD) assert_equal("\n \n" + " \n ", di.inspect) di_no_desc = DescListItem.new dt_no_desc = DescListItem::Term.new di_no_desc.set_term_under_document_struct(dt_no_desc, DocumentStructure::RD) assert_equal("\n ", di_no_desc.inspect) di_no_term = DescListItem.new di_no_term.add_child_under_document_struct(TextBlock.new, DocumentStructure::RD) assert_equal("\n ", di_no_term.inspect) assert_equal("", DescListItem.new.inspect) end end class TestDescListItemTerm < Test::Unit::TestCase def setup @flat = DescListItem::Term.new @c1 = StringElement.new "aaa" @c2 = Emphasis.new @c3 = StringElement.new " bbb" @flat.add_children_under_document_struct([@c1, @c2, @c3], DocumentStructure::RD) @nest = DescListItem::Term.new @d1 = StringElement.new "aaa" @d2 = Emphasis.new @d21 = StringElement.new " bbb" @d2.add_child_under_document_struct(@d21, DocumentStructure::RD) @nest.add_children_under_document_struct([@d1, @d2], DocumentStructure::RD) @empty = DescListItem::Term.new end def test_each_child exp = [@c1, @c2, @c3] i = 0 @flat.each_child do |b| assert_equal(exp[i], b) i += 1 end exp = [@d1, @d2] i = 0 @nest.each_child do |b| assert_equal(exp[i], b) i += 1 end end def test_each_element exp = [@flat, @c1, @c2, @c3] i = 0 @flat.each_element do |b| assert_equal(exp[i], b) i += 1 end exp = [@nest, @d1, @d2, @d21] i = 0 @nest.each_element do |b| assert_equal(exp[i], b) i += 1 end exp = [@empty] i = 0 @empty.each_element do |b| assert_equal(exp[i], b) i += 1 end end def test_to_label assert_equal("aaa bbb", @flat.to_label) assert_equal("aaabbb", @nest.to_label) assert_equal("", @empty.to_label) end end rdtool-0.6.38/test/test-textblock.rb0000755000004100000410000000213112057274011017422 0ustar www-datawww-datarequire 'test/unit' require 'rd/block-element' require 'rd/inline-element' require 'rd/rd-struct' include RD class TestTextBlock < Test::Unit::TestCase def setup @p = TextBlock.new @c1 = StringElement.new "string" @c2 = Emphasis.new @c21 = StringElement.new "in emphasis" @c2.add_child_under_document_struct(@c21, DocumentStructure::RD) @c3 = Code.new @c31 = StringElement.new "code" @c32 = Var.new @c321 = StringElement.new "var" @c32.add_child_under_document_struct(@c321, DocumentStructure::RD) @c3.add_children_under_document_struct([@c31, @c32], DocumentStructure::RD) @c4 = Verb.new "verb" @p.add_children_under_document_struct([@c1, @c2, @c3, @c4], DocumentStructure::RD) end def test_each_child exp = [@c1, @c2, @c3, @c4] i = 0 @p.each_child do |b| assert_equal(exp[i], b) i += 1 end end def test_each_element exp = [@p, @c1, @c2, @c21, @c3, @c31, @c32, @c321, @c4] i = 0 @p.each_element do |b| assert_equal(exp[i], b) i += 1 end end end rdtool-0.6.38/test/test-reference-resolver.rb0000755000004100000410000001465412057274011021235 0ustar www-datawww-datarequire 'test/unit' require 'temp-dir' require 'rd/reference-resolver' require 'rd/tree' require 'rd/rd-struct' include RD class TestReferenceResolver < Test::Unit::TestCase def setup @tr_head1 = Tree.new_with_document_struct(DocumentStructure::RD) @de_head1 = DocumentElement.new @tr_head1.root = @de_head1 hl_head1 = nil se_head1 = nil @de_head1.build do hl_head1 = new Headline, 1 do se_head1 = new StringElement, "label" end end @hl_head1 = hl_head1 @se_head1 = se_head1 @tr_head2 = Tree.new_with_document_struct(DocumentStructure::RD) @de_head2 = DocumentElement.new @tr_head2.root = @de_head2 hl1_head2, hl2_head2 = nil @de_head2.build do hl1_head2 = new Headline, 1 do new StringElement, "label1" end new TextBlock hl2_head2 = new Headline, 2 do new StringElement, "label2" end end @hl1_head2 = hl1_head2 @hl2_head2 = hl2_head2 @tr_desc = Tree.new_with_document_struct(DocumentStructure::RD) @de_desc = DocumentElement.new @tr_desc.root = @de_desc hl1_desc, dt1_desc = nil @de_desc.build do hl1_desc = new(Headline, 1) do new StringElement, "label1" end new DescList do new DescListItem do dt1_desc = make_term do new StringElement, "label2" end end end end @hl1_desc = hl1_desc @dt1_desc = dt1_desc @tr_conf = Tree.new_with_document_struct(DocumentStructure::RD) @de_conf = DocumentElement.new @tr_conf.root = @de_conf hl1_conf, hl2_conf = nil @de_conf.build do hl1_conf = new Headline, 1 do new StringElement, "label" end hl2_conf = new Headline, 2 do new StringElement, "label" end end @hl1_conf = hl1_conf @hl2_conf = hl2_conf @tr_no = Tree.new_with_document_struct(DocumentStructure::RD) @de_no = DocumentElement.new @tr_no.root = @de_no @resolver = ReferenceResolver.new(@tr_head2) end def test_referent_of_label @tr_desc.include_path = ["test/data"] resolv = ReferenceResolver.new(@tr_desc, "label:") label1 = Reference::RDLabel.new("label1") assert_equal([nil, "label:0"], resolv.referent_of_label(label1)) label2 = Reference::RDLabel.new("label2") assert_equal([nil, "label:1"], resolv.referent_of_label(label2)) label_ext = Reference::RDLabel.new("label1", "label.rd") assert_equal(["label", "label:0"], resolv.referent_of_label(label_ext)) label3 = Reference::RDLabel.new("label3") assert_equal(nil, resolv.referent_of_label(label3)) label_ext3 = Reference::RDLabel.new("label3", "label.rd") assert_equal(["label", nil], resolv.referent_of_label(label_ext3)) end def test_refer_element resolv = ReferenceResolver.new(@tr_head1) assert_equal([@hl_head1], resolv.refer_element("label")) assert_equal([], resolv.refer_element("label not found")) resolv = ReferenceResolver.new(@tr_head2) assert_equal([@hl1_head2], resolv.refer_element("label1")) assert_equal([@hl2_head2], resolv.refer_element("label2")) resolv = ReferenceResolver.new(@tr_desc) assert_equal([@hl1_desc], resolv.refer_element("label1")) assert_equal([@dt1_desc], resolv.refer_element("label2")) resolv = ReferenceResolver.new(@tr_conf) assert_equal([@hl1_conf, @hl2_conf], resolv.refer_element("label")) resolv = ReferenceResolver.new(@tr_no) assert_equal([], resolv.refer_element("label")) end def test_refer resolv = ReferenceResolver.new(@tr_head1, "label:") assert_equal("label:0", resolv.refer("label")) assert_equal(nil, resolv.refer("label not found")) resolv = ReferenceResolver.new(@tr_head2, "label:") assert_equal("label:0", resolv.refer("label1")) assert_equal("label:1", resolv.refer("label2")) resolv = ReferenceResolver.new(@tr_desc, "label:") assert_equal("label:0", resolv.refer("label1")) assert_equal("label:1", resolv.refer("label2")) resolv = ReferenceResolver.new(@tr_conf, "label:") assert_equal("label:0", resolv.refer("label")) resolv = ReferenceResolver.new(@tr_no, "label:") assert_equal(nil, resolv.refer("label")) resolv = ReferenceResolver.new(@tr_head1, "label:") label = Reference::RDLabel.new("label") assert_equal("label:0", resolv.refer(label)) ref = Reference.new(label) assert_equal("label:0", resolv.refer(ref)) end def test_refer_external_file tr_ext = Tree.new_with_document_struct(DocumentStructure::RD, ["test/data"]) label_ext = Reference::RDLabel.new("label1", "label.rd") de = DocumentElement.new tr_ext.root = de ref = nil de.build do new TextBlock do se = StringElement.new "label" ref = new Reference, label_ext end end label_not_exist = Reference::RDLabel.new("label3", "label.rd") resolv = ReferenceResolver.new(tr_ext) assert_equal(["label", "label:0"], resolv.refer_external_file(ref)) assert_equal(["label", "label:0"], resolv.refer_external_file(label_ext)) assert_equal(["label", nil], resolv.refer_external_file(label_not_exist)) end def test_get_label_num assert_equal(0, @resolver.get_label_num(@hl1_head2)) assert_equal(1, @resolver.get_label_num(@hl2_head2)) assert_equal(nil, @resolver.get_label_num(@dt1_desc)) end def test_get_anchor resolv = ReferenceResolver.new(@tr_head2, "Label-") assert_equal("Label-0", resolv.get_anchor(@hl1_head2)) assert_equal("Label-1", resolv.get_anchor(@hl2_head2)) assert_equal(nil, resolv.get_anchor(@dt1_desc)) end def test_label2str assert_equal("string", @resolver.label2str("string")) assert_equal("label", @resolver.label2str(@hl_head1)) assert_equal("label2", @resolver.label2str(@dt1_desc)) label = Reference::RDLabel.new("label1") assert_equal("label1", @resolver.label2str(label)) ref = Reference.new(label) assert_equal("label1", @resolver.label2str(ref)) assert_raises(ArgumentError) do @resolver.label2str([]) end end def test_make_rbl_file in_temp_dir do begin @resolver.make_rbl_file("label-head") assert(File.exist?("label-head.rbl")) ensure remove_file("label-head.rbl") end begin @resolver.make_rbl_file("label-head2.rd") assert(File.exist?("label-head2.rbl")) ensure remove_file("label-head2.rbl") end end end end rdtool-0.6.38/test/test-inline-parser.rb0000755000004100000410000000305112057274011020175 0ustar www-datawww-datarequire 'test/unit' require 'rd/rdinlineparser.tab' require 'rd/rd-struct' include RD class TestInlineParser < Test::Unit::TestCase def setup @block_parser = RDParser.new @tree = tree = Tree.new_with_document_struct(DocumentStructure::RD) @block_parser.instance_eval do @tree = tree end @inline_parser = RDInlineParser.new(@block_parser) end def test_tree assert_equal(@tree, @inline_parser.tree) end def test_make_reference_from_label label = Reference::TemporaryLabel.new([StringElement.new("label")]) expect = Reference.new_from_label_under_document_struct(label, DocumentStructure::RD) ref = @inline_parser.make_reference_from_label(label) assert_equal(expect.label.element_label, ref.label.element_label) assert_equal(expect.label.filename, ref.label.filename) end def test_prev_words_on_error @inline_parser.instance_eval{@pre="foo bar baz"} assert_equal("foo bar baz", @inline_parser.prev_words_on_error("foo")) assert_equal("foo bar ", @inline_parser.prev_words_on_error("baz")) assert_equal("foo bar baz", @inline_parser.prev_words_on_error(false)) assert_equal("foo bar baz", @inline_parser.prev_words_on_error("not exist")) @inline_parser.instance_eval{@pre="foo bar\nfoo2 bar2"} assert_equal("foo2 bar2", @inline_parser.prev_words_on_error("foo2")) assert_equal("foo2 ", @inline_parser.prev_words_on_error("bar2")) @inline_parser.instance_eval{@pre="foo?"} assert_equal("foo", @inline_parser.prev_words_on_error("?")) end end rdtool-0.6.38/test/test-nonterminal-inline.rb0000755000004100000410000000151012057274011021225 0ustar www-datawww-datarequire 'test/unit' require 'rd/inline-element' require 'rd/document-struct' require 'dummy' include RD DummyStruct.define_relationship(NonterminalInline, DummyElement) class TestNonterminalInline < Test::Unit::TestCase def test_children el = NonterminalInline.new assert_equal([], el.children) el.children.push 1 assert_equal([1], el.children) end def test_to_label one = NonterminalInline.new one.add_child_under_document_struct(DummyElement.new, DummyStruct) assert_equal("label", one.to_label) two = NonterminalInline.new two.add_child_under_document_struct(DummyElement.new, DummyStruct) two.add_child_under_document_struct(DummyElement.new, DummyStruct) assert_equal("label label", two.to_label) zero = NonterminalInline.new assert_equal("", zero.to_label) end end rdtool-0.6.38/test/test-reference.rb0000755000004100000410000001037712057274011017374 0ustar www-datawww-datarequire 'test/unit' require 'rd/inline-element' require 'rd/document-struct' require 'rd/rd-struct' require 'rd/loose-struct' require 'dummy' include RD DummyStruct.define_relationship(Reference, DummyElement) class TestReference < Test::Unit::TestCase def test_initialize d1 = DummyElement.new l = Reference::TemporaryLabel.new([d1]) ref = Reference.new_from_label_under_document_struct(l, DummyStruct) assert_kind_of(Reference::RDLabel, ref.label) assert_equal([d1], ref.instance_eval("children")) l2 = Reference::TemporaryLabel.new([d1], "filename") ref = Reference.new_from_label_under_document_struct(l2, DummyStruct) assert_kind_of(Reference::RDLabel, ref.label) assert_equal([d1], ref.instance_eval("children")) assert_equal("filename", ref.label.filename) l = Reference::RDLabel.new("label") ref = Reference.new(l) assert_kind_of(Reference::RDLabel, ref.label) assert_equal([], ref.instance_eval("children")) url = Reference::URL.new("label") ref2 = Reference.new_from_label_under_document_struct(url, DocumentStructure::RD) assert_kind_of(Reference::URL, ref2.label) assert_kind_of(StringElement, ref2.instance_eval("children")[0]) assert_equal("", ref2.instance_eval("children")[0].content) end def test_s_new_from_label_without_document_struct se = StringElement.new "string" label = Reference::TemporaryLabel.new([se]) ref = Reference.new_from_label_without_document_struct(label) assert_kind_of(Reference::RDLabel, ref.label) assert_equal([se], ref.instance_eval("children")) end def test_to_label_RDLabel l = Reference::TemporaryLabel.new([DummyElement.new]) ref = Reference.new(l) assert_equal("label", ref.to_label) end def test_to_label_URL l = Reference::URL.new "http://www.ruby-lang.org/" ref = Reference.new l assert_equal("", ref.to_label) end def test_result_of_apply_method_of visitor = DummyVisitor.new label = Reference::RDLabel.new("label") reference = Reference.new(label) result = ["apply_to_Reference_with_RDLabel", [reference, []]] assert_equal(result, reference.result_of_apply_method_of(visitor, [])) url = Reference::URL.new("url") reference = Reference.new(url) result = ["apply_to_Reference_with_URL", [reference, []]] assert_equal(result, reference.result_of_apply_method_of(visitor, [])) end def test_add_child d1 = DummyElement.new d2 = DummyElement.new l = Reference::TemporaryLabel.new([d1]) ref = Reference.new_from_label_under_document_struct(l, DummyStruct) ref.add_child_under_document_struct(d2, DummyStruct) assert_equal(3, ref.to_a.size) assert_equal("label", ref.label.element_label) end def test_build lb = Reference::RDLabel.new("label") ref = Reference.new(lb).build(DocumentStructure::LOOSE) do set_label(Reference::RDLabel.new("LABEL")) end assert_equal("LABEL", ref.to_label) end end class TestRDLabel < Test::Unit::TestCase def test_to_label one = Reference::RDLabel.new("label") assert_equal("label", one.to_label) zero = Reference::RDLabel.new("") assert_equal("", zero.to_label) file = Reference::RDLabel.new("label", "filename") assert_equal("label", file.to_label) end def test_result_of_apply_method_of visitor = DummyVisitor.new label = Reference::RDLabel.new("label") reference = Reference.new(label) result = ["apply_to_Reference_with_RDLabel", [reference, []]] assert_equal(result, label.result_of_apply_method_of(visitor, reference, [])) end end class TestURL < Test::Unit::TestCase def test_to_label nor = Reference::URL.new "http://www.ruby-lang.org/" assert_equal("", nor.to_label) empty = Reference::URL.new "" assert_equal("", empty.to_label) end def test_result_of_apply_method_of visitor = DummyVisitor.new label = Reference::URL.new("label") reference = Reference.new(label) result = ["apply_to_Reference_with_URL", [reference, []]] assert_equal(result, label.result_of_apply_method_of(visitor, reference, [])) end end rdtool-0.6.38/test/test-headline.rb0000755000004100000410000000447712057274011017213 0ustar www-datawww-datarequire 'test/unit' require 'rd/block-element' require 'rd/inline-element' require 'rd/rd-struct' require 'rd/document-struct' include RD class TestHeadline < Test::Unit::TestCase def test_s_new a = Headline.new(1) assert_equal(1, a.level) end def test_add_child_under_document_struct check_add_child(StringElement.new("")) check_add_child(Emphasis.new) check_add_child(Code.new) check_add_child(Var.new) check_add_child(Keyboard.new) check_add_child(Index.new) check_add_child(Verb.new("")) check_add_child_fail(TextBlock.new) check_add_child_fail(Verbatim.new) check_add_child_fail(ItemList.new) check_add_child_fail(ItemListItem.new) check_add_child_fail(Reference.new(Reference::RDLabel.new(""))) check_add_child_fail(Footnote.new) end def check_add_child(child) parent = Headline.new(1) parent.add_child_under_document_struct(child, DocumentStructure::RD) assert_equal([child], parent.children) assert_equal(parent, child.parent) end def check_add_child_fail(child) parent = Headline.new(1) assert_raises(ArgumentError) do parent.add_child_under_document_struct(child, DocumentStructure::RD) end end def test_to_label a = Headline.new(1) c1 = StringElement.new "label" a.add_child_under_document_struct(c1, DocumentStructure::RD) assert_equal("label", a.to_label) b = Headline.new(1) c2 = Emphasis.new c21 = StringElement.new "LABEL" c2.add_child_under_document_struct(c21, DocumentStructure::RD) b.add_children_under_document_struct([c1, c2], DocumentStructure::RD) assert_equal("labelLABEL", b.to_label) b = Headline.new(1) c2 = Code.new c21 = StringElement.new " LABEL " c2.add_child_under_document_struct(c21, DocumentStructure::RD) b.add_children_under_document_struct([c1, c2], DocumentStructure::RD) assert_equal("labelLABEL", b.to_label) end def test_s_mark_to_level assert_equal(1, Headline.mark_to_level("=")) assert_equal(2, Headline.mark_to_level("==")) assert_equal(3, Headline.mark_to_level("===")) assert_equal(4, Headline.mark_to_level("====")) assert_equal(5, Headline.mark_to_level("+")) assert_equal(6, Headline.mark_to_level("++")) assert_raises(ArgumentError) do Headline.mark_to_level("=====") end end end rdtool-0.6.38/test/test-document-element.rb0000755000004100000410000000173012057274011020674 0ustar www-datawww-datarequire 'test/unit' require 'rd/element' require 'rd/rd-struct' include RD class TestDocumentElement < Test::Unit::TestCase def setup @p = DocumentElement.new @c1 = Headline.new(1) @c2 = TextBlock.new @c3 = ItemList.new @c31 = ItemListItem.new @c311 = TextBlock.new @c31.add_child_under_document_struct(@c311, DocumentStructure::RD) @c3.add_child_under_document_struct(@c31, DocumentStructure::RD) @p.add_children_under_document_struct([@c1, @c2, @c3], DocumentStructure::RD) end def test_s_new assert(DocumentElement.new) end def test_blocks assert_equal([@c1, @c2, @c3], @p.blocks) end def test_each_block i = 1 @p.each_block do |b| assert_equal(eval("@c#{i}"), b) i += 1 end end def test_each_element exp = [@p, @c1, @c2, @c3, @c31, @c311] i = 0 @p.each_element do |b| assert_equal(exp[i], b) i += 1 end end end rdtool-0.6.38/test/test-element.rb0000755000004100000410000000216212057274011017060 0ustar www-datawww-datarequire 'test/unit' require 'rd/tree' require 'rd/element' require 'rd/rd-struct' include RD class TestElement < Test::Unit::TestCase def setup @tree = Tree.new_with_document_struct(DocumentStructure::RD) @de = DocumentElement.new @tree.root = @de @tb = TextBlock.new @de.add_child(@tb) @err = TextBlock.new end def test_tree assert_equal(@tree, @de.tree) assert_equal(@tree, @tb.tree) assert_raises(RuntimeError) do @err.tree end end def test_inspect assert_equal("", TextBlock.new.inspect) t = TextBlock.new s = StringElement.new "" t.add_child_under_document_struct(s, DocumentStructure::RD) assert_equal("\n ", t.inspect) t = TextBlock.new e = Emphasis.new s = StringElement.new "" s2 = StringElement.new "a" e.add_child_under_document_struct(s, DocumentStructure::RD) t.add_children_under_document_struct([e, s2], DocumentStructure::RD) exp = "\n \n \n " assert_equal(exp, t.inspect) end end rdtool-0.6.38/test/test-output-format-visitor.rb0000755000004100000410000000235512057274011021756 0ustar www-datawww-datarequire 'test/unit' require 'temp-dir' require 'rd/output-format-visitor' require 'rd/tree' require 'rd/element' require 'rd/block-element' require 'rd/inline-element' require 'rd/rd-struct' include RD class TestOFVisitor < Test::Unit::TestCase def setup end def test_initialize vis = OutputFormatVisitor.new assert_equal([], vis.include_suffix) vis = SampleVisitor.new assert_equal(["html"], vis.include_suffix) end def test_apply_to_include tree = Tree.new_with_document_struct(DocumentStructure::RD, ["test/data/sub", "test/data/"]) de = DocumentElement.new # test/data/includee1.html inc1 = Include.new("includee1") # test/data/includee2.html, test/data/sub/includee2.html inc2 = Include.new("includee2") # test/data/includee3.nothtml inc3 = Include.new("includee3") tree.root = de de.add_child(inc1) de.add_child(inc2) de.add_child(inc3) vis = SampleVisitor.new assert_equal("includee1.html", vis.apply_to_Include(inc1)) assert_equal("sub/includee2.html", vis.apply_to_Include(inc2)) assert_equal(nil, vis.apply_to_Include(inc3)) end end class SampleVisitor < OutputFormatVisitor INCLUDE_SUFFIX = ["html"] end rdtool-0.6.38/test/test-nonterminal-element.rb0000755000004100000410000001150712057274011021407 0ustar www-datawww-datarequire 'test/unit' require 'rd/tree' require 'rd/element' require 'rd/loose-struct' require 'rd/rd-struct' include RD class TestElement < Test::Unit::TestCase def test_add_child_under_document_struct check_add_child(TextBlock.new, StringElement.new("")) check_add_child(Headline.new(1), Emphasis.new) check_add_child(ItemList.new, ItemListItem.new) check_add_child(ItemListItem.new, TextBlock.new) check_add_child(Emphasis.new, Code.new) assert_raises(ArgumentError) do Headline.new.add_child_under_document_struct(Reference. new(Reference::RDLabel.new), DocumentStructure::RD) ItemListItem.new.add_child_under_document_struct(Headline.new, DocumentStructure::RD) end end def check_add_child(p, c) assert(p.add_child_under_document_struct(c, DocumentStructure::RD)) end def test_add_children_under_document_struct p = TextBlock.new c1 = Code.new c2 = Var.new c3 = Reference.new(Reference::RDLabel.new("")) p.add_children_under_document_struct([c1, c2, c3], DocumentStructure::RD) assert_equal([c1, c2, c3], p.children) [c1, c2, c3].each do |i| assert_equal(p, i.parent) end end def test_add_child_under_document_struct2 p = TextBlock.new assert_equal([], p.children) c1 = Emphasis.new p.add_child_under_document_struct(c1, DocumentStructure::RD) assert_equal([c1], p.children) assert_equal(p, c1.parent) c2 = StringElement.new("") p.add_child_under_document_struct(c2, DocumentStructure::RD) assert_equal([c1, c2], p.children) assert_equal(p, c2.parent) p = DocumentElement.new c1 = Headline.new(1) p.add_child_under_document_struct(c1, DocumentStructure::RD) assert_equal([c1], p.children) assert_equal(p, c1.parent) c2 = ItemList.new p.add_child_under_document_struct(c2, DocumentStructure::RD) assert_equal([c1, c2], p.children) assert_equal(p, c2.parent) end def test_add_children_without_document_struct p = TextBlock.new c1 = StringElement.new "string" c2 = Emphasis.new c3 = Headline.new(1) assert_equal([], p.children) p.add_children_without_document_struct([c1]) assert_equal([c1], p.children) assert_equal(p, c1.parent) p.add_children_without_document_struct([c1, c2]) assert_equal([c1, c1, c2], p.children) assert_equal(p, c2.parent) p.add_children_without_document_struct([c3]) assert_equal([c1, c1, c2, c3], p.children) assert_equal(p, c2.parent) end def test_push_to_children parent = TextBlock.new child1 = StringElement.new "string" parent.push_to_children(child1) assert_equal([child1], parent.children) assert_equal(parent, child1.parent) end def test_children assert_equal([], DocumentElement.new.children) assert_equal([], Headline.new(1).children) assert_equal([], TextBlock.new.children) assert_equal([], List.new.children) assert_equal([], ListItem.new.children) assert_equal([], DescListItem::Term.new.children) assert_equal([], NonterminalInline.new.children) end def test_build testcase = self tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tr.root = de tb = TextBlock.new de.add_child(tb) res = tb.build do testcase.assert_equal(tb, self) end assert_equal(tb, res) end def test_build_under_document_struct testcase = self tb = TextBlock.new assert_nothing_raised do tb.build(DocumentStructure::LOOSE) do testcase.assert_equal(DocumentStructure::LOOSE, tb.temporary_document_structure) new Headline, 1 end end assert_equal(nil, tb.temporary_document_structure) begin tb.build(DocumentStructure::LOOSE) do raise RuntimeError end rescue assert_equal(nil, tb.temporary_document_structure) end end def test_make_child tr = Tree.new_with_document_struct(DocumentStructure::RD) de = DocumentElement.new tb = TextBlock.new tr.root = de de.add_child(tb) tb.make_child(StringElement, "string") assert_equal("\n ", tb.inspect) assert_raises(ArgumentError) do tb.make_child(TextBlock) end tr2 = Tree.new_with_document_struct(DocumentStructure::RD) de2 = DocumentElement.new tr2.root = de2 de2.build do new TextBlock do new StringElement, "string" new Emphasis do new StringElement, "emphais" end end end assert_equal("\n \n" + " \n \n " + "", de2.inspect) end end rdtool-0.6.38/test/test-rdvisitor.rb0000755000004100000410000000153712057274011017461 0ustar www-datawww-datarequire 'test/unit' require 'rd/rdvisitor' require 'rd/rd-struct' include RD class TestRDVisitor < Test::Unit::TestCase def test_refer_external tr_ext = Tree.new_with_document_struct(DocumentStructure::RD, ["test/data"]) label_ext = Reference::RDLabel.new("label1", "label.rd") tr_ext.root = DocumentElement.new ref_ext = nil tr_ext.root.build do new TextBlock do StringElement.new "label" ref_ext = new Reference, label_ext end end vis_ext = RDVisitor.new vis_ext.prepare_labels(tr_ext) label_not_exist = Reference::RDLabel.new("label3", "label.rd") assert_equal("label:0", vis_ext.refer_external(ref_ext)) assert_equal( "label:0", vis_ext.refer_external(label_ext)) assert_equal(nil, vis_ext.refer_external(label_not_exist)) end end rdtool-0.6.38/test/test-rdtree.rb0000755000004100000410000000062112057274011016712 0ustar www-datawww-datarequire 'test/unit' require 'rd/rdfmt' require 'rd/element' include RD class TestRDTree < Test::Unit::TestCase def test_s_new tr = RDTree.new("=begin\nTEST\n=end\n") assert_kind_of(DocumentElement, tr.root) tr_not_parse = RDTree.new("=begin\nTEST\n=end\n", ["test/data"], false) assert_nil(tr_not_parse.root) assert_equal(["test/data"], tr_not_parse.include_paths) end end rdtool-0.6.38/test/temp-dir.rb0000755000004100000410000000037612057274011016200 0ustar www-datawww-data def in_temp_dir tmpdir = "test-tmp.#$$" pwd = Dir.pwd Dir.mkdir(tmpdir) Dir.chdir(tmpdir) begin yield ensure Dir.chdir(pwd) Dir.rmdir(tmpdir) end end def remove_file(file) if File.exist? file File.unlink(file) end end rdtool-0.6.38/test/test-list.rb0000755000004100000410000000175412057274011016410 0ustar www-datawww-datarequire 'test/unit' require 'rd/list.rb' require 'rd/rd-struct' include RD class TestList < Test::Unit::TestCase def setup @a = ItemList.new @c1 = ItemListItem.new @c2 = ItemListItem.new @a.add_children_under_document_struct([@c1, @c2], DocumentStructure::RD) @b = ItemList.new @d1 = ItemListItem.new @d11 = TextBlock.new @d1.add_child_under_document_struct(@d11, DocumentStructure::RD) @b.add_children_under_document_struct([@d1], DocumentStructure::RD) end def test_each_item exp = [@c1, @c2] i = 0 @a.each_item do |b| assert_equal(exp[i], b) i += 1 end exp = [@d1] i = 0 @b.each_item do |b| assert_equal(exp[i], b) i += 1 end end def test_each_element exp = [@a, @c1, @c2] i = 0 @a.each_element do |b| assert_equal(exp[i], b) i += 1 end exp = [@b, @d1, @d11] i = 0 @b.each_element do |b| assert_equal(exp[i], b) i += 1 end end end rdtool-0.6.38/test/test-parser-util.rb0000755000004100000410000000176712057274011017710 0ustar www-datawww-datarequire 'test/unit' require 'rd/rdblockparser.tab' require 'rd/rd-struct' include RD class TestParserUtil < Test::Unit::TestCase def setup @p = RDParser.new @tree = tree = Tree.new_with_document_struct(DocumentStructure::RD) @p.instance_eval do @tree = tree end end def test_tree obj = Object.new obj.extend(ParserUtility) assert_raises(NotImplementedError) do obj.tree end end def test_add_children_to_element headline = Headline.new(1) string_element = StringElement.new "string" emphasis = Emphasis.new @p.add_children_to_element(headline, string_element, emphasis) assert_equal([string_element, emphasis], headline.children) textblock = TextBlock.new @p.add_children_to_element(textblock, emphasis, string_element) assert_equal([emphasis, string_element], textblock.children) textblock_empty = TextBlock.new @p.add_children_to_element(textblock_empty) assert_equal([], textblock_empty.children) end end rdtool-0.6.38/test/test-rbl-suite.rb0000755000004100000410000000235112057274011017335 0ustar www-datawww-datarequire 'test/unit' require 'rd/rbl-suite' require 'rd/rbl-file' include RD class TestRBLSuite < Test::Unit::TestCase def setup @suite = RBLSuite.new(["test/data"]) end def test_get_rbl_file assert_equal([], @suite.rbl_files) rbl = @suite.get_rbl_file("label.rd") assert_equal(rbl, @suite.get_rbl_file("label.rd")) assert_equal(1, @suite.rbl_files.size) end def test_add_rbl_file assert_equal([], @suite.rbl_files) rbl = @suite.add_rbl_file("label.rd") assert_kind_of(RBLFile, rbl) assert_equal(1, @suite.rbl_files.size) assert_equal("label", @suite.rbl_files[0].filename) assert_equal(rbl, @suite.rbl_files[0]) assert_nothing_raised do @suite.add_rbl_file("not-exist-label.rd") end end def test_refer assert_equal(["label", "label:0"], @suite.refer("label1", "label.rd")) assert_equal(["label2", "Label-0"], @suite.refer("label1", "label2.rd")) assert_equal(["label", "label:0"], @suite.refer("label1", "label")) assert_equal(["label", "label:1"], @suite.refer("label2", "label.rd")) assert_equal(["label", nil], @suite.refer("label3", "label.rd")) fns = @suite.rbl_files.collect{|i| i.filename } assert_equal(["label", "label2"], fns) end end rdtool-0.6.38/test/dummy.rb0000755000004100000410000000073212057274011015606 0ustar www-datawww-datarequire "rd/element" require "rd/document-struct" require "rd/visitor" module RD class DummyElement < Element attr_accessor :parent def children [] end def each_element yield(self) end def accept(visitor) "dummy" end def to_label " label " end end DummyStruct = DocumentStructure.new end class DummyVisitor < RD::Visitor def method_missing(method, *args) [method.to_s, args] end end rdtool-0.6.38/test/data/0000755000004100000410000000000012057274011015032 5ustar www-datawww-datardtool-0.6.38/test/data/includee1.html0000644000004100000410000000001612057274011017566 0ustar www-datawww-dataincludee1.htmlrdtool-0.6.38/test/data/includee4.xhtml0000644000004100000410000000000012057274011017752 0ustar www-datawww-datardtool-0.6.38/test/data/label2.rbl0000644000004100000410000000004412057274011016672 0ustar www-datawww-datalabel1 => Label-0 label2 => Label-1 rdtool-0.6.38/test/data/sub/0000755000004100000410000000000012057274011015623 5ustar www-datawww-datardtool-0.6.38/test/data/sub/includee4.html0000644000004100000410000000000012057274011020353 0ustar www-datawww-datardtool-0.6.38/test/data/sub/includee2.html0000644000004100000410000000002212057274011020355 0ustar www-datawww-datasub/includee2.htmlrdtool-0.6.38/test/data/includee3.nothtml0000644000004100000410000000002112057274011020305 0ustar www-datawww-dataincludee3.nothtmlrdtool-0.6.38/test/data/label.rbl0000644000004100000410000000004412057274011016610 0ustar www-datawww-datalabel1 => label:0 label2 => label:1 rdtool-0.6.38/test/data/includee2.html0000644000004100000410000000001612057274011017567 0ustar www-datawww-dataincludee2.htmlrdtool-0.6.38/test/test-version.rb0000755000004100000410000000342212057274011017114 0ustar www-datawww-datarequire 'test/unit' require 'rd/version' include RD class TestVersion < Test::Unit::TestCase def test_s_new_from_version_string ver011 = Version.new_from_version_string("name", "$Version: 0.1.1$") # " assert_equal("name", ver011.name) assert_equal(0, ver011.major) assert_equal(1, ver011.minor) assert_equal(1, ver011.patch_level) ver0101 = Version.new_from_version_string("name", "$Version: 0.10.1$") #" assert_equal(0, ver0101.major) assert_equal(10, ver0101.minor) assert_equal(1, ver0101.patch_level) ver01 = Version.new_from_version_string("name", "$Version: 0.1$") # " assert_equal(0, ver01.major) assert_equal(1, ver01.minor) assert_equal(nil, ver01.patch_level) ver0 = Version.new_from_version_string("name", "$Version: 0$") # " assert_equal(0, ver0.major) assert_equal(nil, ver0.minor) assert_equal(nil, ver0.patch_level) ver011_2 = Version.new_from_version_string("name", "0.1.1") # " assert_equal("name", ver011_2.name) assert_equal(0, ver011_2.major) assert_equal(1, ver011_2.minor) assert_equal(1, ver011_2.patch_level) end def test_s_clean_up_version_string assert_equal("0.1.1", Version.clean_up_version_string("$Version: 0.1.1$")) #" assert_equal("0.1.1", Version.clean_up_version_string("0.1.1")) assert_equal("", Version.clean_up_version_string("$Version$")) # " end def test_to_s ver011 = Version.new("name", 0, 1, 1) assert_equal("name 0.1.1", ver011.to_s) ver0101 = Version.new("name", 0, 10, 1) assert_equal("name 0.10.1", ver0101.to_s) ver01 = Version.new("name", 0, 1, nil) assert_equal("name 0.1", ver01.to_s) ver0 = Version.new("name", 0, nil, nil) assert_equal("name 0", ver0.to_s) end end rdtool-0.6.38/test/test-list-item.rb0000755000004100000410000000176212057274011017343 0ustar www-datawww-datarequire 'test/unit' require 'rd/list.rb' require 'rd/rd-struct' include RD class TestListItem < Test::Unit::TestCase def setup @a = ItemListItem.new @c1 = TextBlock.new @c2 = TextBlock.new @a.add_children_under_document_struct([@c1, @c2], DocumentStructure::RD) @b = ItemListItem.new @d1 = TextBlock.new @d11 = Emphasis.new @d1.add_child_under_document_struct(@d11, DocumentStructure::RD) @b.add_children_under_document_struct([@d1], DocumentStructure::RD) end def test_each_block exp = [@c1, @c2] i = 0 @a.each_block do |b| assert_equal(exp[i], b) i += 1 end exp = [@d1] i = 0 @b.each_block do |b| assert_equal(exp[i], b) i += 1 end end def test_each_element exp = [@a, @c1, @c2] i = 0 @a.each_element do |b| assert_equal(exp[i], b) i += 1 end exp = [@b, @d1, @d11] i = 0 @b.each_element do |b| assert_equal(exp[i], b) i += 1 end end end rdtool-0.6.38/test/test-visitor.rb0000755000004100000410000001477712057274011017145 0ustar www-datawww-datarequire 'test/unit' require 'rd/visitor' require 'rd/block-element' require 'rd/list' require 'rd/desclist' require 'rd/methodlist' require 'rd/inline-element' require 'rd/tree' require 'rd/rd-struct' require 'dummy' include RD DummyStruct.define_relationship(NonterminalElement, DummyElement) class TestVisitor < Test::Unit::TestCase def setup @vis = DummyVisitor.new end def test_visit_children el = TextBlock.new add_2_children(el) assert_equal(["dummy", "dummy"], @vis.visit_children(el)) empty = TextBlock.new assert_equal([], @vis.visit_children(empty)) end def test_visit_DocumentElement el = DocumentElement.new add_2_children(el) assert_equal(["apply_to_DocumentElement", [el, ["dummy", "dummy"]]], @vis.visit_DocumentElement(el)) end def test_visit_Headline el = Headline.new(1) add_2_children(el) assert_equal(["apply_to_Headline", [el, ["dummy", "dummy"]]], @vis.visit_Headline(el)) end def test_visit_Include el = Include.new "include" assert_equal(["apply_to_Include", [el]], @vis.visit_Include(el)) end def test_visit_TextBlock el = TextBlock.new add_2_children(el) assert_equal(["apply_to_TextBlock", [el, ["dummy", "dummy"]]], @vis.visit_TextBlock(el)) end def test_visit_Verbatim el = Verbatim.new "Verbatim" assert_equal(["apply_to_Verbatim", [el]], @vis.visit_Verbatim(el)) end def test_visit_ItemList el = ItemList.new add_2_children(el) assert_equal(["apply_to_ItemList", [el, ["dummy", "dummy"]]], @vis.visit_ItemList(el)) end def test_visit_EnumList el = EnumList.new add_2_children(el) assert_equal(["apply_to_EnumList", [el, ["dummy", "dummy"]]], @vis.visit_EnumList(el)) end def test_visit_DescList el = DescList.new add_2_children(el) assert_equal(["apply_to_DescList", [el, ["dummy", "dummy"]]], @vis.visit_DescList(el)) end def test_visit_MethodList el = MethodList.new add_2_children(el) assert_equal(["apply_to_MethodList", [el, ["dummy", "dummy"]]], @vis.visit_MethodList(el)) end def test_visit_ItemListItem el = ItemListItem.new add_2_children(el) assert_equal(["apply_to_ItemListItem", [el, ["dummy", "dummy"]]], @vis.visit_ItemListItem(el)) end def test_visit_EnumListItem el = EnumListItem.new add_2_children(el) assert_equal(["apply_to_EnumListItem", [el, ["dummy", "dummy"]]], @vis.visit_EnumListItem(el)) end def test_visit_DescListItem el = DescListItem.new el.set_term_under_document_struct(DummyElement.new, DummyStruct) add_2_children(el) assert_equal(["apply_to_DescListItem", [el, "dummy", ["dummy", "dummy"]]], @vis.visit_DescListItem(el)) empty = DescListItem.new empty.set_term_under_document_struct(DummyElement.new, DummyStruct) assert_equal(["apply_to_DescListItem", [empty, "dummy", []]], @vis.visit_DescListItem(empty)) end def test_visit_DescListItemTerm el = DescListItem::Term.new add_2_children(el) assert_equal(["apply_to_DescListItemTerm", [el, ["dummy", "dummy"]]], @vis.visit_DescListItemTerm(el)) end def test_visit_MethodListItem el = MethodListItem.new el.set_term_under_document_struct(DummyElement.new, DummyStruct) add_2_children(el) assert_equal(["apply_to_MethodListItem", [el, "dummy", ["dummy", "dummy"]]], @vis.visit_MethodListItem(el)) empty = MethodListItem.new empty.set_term_under_document_struct(DummyElement.new, DummyStruct) assert_equal(["apply_to_MethodListItem", [empty, "dummy", []]], @vis.visit_MethodListItem(empty)) end def test_visit_MethodListItemTerm el = MethodListItem::Term.new assert_equal(["apply_to_MethodListItemTerm", [el]], @vis.visit_MethodListItemTerm(el)) end def test_visit_StringElement el = StringElement.new "string" assert_equal(["apply_to_StringElement", [el]], @vis.visit_StringElement(el)) end def test_visit_Verb el = Verb.new "string" assert_equal(["apply_to_Verb", [el]], @vis.visit_Verb(el)) end def test_visit_Emphasis el = Emphasis.new add_2_children(el) assert_equal(["apply_to_Emphasis", [el, ["dummy", "dummy"]]], @vis.visit_Emphasis(el)) end def test_visit_Code el = Code.new add_2_children(el) assert_equal(["apply_to_Code", [el, ["dummy", "dummy"]]], @vis.visit_Code(el)) end def test_visit_Var el = Var.new add_2_children(el) assert_equal(["apply_to_Var", [el, ["dummy", "dummy"]]], @vis.visit_Var(el)) end def test_visit_Keyboard el = Keyboard.new add_2_children(el) assert_equal(["apply_to_Keyboard", [el, ["dummy", "dummy"]]], @vis.visit_Keyboard(el)) end def test_visit_Index el = Index.new add_2_children(el) assert_equal(["apply_to_Index", [el, ["dummy", "dummy"]]], @vis.visit_Index(el)) end def test_visit_Footnote el = Footnote.new add_2_children(el) assert_equal(["apply_to_Footnote", [el, ["dummy", "dummy"]]], @vis.visit_Footnote(el)) end def test_visit_Reference el = Reference.new(Reference::RDLabel.new("label")) add_2_children(el) assert_equal(["apply_to_Reference_with_RDLabel", [el, ["dummy", "dummy"]]], @vis.visit_Reference(el)) empty = Reference.new(Reference::RDLabel.new("label")) assert_equal(["apply_to_Reference_with_RDLabel", [empty, []]], @vis.visit_Reference(empty)) url_reference = Reference.new(Reference::URL.new("url")) add_2_children(url_reference) assert_equal(["apply_to_Reference_with_URL", [url_reference, ["dummy", "dummy"]]], @vis.visit_Reference(url_reference)) # OldStyleDummyVisitor#apply_to_Reference_with_RDLabel is not implemented. # So, #apply_to_reference is called instead of it. old_visitor = OldStyleDummyVisitor.new assert_equal(["apply_to_Reference", [el, ["dummy", "dummy"]]], old_visitor.visit_Reference(el)) end def add_2_children(el) el.add_children_under_document_struct([DummyElement.new, DummyElement.new], DummyStruct) end end class OldStyleDummyVisitor < Visitor def apply_to_Reference(*args) ["apply_to_Reference", args] end end rdtool-0.6.38/test/test-rbl-file.rb0000755000004100000410000001050012057274011017116 0ustar www-datawww-datarequire 'test/unit' require 'temp-dir' require 'rd/rbl-file' require 'rd/block-element' require 'rd/inline-element' require 'rd/rd-struct' require 'rd/reference-resolver' include RD class TestRBLFile < Test::Unit::TestCase def setup tr_head2 = Tree.new_with_document_struct(DocumentStructure::RD) de_head2 = DocumentElement.new tr_head2.root = de_head2 hl1_head2, hl2_head2 = nil de_head2.build do hl1_head2 = new Headline, 1 do new StringElement, "label1" end new TextBlock hl2_head2 = new Headline, 2 do new StringElement, "label2" end end @resolv_head2 = ReferenceResolver.new(tr_head2, "label:") tr_desc = Tree.new_with_document_struct(DocumentStructure::RD) de_desc = DocumentElement.new tr_desc.root = de_desc hl1_desc, dt1_desc = nil de_desc.build do hl1_desc = new(Headline, 1) do new StringElement, "label1" end new DescList do new DescListItem do dt1_desc = make_term do new StringElement, "label2" end end end end @resolv_desc = ReferenceResolver.new(tr_desc, "Label-") tr_empty = Tree.new_with_document_struct(DocumentStructure::RD) de_empty = DocumentElement.new tr_empty.root = de_empty @resolv_empty = ReferenceResolver.new(tr_empty, "LABEL") tr_arr = Tree.new_with_document_struct(DocumentStructure::RD) de_arr = DocumentElement.new tr_arr.root = de_arr de_arr.build do new Headline, 1 do new StringElement, "a => b" end end @resolv_arr = ReferenceResolver.new(tr_arr, "label:") @rbl_head2 = RBLFile.new("test-head2") @rbl_desc = RBLFile.new("test-desc") @rbl_empty = RBLFile.new("test-empty") @rbl_arr = RBLFile.new("test-arr") end def test_labels_to_string res = "label1 => label:0\nlabel2 => label:1" assert_equal(res, RBLFile.labels_to_string(@resolv_head2)) res2 = "label1 => Label-0\nlabel2 => Label-1" assert_equal(res2, RBLFile.labels_to_string(@resolv_desc)) res_empty = "" assert_equal(res_empty, RBLFile.labels_to_string(@resolv_empty)) res_arr = "a => b => label:0" assert_equal(res_arr, RBLFile.labels_to_string(@resolv_arr)) end def test_string_to_labels rbl = RBLFile.new("test-head2") src_head2 = "label1 => label:0\nlabel2 => label:1" res_head2 = [["label1", "label:0"], ["label2", "label:1"]] assert_equal(res_head2, rbl.string_to_labels(src_head2)) src_head2 = "label1 =>label:0\nlabel2=> label:1" res_head2 = [["label1", "label:0"], ["label2", "label:1"]] assert_equal(res_head2, rbl.string_to_labels(src_head2)) src_desc = "label1 => Label-0\nlabel2 => Label-1" res_desc = [["label1", "Label-0"], ["label2", "Label-1"]] assert_equal(res_desc, rbl.string_to_labels(src_desc)) src_empty = "" res_empty = [] assert_equal(res_empty, @rbl_empty.string_to_labels(src_empty)) src_arr = "a => b => label:0" res_arr = [["a => b", "label:0"]] assert_equal(res_arr, @rbl_arr.string_to_labels(src_arr)) end def test_rbl_file_path assert_equal("test-head2.rbl", RBLFile.rbl_file_path("test-head2.rd")) assert_equal("test-head2.rbl", RBLFile.rbl_file_path("test-head2.rb")) assert_equal("test-desc.rbl", RBLFile.rbl_file_path("test-desc")) end def test_s_create_rbl_file in_temp_dir do begin RBLFile.create_rbl_file("test-head2.rd", @resolv_head2) assert(File.exist?("test-head2.rbl")) ensure remove_file("test-head2.rbl") end end end def test_load_rbl_file in_temp_dir do spath = [Dir.pwd] begin RBLFile.create_rbl_file("test-head2.rd", @resolv_head2) rbl_rd = RBLFile.new("test-head2.rd") rbl_rd.load_rbl_file(spath) res = [["label1", "label:0"], ["label2", "label:1"]] assert_equal(res, rbl_rd.labels) rbl_no = RBLFile.new("test-head2") rbl_no.load_rbl_file(spath) assert_equal(res, rbl_no.labels) ensure remove_file("test-head2.rbl") end end end def test_refer spath = ["test/data"] rbl = RBLFile.new("label") rbl.load_rbl_file(spath) assert_equal("label:0", rbl.refer("label1")) assert_equal("label:1", rbl.refer("label2")) assert_equal(nil, rbl.refer("label3")) end end rdtool-0.6.38/test/test-document-struct.rb0000755000004100000410000000404412057274011020570 0ustar www-datawww-datarequire 'test/unit' require 'rd/document-struct.rb' require 'rd/rdfmt' class TestDocumentStructure < Test::Unit::TestCase include RD def test_each_relationship a = DocumentStructure.new r1 = ElementRelationship.new(TextBlock, InlineElement) r2 = ElementRelationship.new(DocumentElement, BlockElement) r3 = ElementRelationship.new(ListItem, BlockElement) r4 = ElementRelationship.new(ItemList, ItemListItem) exp = [r1, r2, r3, r4] a.add_relationships(*exp) a.each_relationship do |i| assert(exp.include?(i)) exp.delete(i) end assert_equal([], exp) end def test_is_valid? a = DocumentStructure.new r1 = ElementRelationship.new(TextBlock, InlineElement) r2 = ElementRelationship.new(DocumentElement, BlockElement) r3 = ElementRelationship.new(ListItem, BlockElement) r4 = ElementRelationship.new(ItemList, ItemListItem) a.add_relationships(r1, r2, r3, r4) assert(a.is_valid?(TextBlock.new, Emphasis.new)) assert(a.is_valid?(DocumentElement.new, TextBlock.new)) assert(a.is_valid?(ItemList.new, ItemListItem.new)) assert_false(a.is_valid?(TextBlock.new, Headline.new(1))) assert_false(a.is_valid?(ItemList.new, TextBlock.new)) end end class TestElementRelationship < Test::Unit::TestCase include RD def test_match? a = ElementRelationship.new(TextBlock, InlineElement) assert(a.match?(TextBlock.new, Emphasis.new)) assert_false(a.match?(TextBlock.new, Headline.new(1))) a = ElementRelationship.new(InlineElement, InlineElement) assert(a.match?(Emphasis.new, Code.new)) assert_false(a.match?(Emphasis.new, Headline.new(1))) a = ElementRelationship.new(DocumentElement, BlockElement) assert(a.match?(DocumentElement.new, Headline.new(1))) assert_false(a.match?(DocumentElement.new, Emphasis.new)) a = ElementRelationship.new(ItemList, ItemListItem) assert(a.match?(ItemList.new, ItemListItem.new)) assert_false(a.match?(ItemList.new, TextBlock.new)) end end def assert_false(cond) assert_equal(false, cond) end rdtool-0.6.38/test/test-terminal-inline.rb0000755000004100000410000000163612057274011020523 0ustar www-datawww-datarequire 'test/unit' require 'rd/inline-element' include RD class TestStringElement < Test::Unit::TestCase def test_to_label el = StringElement.new "label" assert_equal("label", el.to_label) ws = StringElement.new " label " assert_equal(" label ", ws.to_label) empty = StringElement.new "" assert_equal("", empty.to_label) end def test_content el = StringElement.new "" assert_equal("", el.content) el.content = "label" assert_equal("label", el.content) end end class TestVerb < Test::Unit::TestCase def test_to_label el = Verb.new "label" assert_equal("label", el.to_label) ws = Verb.new " label " assert_equal("label", ws.to_label) empty = Verb.new "" assert_equal("", empty.to_label) end def test_content el = Verb.new "" assert_equal("", el.content) el.content = "label" assert_equal("label", el.content) end end rdtool-0.6.38/test/dummy-observer.rb0000755000004100000410000000012712057274011017431 0ustar www-datawww-dataclass DummyObserver attr_reader :args def update(*args) @args = args end end rdtool-0.6.38/test/test-block-parser.rb0000755000004100000410000000266012057274011020016 0ustar www-datawww-datarequire 'test/unit' require 'rd/rdblockparser.tab' require 'rd/rd-struct' include RD class TestBlockParser < Test::Unit::TestCase def setup @p = RDParser.new @p.class.module_eval { public :cut_off,:set_term_to_element } @p.instance_eval do @tree = Tree.new_with_document_struct(DocumentStructure::RD) end end def test_cut_off assert_equal(["aaaa"], @p.cut_off(["aaaa"])) assert_equal(["aaaa\n"], @p.cut_off(["aaaa\n"])) assert_equal(["aaaa\n"], @p.cut_off([" aaaa\n"])) assert_equal(["aaaa\n", "bbbb\n"], @p.cut_off([" aaaa\n", " bbbb\n"])) assert_equal(["aaaa\n", " bbbb\n"], @p.cut_off(["aaaa\n", " bbbb\n"])) assert_equal(["aaaa\n", " bbbb\n"], @p.cut_off([" aaaa\n", " bbbb\n"])) assert_equal(["aaaa\n", " bbbb\n", " cccc\n"], @p.cut_off([" aaaa\n", " bbbb\n", " cccc\n"])) assert_equal(["aaaa\n", " bbbb\n", " cccc\n"], @p.cut_off([" aaaa\n", " bbbb\n", " cccc\n"])) assert_raises(RuntimeError) do @p.cut_off([" aaaa\n", "bbbb\n"]) end end def test_set_term_to_element desclist = DescListItem.new term = DescListItem::Term.new @p.set_term_to_element(desclist, term) assert_equal(term, desclist.term) methodlist = MethodListItem.new term = MethodListItem::Term.new "string" @p.set_term_to_element(methodlist, term) assert_equal(term, methodlist.term) end end rdtool-0.6.38/test/test-rd2html-lib.rb0000755000004100000410000004206212057274011017552 0ustar www-datawww-datarequire 'test/unit' require 'rd/rd2html-lib' require 'rd/tree' require 'rd/element' require 'rd/block-element' require 'rd/list' require 'rd/desclist' require 'rd/methodlist' require 'rd/inline-element' require 'rd/rd-struct' include RD class TestRD2HTMLVisitor < Test::Unit::TestCase def setup @vis = RD2HTMLVisitor.new @vis.class.module_eval { public :xml_decl public :forward_links, :backward_links public :document_title public :html_content_type public :html_title public :html_open_tag public :link_to_css public :prepare_footnotes public :make_foottext } @ch1 = ["a"] @ch2 = ["a", "b"] @ch3 = ["a\n"] @ch0 = [] @tr_fn = Tree.new_with_document_struct(DocumentStructure::RD) @tr_fn.root = DocumentElement.new fn1, fn2 = nil @tr_fn.root.build do new TextBlock do fn1 = new Footnote do new StringElement, "footnote 1" end fn2 = new Footnote do new StringElement, "footnote 2" end end end @fn1_fn = fn1 @fn2_fn = fn2 @tr2_fn = Tree.new_with_document_struct(DocumentStructure::RD) @tr2_fn.root = DocumentElement.new @tr2_fn.root.build do new Headline, 1 new TextBlock do new StringElement, "string" end end end def test_xml_decl vis_with_charset = RD2HTMLVisitor.new vis_with_charset.charset = "CharSet" assert_equal(%||, vis_with_charset.xml_decl) vis_no_charset = RD2HTMLVisitor.new assert_equal(%||, vis_no_charset.xml_decl) end def test_html_open_tag vis_with_lang = RD2HTMLVisitor.new vis_with_lang.lang = "Language" assert_equal(%||, vis_with_lang.html_open_tag) vis_no_lang = RD2HTMLVisitor.new assert_equal(%||, vis_no_lang.html_open_tag) end def test_html_title vis_with_title = RD2HTMLVisitor.new vis_with_title.title = "Title" assert_equal("Title", vis_with_title.html_title) vis_no_title = RD2HTMLVisitor.new assert_equal("Untitled", vis_no_title.html_title) end def test_html_content_type vis_with_charset = RD2HTMLVisitor.new vis_with_charset.charset = "CharSet" assert_equal(%|", vis_with_charset.html_content_type) vis_no_charset = RD2HTMLVisitor.new assert_equal(nil, vis_no_charset.html_content_type) end def test_link_to_css vis_with_css = RD2HTMLVisitor.new vis_with_css.css = "CSS.css" assert_equal(%|", vis_with_css.link_to_css) vis_no_css = RD2HTMLVisitor.new assert_equal(nil, vis_no_css.link_to_css) end def test_forward_links vis_rel1 = RD2HTMLVisitor.new vis_rel1.html_link_rel["rel1"] = "REL1" assert_equal('', vis_rel1.forward_links) vis_rel2 = vis_rel1 vis_rel2.html_link_rel["rel2"] = "REL2" assert_equal('' + "\n" + '', vis_rel2.forward_links) vis_no_rel = RD2HTMLVisitor.new assert_equal(nil, vis_no_rel.forward_links) end def test_backward_links vis_rev1 = RD2HTMLVisitor.new vis_rev1.html_link_rev["rev1"] = "REV1" assert_equal('', vis_rev1.backward_links) vis_rev2 = vis_rev1 vis_rev2.html_link_rev["rev2"] = "REV2" assert_equal('' + "\n" + '', vis_rev2.backward_links) vis_no_rev = RD2HTMLVisitor.new assert_equal(nil, vis_no_rev.backward_links) end def test_document_title vis_titled = RD2HTMLVisitor.new vis_titled.title = "Title" assert_equal("Title", vis_titled.document_title) vis_with_filename = RD2HTMLVisitor.new vis_with_filename.filename = "FileName" assert_equal("FileName", vis_with_filename.document_title) vis_untitled = RD2HTMLVisitor.new assert_equal("Untitled", vis_untitled.document_title) end def test_apply_to_Headline tr = Tree.new_with_document_struct(DocumentStructure::RD) tr.root = DocumentElement.new hl1, hl2 = nil tr.root.build do hl1 = new Headline, 1 do new StringElement, "headline 1" end hl2 = new Headline, 2 do new StringElement, "headline 2" end end @vis.prepare_labels(tr, "label:") assert_equal(expect_for_hl1(@ch1), @vis.apply_to_Headline(hl1, @ch1)) assert_equal(expect_for_hl1(@ch2), @vis.apply_to_Headline(hl1, @ch2)) assert_equal(expect_for_hl1(@ch0), @vis.apply_to_Headline(hl1, @ch0)) assert_equal(expect_for_hl2(@ch1), @vis.apply_to_Headline(hl2, @ch1)) assert_equal(expect_for_hl2(@ch2), @vis.apply_to_Headline(hl2, @ch2)) assert_equal(expect_for_hl2(@ch0), @vis.apply_to_Headline(hl2, @ch0)) end def expect_for_hl1(children) %|

#{children.join('')}

| end def expect_for_hl2(children) %|

#{children.join('')}

| end def test_apply_to_TextBlock tb = TextBlock.new assert_equal("

a

", @vis.apply_to_TextBlock(tb, @ch1)) assert_equal("

ab

", @vis.apply_to_TextBlock(tb, @ch2)) assert_equal("

a

", @vis.apply_to_TextBlock(tb, @ch3)) assert_equal("

", @vis.apply_to_TextBlock(tb, @ch0)) tb_in_list = TextBlock.new li = ItemListItem.new li.add_child_under_document_struct(tb_in_list, DocumentStructure::RD) assert_equal("a", @vis.apply_to_TextBlock(tb_in_list, @ch1)) assert_equal("ab", @vis.apply_to_TextBlock(tb_in_list, @ch2)) assert_equal("a", @vis.apply_to_TextBlock(tb_in_list, @ch3)) assert_equal("", @vis.apply_to_TextBlock(tb_in_list, @ch0)) tb1_in_list2 = TextBlock.new tb2_in_list2 = TextBlock.new li2 = ItemListItem.new li2.add_children_under_document_struct([tb1_in_list2, tb2_in_list2], DocumentStructure::RD) assert_equal("

a

", @vis.apply_to_TextBlock(tb1_in_list2, @ch1)) assert_equal("

ab

", @vis.apply_to_TextBlock(tb1_in_list2, @ch2)) assert_equal("

a

", @vis.apply_to_TextBlock(tb1_in_list2, @ch3)) assert_equal("

", @vis.apply_to_TextBlock(tb1_in_list2, @ch0)) end def test_apply_to_Verbatim verb1 = Verbatim.new "aaa" assert_equal("
aaa
", @vis.apply_to_Verbatim(verb1)) verb2 = Verbatim.new "aaa\n" assert_equal("
aaa
", @vis.apply_to_Verbatim(verb2)) verb3 = Verbatim.new "aaa\nbbb" assert_equal("
aaa\nbbb
", @vis.apply_to_Verbatim(verb3)) verb_empty = Verbatim.new "" assert_equal("
", @vis.apply_to_Verbatim(verb_empty))
    verb_amp = Verbatim.new "&"
    assert_equal("
&
", @vis.apply_to_Verbatim(verb_amp)) verb_lt = Verbatim.new "<" assert_equal("
<
", @vis.apply_to_Verbatim(verb_lt)) verb_gt = Verbatim.new ">" assert_equal("
>
", @vis.apply_to_Verbatim(verb_gt)) verb3 = Verbatim.new ["aaa\n", "bbb"] assert_equal("
aaa\nbbb
", @vis.apply_to_Verbatim(verb3)) end def test_apply_to_ItemList list = ItemList.new assert_equal("
    \na\n
", @vis.apply_to_ItemList(list, @ch1)) assert_equal("
    \na\nb\n
", @vis.apply_to_ItemList(list, @ch2)) assert_equal("
    \na\n
", @vis.apply_to_ItemList(list, @ch3)) assert_equal("
    \n\n
", @vis.apply_to_ItemList(list, @ch0)) end def test_apply_to_EnumList list = EnumList.new assert_equal("
    \na\n
", @vis.apply_to_EnumList(list, @ch1)) assert_equal("
    \na\nb\n
", @vis.apply_to_EnumList(list, @ch2)) assert_equal("
    \na\n
", @vis.apply_to_EnumList(list, @ch3)) assert_equal("
    \n\n
", @vis.apply_to_EnumList(list, @ch0)) end def test_apply_to_DescList list = DescList.new assert_equal("
\na\n
", @vis.apply_to_DescList(list, @ch1)) assert_equal("
\na\nb\n
", @vis.apply_to_DescList(list, @ch2)) assert_equal("
\na\n
", @vis.apply_to_DescList(list, @ch3)) assert_equal("
\n\n
", @vis.apply_to_DescList(list, @ch0)) end def test_apply_to_MethodList list = MethodList.new assert_equal("
\na\n
", @vis.apply_to_MethodList(list, @ch1)) assert_equal("
\na\nb\n
", @vis.apply_to_MethodList(list, @ch2)) assert_equal("
\na\n
", @vis.apply_to_MethodList(list, @ch3)) assert_equal("
\n\n
", @vis.apply_to_MethodList(list, @ch0)) end def test_apply_to_ItemListItem item = ItemListItem.new assert_equal("
  • a
  • ", @vis.apply_to_ItemListItem(item, @ch1)) assert_equal("
  • a\nb
  • ", @vis.apply_to_ItemListItem(item, @ch2)) assert_equal("
  • a
  • ", @vis.apply_to_ItemListItem(item, @ch3)) assert_equal("
  • ", @vis.apply_to_ItemListItem(item, @ch0)) end def test_apply_to_EnumListItem item = EnumListItem.new assert_equal("
  • a
  • ", @vis.apply_to_EnumListItem(item, @ch1)) assert_equal("
  • a\nb
  • ", @vis.apply_to_EnumListItem(item, @ch2)) assert_equal("
  • a
  • ", @vis.apply_to_EnumListItem(item, @ch3)) assert_equal("
  • ", @vis.apply_to_EnumListItem(item, @ch0)) end def test_apply_to_DescListItem tr = Tree.new_with_document_struct(DocumentStructure::RD) tr.root = DocumentElement.new di1, di2 = nil tr.root.build do new DescList do di1 = new DescListItem do make_term do new StringElement, "desclist 1" end end di2 = new DescListItem do make_term do new StringElement, "desclist 2" end end end end @vis.prepare_labels(tr, "label:") assert_equal(expect_for_di1_with_child("term1", @ch1), @vis.apply_to_DescListItem(di1, ["term1"], @ch1)) assert_equal(expect_for_di1_with_child("term1term2", @ch1), @vis.apply_to_DescListItem(di1, ["term1", "term2"], @ch1)) assert_equal(expect_for_di1_with_child("term1", @ch2), @vis.apply_to_DescListItem(di1, ["term1"], @ch2)) assert_equal(expect_for_di1_with_child("term1", @ch3), @vis.apply_to_DescListItem(di1, ["term1"], @ch3)) assert_equal(expect_for_di1_no_child("term1"), @vis.apply_to_DescListItem(di1, ["term1"], @ch0)) assert_equal(expect_for_di1_no_child("term1term2"), @vis.apply_to_DescListItem(di1, ["term1", "term2"], @ch0)) assert_equal(expect_for_di2_with_child("term1", @ch1), @vis.apply_to_DescListItem(di2, ["term1"], @ch1)) assert_equal(expect_for_di2_no_child("term1"), @vis.apply_to_DescListItem(di2, ["term1"], @ch0)) end def expect_for_di1_with_child(term, children) %|
    #{term}
    \n| + %|
    \n#{children.join("\n").chomp}\n
    | end def expect_for_di1_no_child(term) %|
    #{term}
    | end def expect_for_di2_with_child(term, children) %|
    #{term}
    \n| + %|
    \n#{children.join("\n").chomp}\n
    | end def expect_for_di2_no_child(term) %|
    #{term}
    | end # MethodListItem ... def check_apply_to_NonterminalInline(type, tag) element = type.new name = type.to_s.sub(/RD::/, "") assert_equal("<#{tag}>a", @vis.send("apply_to_#{name}", element, @ch1)) assert_equal("<#{tag}>ab", @vis.send("apply_to_#{name}", element, @ch2)) assert_equal("<#{tag}>a\n", @vis.send("apply_to_#{name}", element, @ch3)) assert_equal("<#{tag}>", @vis.send("apply_to_#{name}", element, @ch0)) end def test_apply_to_Emphasis check_apply_to_NonterminalInline(Emphasis, "em") end def test_apply_to_Code check_apply_to_NonterminalInline(Code, "code") end def test_apply_to_Var check_apply_to_NonterminalInline(Var, "var") end def test_apply_to_Keyboard check_apply_to_NonterminalInline(Keyboard, "kbd") end def test_apply_to_StringElement se1 = StringElement.new "a" assert_equal("a", @vis.apply_to_StringElement(se1)) se2 = StringElement.new "a\nb" assert_equal("a\nb", @vis.apply_to_StringElement(se2)) se_empty = StringElement.new "" assert_equal("", @vis.apply_to_StringElement(se_empty)) se_ws = StringElement.new " " assert_equal(" ", @vis.apply_to_StringElement(se_ws)) se_lt = StringElement.new "<" assert_equal("<", @vis.apply_to_StringElement(se_lt)) se_gt = StringElement.new ">" assert_equal(">", @vis.apply_to_StringElement(se_gt)) se_amp = StringElement.new "&" assert_equal("&", @vis.apply_to_StringElement(se_amp)) end def test_apply_to_Verb verb1 = Verb.new "a" assert_equal("a", @vis.apply_to_Verb(verb1)) verb2 = Verb.new "a\nb" assert_equal("a\nb", @vis.apply_to_Verb(verb2)) verb_empty = Verb.new "" assert_equal("", @vis.apply_to_Verb(verb_empty)) verb_ws = Verb.new " " assert_equal(" ", @vis.apply_to_Verb(verb_ws)) verb_lt = Verb.new "<" assert_equal("<", @vis.apply_to_Verb(verb_lt)) verb_gt = Verb.new ">" assert_equal(">", @vis.apply_to_Verb(verb_gt)) verb_amp = Verb.new "&" assert_equal("&", @vis.apply_to_Verb(verb_amp)) end def test_apply_to_Footnote @vis.prepare_footnotes(@tr_fn) assert_equal([], @vis.foottexts) assert_equal(expect_for_footnote(1), @vis.apply_to_Footnote(@fn1_fn, ["footnote 1"])) assert_equal([["footnote 1"]], @vis.foottexts) assert_equal(expect_for_footnote(2), @vis.apply_to_Footnote(@fn2_fn, ["footnote", " 2"])) assert_equal([["footnote 1"], ["footnote", " 2"]], @vis.foottexts) @vis.prepare_footnotes(@tr2_fn) assert_raises(ArgumentError) do @vis.apply_to_Footnote(@fn2_fn, []) end end def expect_for_footnote(num) %Q||+ %Q|*#{num}| end def test_get_footnote_num @vis.prepare_footnotes(@tr_fn) assert_equal(1, @vis.get_footnote_num(@fn1_fn)) assert_equal(2, @vis.get_footnote_num(@fn2_fn)) assert_equal(nil, @vis.get_footnote_num(Footnote.new)) @vis.prepare_footnotes(@tr2_fn) assert_equal(nil, @vis.get_footnote_num(@fn1_fn)) assert_raises(ArgumentError) do @vis.get_footnote_num(Headline.new(1)) end end def test_prepare_footnotes @vis.prepare_footnotes(@tr_fn) assert_equal([@fn1_fn, @fn2_fn], @vis.footnotes) @vis.prepare_footnotes(@tr2_fn) assert_equal([], @vis.footnotes) end def test_add_foottext @vis.prepare_footnotes(@tr_fn) assert_equal([], @vis.foottexts) @vis.add_foottext(@vis.get_footnote_num(@fn1_fn), ["footnote 1"]) assert_equal([["footnote 1"]], @vis.foottexts) @vis.add_foottext(@vis.get_footnote_num(@fn2_fn), ["footnote", "2"]) assert_equal([["footnote 1"], ["footnote", "2"]], @vis.foottexts) assert_raises(ArgumentError) do @vis.add_foottext(3, "footnote 3") end end def test_apply_to_Foottext @vis.prepare_footnotes(@tr_fn) exp1 = %|| + %|*1| + %|footnote 1
    | assert_equal(exp1, @vis.apply_to_Foottext(@fn1_fn, ["footnote 1"])) exp2 = %|| + %|*2| + %|footnote 2
    | assert_equal(exp2, @vis.apply_to_Foottext(@fn2_fn, ["footnote", " 2"])) @vis.prepare_footnotes(@tr2_fn) assert_raises(ArgumentError) do @vis.apply_to_Foottext(@fn1_fn, ["footnote 1"]) end end def test_make_foottext @vis.prepare_footnotes(@tr_fn) ft1 = ["footnote 1"] ft2 = ["footnote", " 2"] @vis.add_foottext(@vis.get_footnote_num(@fn1_fn), ft1) @vis.add_foottext(@vis.get_footnote_num(@fn2_fn), ft2) exp1 = @vis.apply_to_Foottext(@fn1_fn, ft1) exp2 = @vis.apply_to_Foottext(@fn2_fn, ft2) assert_equal(%|
    \n

    \n#{exp1}\n#{exp2}\n

    |, @vis.make_foottext) @vis.prepare_footnotes(@tr2_fn) assert_equal(nil, @vis.make_foottext) end def test_hyphen_escape assert_equal("­­", @vis.hyphen_escape("--")) assert_equal("-", @vis.hyphen_escape("-")) assert_equal("­­-", @vis.hyphen_escape("---")) assert_equal("- -", @vis.hyphen_escape("- -")) assert_equal("aa­­bb", @vis.hyphen_escape("aa--bb")) assert_equal("", @vis.hyphen_escape("")) end end rdtool-0.6.38/doc/0000755000004100000410000000000012057274011013707 5ustar www-datawww-datardtool-0.6.38/doc/rd-draft.html0000644000004100000410000006156312057274011016313 0ustar www-datawww-data doc/rd-draft.rd

    RD working draft

    Japanese version is here.

    What is RD?

    RD is Ruby's POD, embeddable documentation format in script file.

    RD is influenced mainly from plain2, a program to translate from plain text to some mark-up language. So, RD looks like plain text, and its simpleness and neatness make it easy to read and write.

    How does the interpreter work for RD?

    Ruby's interpreter, ruby, simply ignores text between a line beginning with "=begin" and one beginning with "=end". So, RD is not only embeddable. You can write anything between =begin and =end. RD is one of them, but RD will be a standard one.*1

    Concepts and Syntax

    Element, Block and Inline

    We will use the term "Element" for features of RD which add information of document structure to text. In addition, we use a term "Block" for Elements for large and global structures, and a term "Inline" for ones for small and local decorations.

    Paragraph, headline or list is a kind of Block. RD uses indentation and special characters to describe Blocks. You can also write complicated structure to nested Blocks. And this style of Block looks naturally like plain text format. See Block for details.

    Emphasis, code or reference is a kind of Inline. Parentheses and special characters, like ((? ... ?)), are used for Inline. Almost all Inline may be nested inside each other. See Inline for more details.

    Block

    Basic Syntax

    Block has line oriented syntax. i.e. each character on the same line belongs to the same Block. And the indentation of the line represents nesting level and type of Block. The first character of the line represents the type of Block.

    Concepts and Terms
    Baseline
    Baseline is standard depth of indent. Relative depth between indent of one line and Baseline affects its Block-type.
    Head Char
    Head Char is the first character of line, except whitespace.
    STRINGLINE
    STRINGLINE is line which consists of strings. STRINGLINE doesn't have "*", "(num)", ":", "=" nor "+" as Head Char. But if the line is indented, "=" and "+" can be Head Char.
    WHITELINE
    WHITELINE is a line which consists of whitespace, "\s", "\t" and "\n".
    Comment
    A line which is matched with /^#/ is regarded as a comment.
    How Baseline is defined and how it works

    At the top level, Baseline is at left end, i.e., indent is 0. In List, Baseline is defined by first Block of ListItem. For example,

    Example: "|" means Baseline
      |Regard this line as one of TextBlock's in top level.
      |<- So this Baseline is at the left-most position.
        *|it is in List. (1)
         |<- this Baseline is defined by the marked with a (1).
        *    |Different Item of List can have different Baseline inside.
             |<- So this Baseline differs from one of this list's first item.

    |Regard this line as one of TextBlock's in top level. |<- So this Baseline is at the left-most position.

    • |it is in List. (1) |<- this Baseline is defined by the marked with a (1).
    • |Different Items in Lists can have different Baselines inside. |<- So this Baseline differs from the one of this list's first item.

    If one Block is nested in another Block, the Baseline of the inside Blocks is deeper than the Baseline of outside Blocks.

    The relative position between Baseline and indent affects the type of Block. If a STRINGLINE has same indent with Baseline, it belongs to TextBlock, otherwise, i.e. it has deeper indent than Baseline, it belongs to Verbatim.

    Types of Block

    Headline

    Headline consists of a line which Head Char is "=" or "+". And Headline can't include more than one line. Headline can be on only top level.

    Example:
    |<- Regard this as top level Baseline.
    = Headline 1.
    === Headline 1.1.1.
    + Headline 1.1.1.1.1.

    Headline 1.

    Headline 1.1.1.

    Headline 1.1.1.1.1.

    Headline Mark represents level of Headline. See following figure. first Mark is biggest one, and last Mark has two parts.

    Fig: Headline Marks
    =
    ==
    ===
    ====
    +
    ++

    Text which follows Mark is title of Headline. It is also used as Label of Reference.

    Title of Headline can contain Inlines except for Reference and Footnote.

    Include

    Include is a line that line head "<<<" and included file name. You can input from other file text, both RD and target format, with Include.

    When you include RD file, included file name have to have ".rd" or ".rb" as suffix, like "foo.rd", and write full name (not full path) of file after "<<<". For example,

    <<< foo.rd

    When you include target format file, include file name have to have suffix of target format standard one, for example ".html" in the case of outputting HTML, ".texi" in the case of outputting Texinfo, and write base name of file after "<<<". For example,

    <<< foo

    RD formatter include "foo.html" to output HTML, and include "foo.texi" to output Texinfo. If you want to use Include for target format, you should prepare plural type of included file.

    TextBlock

    TextBlock is composed of STRINGLINEs, but the STRINGLINEs must have same indent with Baseline. If its indent is deeper than Baseline, the STRINGLINE belongs to Verbatim.

    TextBlock can include Inline inside.

    Example:
    |
    This is TextBlock. 
    Second line of same TextBlock.
      This line is not TextBlock, but Verbatim.
    * And this line is List. (But this line is exactly TextBlock in ListItem.)

    And this example is formatted such like:

    This is TextBlock. Second line of same TextBlock.

    This line is not TextBlock, but Verbatim.
    • And this line is List. (But this line is exactly TextBlock in ListItem.)
    Verbatim

    You can use Verbatim to cite Ruby script. Verbatim is composed of STRINGLINEs, and they must be indented deeper than Baseline. Verbatim can also include a line whose Head Char is "*", "(1)" and ":", But it can't be first line of Verbatim, it is regarded as List. Verbatim can't include a line which is indented shallower than first line. Verbatim can include WHITELINE.

    You can't use Inline in Verbatim.

    Example:
     This is Verbatim.
       Even if a line is indented deeper than first line, it is also in same
       Verbatim.
     * A line seems like list is also included in Verbatim.
    But if the line is indented shallower, it is not in same Verbatim.
    It is in other Verbatim.

    And this example is formatted such like:

    This is Verbatim.
      Even if a line is indented deeper than first line, it is also in same
      Verbatim.
    * A line seems like list is also included in Verbatim.
    But if the line is indented shallower, it is not in same Verbatim.
    It is in other Verbatim.
    List

    List is special Block. List is composed of ListItems, and ListItem is composed of Blocks. So List can include Blocks inside, even also List itself.*2

    ListItem can include WHITELINE, and TextBlock can't include WHITELINE, so when you want to write 2 TextBlock inside ListItem, put a WHITELINE between TextBlocks.

    There is 3 type of List, "ItemList", "EnumList", "DescList" and "MethodList.

    ItemList

    ItemList is simple and not numbered List. ItemListItem begins by a line whose Head Char is "*", and first Block of ItemListItem must be TextBlock.

    Example:
    * first item of parent list
        * first item of sub list
        * second item of sub list
      text block ( line of first item of parent list)

    And this example is formatted such like:

    • first item of parent list

      • first item of sub list
      • second item of sub list

      text block ( line of first item of parent list)

    EnumList

    EnumList is numbered List. EnumListItem starts with a line whose Head Char is "(num)"(num is integer). EnumList is same as ItemList on other points.

    Example:
    (1) first line of parent list
          * first line of sub list(ItemList)
    (2) second list of parent list
    (10) number is ignored...

    And this example is formatted such like:

    1. first line of parent list
      • first line of sub list(ItemList)
    2. second list of parent list
    3. number is ignored...
    DescList

    DescList is List for descriptions. DescListItem has 2 part. One is Term part, the other is Description part. Term of DescListItem is also used as Label for Reference.

    Term part is composed of a line whose Head Char is ":", and Term part is same as Headline, except that a line of Term part can be indented.

    Description part is starts with next line of Term part. Baseline of Description part must be same or deeper than term of Term part of its pair. For example, following style is illegal.

    Example:
    :   |Term
      |Description.

    Description part can include Blocks. List can be first Block of Description part. Term part can contain Inlines except for Reference and Footnote.

    Example:
    :Term
       first line of Description
       second line of Description
    :Term2
       * also include List
       * ...

    And this example is formatted such like:

    Term
    first line of definition. second line of definition
    Term2
    • also include list
    • ...
    MethodList

    MethodList is the special type of DescList for explanation methods of your classes. MethodList is similar with DescList in almost all part, but it is labeled differently. RD formatters know it is some kind of program code, e.g. method or constants of class in Ruby or function prototype in C..., which is on Term part of MethodList. So, MethodList is labeled without the part which seems to be parameters of methods. See Label and Reference for more detail.

    Each item of MethodList has Term part and Description part like DescList. And its Term part start with its Head Char, "---". Its Description part can contain TextBlock, Verbatim and List. But you shouldn't write MethodList in any kind of List. RD will come to deny it possibly in future.

    Example:
    --- Array#each {|i| ... } # => labeled as "Array#each"
          yield block for each item.
    --- Array#index(val) # => labeled as "Array#index"
          return index of first item which equals with ((|val|)). if it hasn't
          same item, return (({nil})).

    And this example is formatted such like:

    Array#each {|i| ... }
    yield block for each item.
    Array#index(val)
    return index of first item which equals with val. if it hasn't same item, return nil.

    Some formatter assumes it is Ruby's methods, constants or etc. which is in Term part of MethodList. it can format term part of MethodList intelligently, but you have to write according as specific formula to make the best of its feature.

    Standard Ruby class reference formula is suggested such like:

    instance method

    instance method method of class Class

    Class#method(its params  ...) { parameter block }
    class method (class singleton method)

    class method method of class Class

    Class.method(its params ...) { parameter block }
    class constants

    constant Const of class Class

    Class::Const
    functions (private methods on top level)

    function func

    function#func(its params ...) { parameter block }

    Ruby use some symbol characters (e.g. [], []=, +, - or <<) for the names of methods. ruby, Ruby interpreter, parses them with different manner from normal methods, but write them as same as others in this formula.

    Example:
      --- Array#[](key)
            return value which in at index ((|key|)).
      --- Array#[]=(key, value)
            put ((|value|)) into cell of index ((|key|)).
      --- Array#+(other)
            return concatenated (({Array})).

    Inline

    You can use Inline in TextBlock, Headline and Term part of DescList. Common style of parentheses is used for Inline. Inline can nest each other.

    in following list of Inlines, preformatted text is on left hand side and postformatted text is on right hand side.

    ((*Em*)) => Em
    Emphasis.
    (({while gets...})) => while gets...
    Code.
    ((|var|)) => var
    Var.*3
    ((%ruby -v%)) => ruby -v
    Keyboard.
    ((:Term:))

    => Term

    Term of Index.

    ((<Identity or URL>))

    => Identity or URL

    Link, Reference. See Label and Reference for more detail.

    ((-Footnote-))

    => *4

    Footnote.

    (('verb')) => verb
    Inline Verbatim.

    Label and Reference

    Reference needs Label. In RD, only title of Headline and Term of DescList and MethodList is regarded as Label. So, you must choose different titles for different Headlines. This problem has not resolved yet.

    How to RD generates Label from Headline, DescList or MethodList

    Title of Headline and Term part of DescList and MethodList are regarded as Label. But they can contain Inlines, so the situation isn't so simple.

    First, MethodList is special in the part of Labeling. Term part of MethodList can't contain Inlines, and RD assumes it is method reference or such thing which is in Term part of MethodList. So it is Labeled under following rules.

    1. It is regarded as Label which is before a character of "(" or "{".*5

    Following example will help you to understand how this rule works. the Label which is generated from the term part of MethodList is after mark of "# =>".

    Example:
      --- Array.new([size[, val]]) # => Array.new
      --- Array#[]=(key, val) # => Array#[]=
      --- Array#each { ... } # => Array#each
      --- void rb_define_method(VALUE class, ...) # => void rb_define_method

    Second, in the case of title of Headline or term part of DescList, there is not such a special rule. But you can use Inlines for text on them, so there are rules to strip Inline mark-ups from text.

    1. Any Inline mark-ups makes any difference to Label. So, both

      = ((*Headline*))

      and

      = Headline

      are Labeled as "Headline".

    2. But white spaces which is after open parenthesis and before close parenthesis of Inline are striped when RD generates Label from it. So, both

      = ((* Headline  *))

      and

      = ((*Headline*))

      are Labeled as "Headline".

    Reference

    You can refer Labeled element with Reference which is a kind of Inline marked up with ((<...>)).

    Most simple use of Reference is to write Label inside parenthesis.

    ((<Label>))

    This works as reference to Label of "Label" and text "Label" is used also for display such like: Label.*6

    When you want to refer a resource pointed with URL, write such like:

    ((<URL:http://www.ruby-lang.org/en/raa.html>))

    RD formatter will format it as hyper-link to its URL if possible such like:<URL:http://www.ruby-lang.org/en/raa.html>.

    When you want to use other text than Label for display, write such like:

    ((<Text for display|Label>))

    "Text for display" is used for display and "Label" is used as Label to refer such like: Text for display

    Text for display can contain some Inline, except for Footnotes and Reference.

    In Reference, "|" and "/" are syntax keywords. So if you will write them inside Reference, you have to double-quote the part it's inside, such like:

    ((<"Bar | inside display text"|Label>))

    Bar | inside display text

    The situations are same whether you will write them inside Substitution part, Filename part and Label part.

    Of course, you can use the text for the display for Reference to URL resource.

    ((<Ruby Application Archive|URL:http://www.ruby-lang.org/en/raa.html>))

    Ruby Application Archive

    When the text for the display is omitted, you can use Inline for Label.

    ((<((*Label*))>))

    Label


    *1 If you are interested in others, see rubyapi2 <URL:http://www.ueda.info.waseda.ac.jp/~igarashi/ruby/xml.html#rubyapi2> for example.
    *2 But List can't include Headline nor Include.
    *3 You can read very good explanation about Var in texinfo.info.
    *4Footnote
    *5 text inside "(...)" is regarded as parameters of method, and text inside "{...}" is regarded as parameter block of methods.
    *6 There is no element Labeled "Label", so it doesn't seems to be Reference probably.

    rdtool-0.6.38/doc/rd-draft.rd0000644000004100000410000004065012057274011015746 0ustar www-datawww-data= RD working draft Japanese version is (()). == What is RD? RD is Ruby's POD, embeddable documentation format in script file. RD is influenced mainly from plain2, a program to translate from plain text to some mark-up language. So, RD looks like plain text, and its simpleness and neatness make it easy to read and write. == How does the interpreter work for RD? Ruby's interpreter, (({ruby})), simply ignores text between a line beginning with "(({=begin}))" and one beginning with "(({=end}))". So, RD is not only embeddable. You can write anything between (({=begin})) and (({=end})). RD is one of them, but RD will be a standard one.((- If you are interested in others, see rubyapi2 (()) for example. -)) == Concepts and Syntax === Element, Block and Inline We will use the term "Element" for features of RD which add information of document structure to text. In addition, we use a term "(())" for Elements for large and global structures, and a term "(())" for ones for small and local decorations. Paragraph, headline or list is a kind of Block. RD uses indentation and special characters to describe Blocks. You can also write complicated structure to nested Blocks. And this style of Block looks naturally like plain text format. See (()) for details. Emphasis, code or reference is a kind of Inline. Parentheses and special characters, like (('((? ... ?))')), are used for Inline. Almost all Inline may be nested inside each other. See (()) for more details. === Block ==== Basic Syntax Block has line oriented syntax. i.e. each character on the same line belongs to the same Block. And the indentation of the line represents nesting level and type of Block. The first character of the line represents the type of Block. + Concepts and Terms :Baseline Baseline is standard depth of indent. Relative depth between indent of one line and Baseline affects its Block-type. :Head Char Head Char is the first character of line, except whitespace. :STRINGLINE STRINGLINE is line which consists of strings. STRINGLINE doesn't have "(({*}))", "(({(((|num|)))}))", "(({:}))", "(({=}))" nor "(({+}))" as Head Char. But if the line is indented, "(({=}))" and "(({+}))" can be Head Char. :WHITELINE WHITELINE is a line which consists of whitespace, "(({\s}))", "(({\t}))" and "(({\n}))". :Comment A line which is matched with (({/^#/})) is regarded as a comment. + How Baseline is defined and how it works At the top level, Baseline is at left end, i.e., indent is 0. In List, Baseline is defined by first Block of ListItem. For example, Example: "|" means Baseline |Regard this line as one of TextBlock's in top level. |<- So this Baseline is at the left-most position. *|it is in List. (1) |<- this Baseline is defined by the marked with a (1). * |Different Item of List can have different Baseline inside. |<- So this Baseline differs from one of this list's first item. |Regard this line as one of TextBlock's in top level. |<- So this Baseline is at the left-most position. *|it is in List. (1) |<- this Baseline is defined by the marked with a (1). * |Different Items in Lists can have different Baselines inside. |<- So this Baseline differs from the one of this list's first item. If one Block is nested in another Block, the Baseline of the inside Blocks is deeper than the Baseline of outside Blocks. The relative position between Baseline and indent affects the type of Block. If a (()) has same indent with Baseline, it belongs to (()), otherwise, i.e. it has deeper indent than Baseline, it belongs to (()). ==== Types of Block + Headline Headline consists of a line which (()) is "(({=}))" or "(({+}))". And Headline can't include more than one line. Headline can be on only top level. Example: |<- Regard this as top level Baseline. = Headline 1. === Headline 1.1.1. + Headline 1.1.1.1.1. = Headline 1. === Headline 1.1.1. + Headline 1.1.1.1.1. Headline Mark represents level of Headline. See following figure. first Mark is biggest one, and last Mark has two parts. Fig: Headline Marks = == === ==== + ++ Text which follows Mark is title of Headline. It is also used as Label of (()). Title of Headline can contain (())s except for (()) and Footnote. + Include Include is a line that line head "(({<<<}))" and included file name. You can input from other file text, both RD and target format, with Include. When you include RD file, included file name have to have ".rd" or ".rb" as suffix, like "foo.rd", and write full name (not full path) of file after "(({<<<}))". For example, <<< foo.rd When you include target format file, include file name have to have suffix of target format standard one, for example ".html" in the case of outputting HTML, ".texi" in the case of outputting Texinfo, and write base name of file after "(({<<<}))". For example, <<< foo RD formatter include "foo.html" to output HTML, and include "foo.texi" to output Texinfo. If you want to use Include for target format, you should prepare plural type of included file. + TextBlock TextBlock is composed of (())s, but the (())s must have same indent with (()). If its indent is deeper than (()), the (()) belongs to (()). TextBlock can include (()) inside. Example: | This is TextBlock. Second line of same TextBlock. This line is not TextBlock, but Verbatim. * And this line is List. (But this line is exactly TextBlock in ListItem.) And this example is formatted such like: This is TextBlock. Second line of same TextBlock. This line is not TextBlock, but Verbatim. * And this line is List. (But this line is exactly TextBlock in ListItem.) + Verbatim You can use Verbatim to cite Ruby script. Verbatim is composed of (())s, and they must be indented deeper than (()). Verbatim can also include a line whose (()) is "(({*}))", "(({(1)}))" and "(({:}))", But it can't be first line of Verbatim, it is regarded as (()). Verbatim can't include a line which is indented shallower than first line. Verbatim can include (()). You can't use (()) in Verbatim. Example: This is Verbatim. Even if a line is indented deeper than first line, it is also in same Verbatim. * A line seems like list is also included in Verbatim. But if the line is indented shallower, it is not in same Verbatim. It is in other Verbatim. And this example is formatted such like: This is Verbatim. Even if a line is indented deeper than first line, it is also in same Verbatim. * A line seems like list is also included in Verbatim. But if the line is indented shallower, it is not in same Verbatim. It is in other Verbatim. + List List is special (()). List is composed of ListItems, and ListItem is composed of Blocks. So List can include Blocks inside, even also List itself.((- But List can't include (()) nor (()). -)) ListItem can include (()), and (()) can't include WHITELINE, so when you want to write 2 TextBlock inside ListItem, put a WHITELINE between TextBlocks. There is 3 type of List, "(())", "(())", "(())" and "(()). ++ ItemList ItemList is simple and not numbered List. ItemListItem begins by a line whose (()) is "(({*}))", and first Block of ItemListItem must be (()). Example: * first item of parent list * first item of sub list * second item of sub list text block ( line of first item of parent list) And this example is formatted such like: * first item of parent list * first item of sub list * second item of sub list text block ( line of first item of parent list) ++ EnumList EnumList is numbered List. EnumListItem starts with a line whose (()) is "(({(((|num|)))}))"(((|num|)) is integer). EnumList is same as (()) on other points. Example: (1) first line of parent list * first line of sub list(ItemList) (2) second list of parent list (10) number is ignored... And this example is formatted such like: (1) first line of parent list * first line of sub list(ItemList) (2) second list of parent list (10) number is ignored... ++ DescList DescList is List for descriptions. DescListItem has 2 part. One is Term part, the other is Description part. Term of DescListItem is also used as Label for (()). Term part is composed of a line whose (()) is "(({:}))", and Term part is same as (()), except that a line of Term part can be indented. Description part is starts with next line of Term part. (()) of Description part must be same or deeper than term of Term part of its pair. For example, following style is illegal. Example: : |Term |Description. Description part can include (())s. (()) can be first Block of Description part. Term part can contain (())s except for (()) and (()). Example: :Term first line of Description second line of Description :Term2 * also include List * ... And this example is formatted such like: :Term first line of definition. second line of definition :Term2 * also include list * ... ++ MethodList MethodList is the special type of (()) for explanation methods of your classes. MethodList is similar with (()) in almost all part, but it is labeled differently. RD formatters know it is some kind of program code, e.g. method or constants of class in Ruby or function prototype in C..., which is on Term part of MethodList. So, MethodList is labeled without the part which seems to be parameters of methods. See ((