pdoc 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +34 -0
- data/Rakefile +46 -0
- data/bin/pdoc +58 -0
- data/lib/pdoc.rb +32 -0
- data/lib/pdoc/error.rb +4 -0
- data/lib/pdoc/generators.rb +6 -0
- data/lib/pdoc/generators/abstract_generator.rb +16 -0
- data/lib/pdoc/generators/html.rb +8 -0
- data/lib/pdoc/generators/html/helpers.rb +256 -0
- data/lib/pdoc/generators/html/page.rb +71 -0
- data/lib/pdoc/generators/html/syntax_highlighter.rb +41 -0
- data/lib/pdoc/generators/html/template.rb +37 -0
- data/lib/pdoc/generators/html/website.rb +194 -0
- data/lib/pdoc/generators/json.rb +15 -0
- data/lib/pdoc/generators/pythonesque.rb +105 -0
- data/lib/pdoc/models.rb +47 -0
- data/lib/pdoc/models/argument.rb +37 -0
- data/lib/pdoc/models/base.rb +107 -0
- data/lib/pdoc/models/callable.rb +19 -0
- data/lib/pdoc/models/class.rb +28 -0
- data/lib/pdoc/models/class_method.rb +18 -0
- data/lib/pdoc/models/class_property.rb +9 -0
- data/lib/pdoc/models/constant.rb +9 -0
- data/lib/pdoc/models/constructor.rb +14 -0
- data/lib/pdoc/models/container.rb +114 -0
- data/lib/pdoc/models/entity.rb +54 -0
- data/lib/pdoc/models/instance_method.rb +18 -0
- data/lib/pdoc/models/instance_property.rb +9 -0
- data/lib/pdoc/models/mixin.rb +10 -0
- data/lib/pdoc/models/namespace.rb +10 -0
- data/lib/pdoc/models/root.rb +27 -0
- data/lib/pdoc/models/section.rb +19 -0
- data/lib/pdoc/models/signature.rb +27 -0
- data/lib/pdoc/models/utility.rb +11 -0
- data/lib/pdoc/parser.rb +109 -0
- data/lib/pdoc/parser/argument_description_nodes.rb +21 -0
- data/lib/pdoc/parser/basic_nodes.rb +31 -0
- data/lib/pdoc/parser/description_nodes.rb +42 -0
- data/lib/pdoc/parser/documentation_nodes.rb +483 -0
- data/lib/pdoc/parser/ebnf_arguments_nodes.rb +58 -0
- data/lib/pdoc/parser/ebnf_expression_nodes.rb +227 -0
- data/lib/pdoc/parser/fragment.rb +55 -0
- data/lib/pdoc/parser/section_content_nodes.rb +19 -0
- data/lib/pdoc/parser/tags_nodes.rb +14 -0
- data/lib/pdoc/parser/treetop_files/argument_description.treetop +31 -0
- data/lib/pdoc/parser/treetop_files/basic.treetop +41 -0
- data/lib/pdoc/parser/treetop_files/description.treetop +7 -0
- data/lib/pdoc/parser/treetop_files/documentation.treetop +75 -0
- data/lib/pdoc/parser/treetop_files/ebnf_arguments.treetop +33 -0
- data/lib/pdoc/parser/treetop_files/ebnf_expression.treetop +70 -0
- data/lib/pdoc/parser/treetop_files/ebnf_javascript.treetop +54 -0
- data/lib/pdoc/parser/treetop_files/events.treetop +17 -0
- data/lib/pdoc/parser/treetop_files/section_content.treetop +8 -0
- data/lib/pdoc/parser/treetop_files/tags.treetop +31 -0
- data/lib/pdoc/runner.rb +110 -0
- data/lib/pdoc/treemaker.rb +94 -0
- data/pdoc.gemspec +31 -0
- data/templates/html/assets/images/pdoc/alias.png +0 -0
- data/templates/html/assets/images/pdoc/class.png +0 -0
- data/templates/html/assets/images/pdoc/class_deprecated.png +0 -0
- data/templates/html/assets/images/pdoc/class_method.png +0 -0
- data/templates/html/assets/images/pdoc/class_property.png +0 -0
- data/templates/html/assets/images/pdoc/constant.png +0 -0
- data/templates/html/assets/images/pdoc/constructor.png +0 -0
- data/templates/html/assets/images/pdoc/deprecated.png +0 -0
- data/templates/html/assets/images/pdoc/description.png +0 -0
- data/templates/html/assets/images/pdoc/information.png +0 -0
- data/templates/html/assets/images/pdoc/instance_method.png +0 -0
- data/templates/html/assets/images/pdoc/instance_property.png +0 -0
- data/templates/html/assets/images/pdoc/method.png +0 -0
- data/templates/html/assets/images/pdoc/method_deprecated.png +0 -0
- data/templates/html/assets/images/pdoc/mixin.png +0 -0
- data/templates/html/assets/images/pdoc/namespace.png +0 -0
- data/templates/html/assets/images/pdoc/property.png +0 -0
- data/templates/html/assets/images/pdoc/related_to.png +0 -0
- data/templates/html/assets/images/pdoc/search-background.png +0 -0
- data/templates/html/assets/images/pdoc/section-background.png +0 -0
- data/templates/html/assets/images/pdoc/section.png +0 -0
- data/templates/html/assets/images/pdoc/selected-section-background.png +0 -0
- data/templates/html/assets/images/pdoc/subclass.png +0 -0
- data/templates/html/assets/images/pdoc/superclass.png +0 -0
- data/templates/html/assets/images/pdoc/utility.png +0 -0
- data/templates/html/assets/javascripts/pdoc/application.js +478 -0
- data/templates/html/assets/javascripts/pdoc/prototype.js +4874 -0
- data/templates/html/assets/javascripts/pdoc/tabs.js +506 -0
- data/templates/html/assets/stylesheets/pdoc/api.css +677 -0
- data/templates/html/assets/stylesheets/pdoc/pygments.css +62 -0
- data/templates/html/helpers.rb +35 -0
- data/templates/html/index.erb +18 -0
- data/templates/html/item_index.js.erb +6 -0
- data/templates/html/layout.erb +67 -0
- data/templates/html/leaf.erb +22 -0
- data/templates/html/node.erb +30 -0
- data/templates/html/partials/class_relationships.erb +19 -0
- data/templates/html/partials/classes.erb +7 -0
- data/templates/html/partials/constructor.erb +5 -0
- data/templates/html/partials/description.erb +5 -0
- data/templates/html/partials/link_list.erb +1 -0
- data/templates/html/partials/method_signatures.erb +14 -0
- data/templates/html/partials/methodized_note.erb +9 -0
- data/templates/html/partials/mixins.erb +7 -0
- data/templates/html/partials/namespaces.erb +7 -0
- data/templates/html/partials/related_utilities.erb +5 -0
- data/templates/html/partials/relationships.erb +11 -0
- data/templates/html/partials/short_description_list.erb +7 -0
- data/templates/html/partials/title.erb +22 -0
- data/templates/html/section.erb +18 -0
- data/test/unit/parser/argument_description_test.rb +40 -0
- data/test/unit/parser/basic_test.rb +55 -0
- data/test/unit/parser/description_test.rb +34 -0
- data/test/unit/parser/documentation_test.rb +520 -0
- data/test/unit/parser/ebnf_arguments_test.rb +81 -0
- data/test/unit/parser/ebnf_expression_test.rb +382 -0
- data/test/unit/parser/ebnf_javascript_test.rb +37 -0
- data/test/unit/parser/events_test.rb +27 -0
- data/test/unit/parser/section_content_test.rb +44 -0
- data/test/unit/parser/tags_test.rb +39 -0
- data/test/unit/parser/test_fragment.rb +80 -0
- data/test/unit/parser_test_helper.rb +62 -0
- data/test/unit/runner/basic_test.rb +14 -0
- data/test/unit/templates/html_helpers_test.rb +25 -0
- metadata +222 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
|
|
2
|
+
|
|
3
|
+
class BasicTest < Test::Unit::TestCase
|
|
4
|
+
include PDocTestHelper
|
|
5
|
+
include Basic
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@parser = BasicParser.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_fixture_loader
|
|
12
|
+
assert_file_parsed "test.txt"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_space
|
|
16
|
+
assert_parsed " "
|
|
17
|
+
assert_equal Space, parse(" ").elements.first.class
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_text_line
|
|
21
|
+
text_line = "\n * here's some text "
|
|
22
|
+
assert_parsed text_line
|
|
23
|
+
assert_equal TextLine, parse(text_line).elements.first.class
|
|
24
|
+
assert_equal "here's some text", parse(text_line).elements.first.to_s.strip
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_line_break
|
|
28
|
+
assert_parsed "\n"
|
|
29
|
+
assert_equal LineBreak, parse("\n").elements.first.class
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_blank_line
|
|
33
|
+
blank_line = "\n * \n"
|
|
34
|
+
assert_parsed blank_line
|
|
35
|
+
assert_equal BlankLine, parse(blank_line).elements.first.class
|
|
36
|
+
assert_equal "", parse(blank_line).elements.first.to_s
|
|
37
|
+
|
|
38
|
+
empty = "\n *\n"
|
|
39
|
+
assert_parsed empty
|
|
40
|
+
assert_equal BlankLine, parse(empty).elements.first.class
|
|
41
|
+
assert_equal "", parse(empty).elements.first.to_s
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_comment_start
|
|
45
|
+
starts = "\n /** "
|
|
46
|
+
assert_parsed starts
|
|
47
|
+
assert_equal CommentStart, parse(starts).elements.first.class
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_comment_end
|
|
51
|
+
ends = "\n **/ \n"
|
|
52
|
+
assert_parsed ends
|
|
53
|
+
assert_equal CommentEnd, parse(ends).elements.first.class
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
|
|
2
|
+
|
|
3
|
+
class DescriptionTest < Test::Unit::TestCase
|
|
4
|
+
include PDocTestHelper
|
|
5
|
+
include Basic
|
|
6
|
+
include Description
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@parser = DescriptionParser.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_parsing
|
|
13
|
+
assert_parsed ""
|
|
14
|
+
assert_parsed "\n * hello"
|
|
15
|
+
assert_parsed "\n * \n * hello"
|
|
16
|
+
assert_file_parsed "text.txt"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_description
|
|
20
|
+
fixture = parse_file("text.txt")
|
|
21
|
+
assert_equal String, fixture.to_s.class
|
|
22
|
+
assert_equal "some text", fixture.to_a.first
|
|
23
|
+
assert_equal "aliqua.", fixture.to_a.last
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_truncate
|
|
27
|
+
assert_equal "some text...", parse_file("text.txt").truncate(8)
|
|
28
|
+
assert_equal "some text", parse("\n * some text").truncate()
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_inspect
|
|
32
|
+
assert_equal "#<Description::Text \"some text more t...\">", parse_file("text.txt").inspect
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
|
|
2
|
+
|
|
3
|
+
class DocumentationTest < Test::Unit::TestCase
|
|
4
|
+
include PDocTestHelper
|
|
5
|
+
include Documentation
|
|
6
|
+
@@fixtures = nil
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@parser = DocumentationParser.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def fixtures
|
|
13
|
+
@@fixtures ||= parse_file("ajax.js") # rather hacky, I know.
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_listing_methods
|
|
17
|
+
%w(klass_methods instance_methods constructors constants
|
|
18
|
+
descendants globals klass_properties instance_properties utilities
|
|
19
|
+
klasses).each do |method|
|
|
20
|
+
assert_respond_to fixtures, method
|
|
21
|
+
end
|
|
22
|
+
assert_equal 34, fixtures.size
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_globals
|
|
26
|
+
assert_equal %w[$ $$ Ajax Element Enumerable String Toggle], fixtures.globals.map(&:name).sort
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_descendants
|
|
30
|
+
assert_equal %w[$ $$ Ajax Base Element Enumerable Manager Request Responders String Toggle],
|
|
31
|
+
fixtures.descendants.map(&:name).sort
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_mixins
|
|
35
|
+
assert_equal %w[Enumerable], fixtures.mixins.map(&:name)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_sections
|
|
39
|
+
assert_equal %w[DOM ajax lang], fixtures.sections.map(&:name)
|
|
40
|
+
assert_equal [Section, Section, Section], fixtures.sections.map(&:class)
|
|
41
|
+
assert_equal %w[Ajax], fixtures.sections[1].children.map(&:name)
|
|
42
|
+
assert_equal %w[Ajax Base Manager Request Responders], fixtures.sections[1].descendants.map(&:name)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_find_by_name
|
|
46
|
+
assert_equal "Ajax", fixtures.find_by_name("Ajax").name
|
|
47
|
+
assert_equal "Responders", fixtures.find_by_name("Ajax.Responders").name
|
|
48
|
+
assert_equal nil, fixtures.find_by_name("Foo.bar")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_root
|
|
52
|
+
assert_equal Doc, fixtures.find_by_name("Ajax").root.class
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_namespace
|
|
56
|
+
fixture = fixtures.find_by_name("Ajax")
|
|
57
|
+
assert_equal Namespace, fixture.class
|
|
58
|
+
assert_equal [], fixture.mixins
|
|
59
|
+
assert_equal "Ajax", fixture.name
|
|
60
|
+
assert_equal "ajax", fixture.section.name
|
|
61
|
+
assert_equal "", fixture.namespace_string
|
|
62
|
+
assert_equal nil, fixture.namespace
|
|
63
|
+
assert !fixture.deprecated?
|
|
64
|
+
assert !fixture.alias?
|
|
65
|
+
assert_equal %w[__private__ getTransport], fixture.klass_methods.map(&:name)
|
|
66
|
+
assert_equal %w[activeRequestCount], fixture.klass_properties.map(&:name)
|
|
67
|
+
assert_equal [], fixture.instance_methods
|
|
68
|
+
assert_equal [], fixture.instance_properties
|
|
69
|
+
assert_equal [], fixture.related_utilities
|
|
70
|
+
assert_equal "ajax", fixture.doc_parent.name
|
|
71
|
+
assert_equal %w[ajax], fixture.ancestors.map(&:name)
|
|
72
|
+
assert_equal %w[Base Request Responders], fixture.children.map(&:name)
|
|
73
|
+
assert_equal %w[Base Request Responders], fixture.descendants.map(&:name)
|
|
74
|
+
|
|
75
|
+
fixture = fixtures.find_by_name("Ajax.Responders")
|
|
76
|
+
assert_equal Namespace, fixture.class
|
|
77
|
+
assert !fixture.mixin?
|
|
78
|
+
assert_equal ["Enumerable"], fixture.mixins.map(&:name)
|
|
79
|
+
assert_equal [Mixin], fixture.mixins.map(&:class)
|
|
80
|
+
assert_equal "Responders", fixture.name
|
|
81
|
+
assert_equal "ajax", fixture.section.name
|
|
82
|
+
assert_equal "Ajax", fixture.namespace_string
|
|
83
|
+
assert_equal "Ajax", fixture.namespace.full_name
|
|
84
|
+
assert !fixture.deprecated?
|
|
85
|
+
assert !fixture.alias?
|
|
86
|
+
assert_equal "Ajax", fixture.doc_parent.name
|
|
87
|
+
assert_equal %w[Ajax ajax], fixture.ancestors.map(&:name)
|
|
88
|
+
assert_equal [], fixture.children
|
|
89
|
+
assert_equal [], fixture.descendants
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_mixin
|
|
93
|
+
fixture = fixtures.find_by_name("Enumerable")
|
|
94
|
+
assert_equal Mixin, fixture.class
|
|
95
|
+
assert fixture.mixin?
|
|
96
|
+
assert_equal "Enumerable", fixture.name
|
|
97
|
+
assert_equal "lang", fixture.section.name
|
|
98
|
+
assert_equal "", fixture.namespace_string
|
|
99
|
+
assert_equal nil, fixture.namespace
|
|
100
|
+
assert_equal [], fixture.klass_methods
|
|
101
|
+
assert_equal [], fixture.klass_properties
|
|
102
|
+
assert_equal ["each"], fixture.instance_methods.map(&:name)
|
|
103
|
+
assert_equal [], fixture.instance_properties
|
|
104
|
+
assert_equal [], fixture.related_utilities
|
|
105
|
+
assert_equal "lang", fixture.doc_parent.name
|
|
106
|
+
assert_equal %w[lang], fixture.ancestors.map(&:name)
|
|
107
|
+
assert_equal [], fixture.children
|
|
108
|
+
assert_equal [], fixture.descendants
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_klass
|
|
112
|
+
fixture = fixtures.find_by_name("Ajax.Base")
|
|
113
|
+
assert_equal Klass, fixture.class
|
|
114
|
+
assert_equal "Base", fixture.name
|
|
115
|
+
assert_equal "Ajax", fixture.namespace_string
|
|
116
|
+
assert_equal "Ajax.Base", fixture.full_name
|
|
117
|
+
assert_equal [], fixture.mixins
|
|
118
|
+
assert_equal %w[Request], fixture.subklasses.map(&:name)
|
|
119
|
+
assert !fixture.mixin?
|
|
120
|
+
assert !fixture.subklass?
|
|
121
|
+
assert_equal nil, fixture.superklass
|
|
122
|
+
assert fixture.superklass?
|
|
123
|
+
assert_equal "ajax", fixture.section.name
|
|
124
|
+
assert_equal "Ajax", fixture.namespace.full_name
|
|
125
|
+
assert !fixture.deprecated?
|
|
126
|
+
assert !fixture.alias?
|
|
127
|
+
assert_equal [], fixture.klass_methods
|
|
128
|
+
assert_equal [], fixture.methodized_methods
|
|
129
|
+
assert_equal [], fixture.klass_properties
|
|
130
|
+
assert_equal [], fixture.instance_methods
|
|
131
|
+
assert_equal [], fixture.instance_properties
|
|
132
|
+
assert_equal [], fixture.related_utilities
|
|
133
|
+
assert_equal "Ajax", fixture.doc_parent.name
|
|
134
|
+
assert_equal %w[Ajax ajax], fixture.ancestors.map(&:name)
|
|
135
|
+
assert_equal [], fixture.children
|
|
136
|
+
assert_equal [], fixture.descendants
|
|
137
|
+
|
|
138
|
+
fixture = fixtures.find_by_name("Ajax.Request")
|
|
139
|
+
assert_equal Klass, fixture.class
|
|
140
|
+
assert_equal "Request", fixture.name
|
|
141
|
+
assert_equal "Ajax", fixture.namespace_string
|
|
142
|
+
assert_equal "Ajax.Request", fixture.full_name
|
|
143
|
+
assert_equal fixtures.find_by_name("new Ajax.Request"), fixture.constructor
|
|
144
|
+
assert_equal [], fixture.mixins
|
|
145
|
+
assert_equal [], fixture.subklasses
|
|
146
|
+
assert !fixture.mixin?
|
|
147
|
+
assert fixture.subklass?
|
|
148
|
+
assert !fixture.superklass?
|
|
149
|
+
assert_equal "Ajax.Base", fixture.superklass.full_name
|
|
150
|
+
assert_equal Klass, fixture.superklass.class
|
|
151
|
+
assert_equal "ajax", fixture.section.name
|
|
152
|
+
assert_equal "Ajax", fixture.namespace.full_name
|
|
153
|
+
assert !fixture.deprecated?
|
|
154
|
+
assert !fixture.alias?
|
|
155
|
+
assert_equal [], fixture.klass_methods
|
|
156
|
+
assert_equal [], fixture.methodized_methods
|
|
157
|
+
assert_equal %w[classProp], fixture.klass_properties.map(&:name)
|
|
158
|
+
assert_equal %w[request success], fixture.instance_methods.map(&:name)
|
|
159
|
+
assert_equal %w[dummy], fixture.instance_properties.map(&:name)
|
|
160
|
+
assert_equal %w[Events], fixture.constants.map(&:name)
|
|
161
|
+
assert_equal [], fixture.related_utilities
|
|
162
|
+
assert_equal "Ajax", fixture.doc_parent.name
|
|
163
|
+
assert_equal %w[Ajax ajax], fixture.ancestors.map(&:name)
|
|
164
|
+
assert_equal [], fixture.children
|
|
165
|
+
assert_equal [], fixture.descendants
|
|
166
|
+
|
|
167
|
+
fixture = fixtures.find_by_name("Element")
|
|
168
|
+
assert_equal Klass, fixture.class
|
|
169
|
+
assert_equal %w[setStyle], fixture.klass_methods.map(&:name)
|
|
170
|
+
assert_equal %w[setStyle], fixture.methodized_methods.map(&:name)
|
|
171
|
+
assert_equal [], fixture.klass_properties
|
|
172
|
+
assert_equal %w[bar foo], fixture.instance_methods.map(&:name)
|
|
173
|
+
assert_equal [], fixture.instance_properties
|
|
174
|
+
assert_equal %w[$], fixture.related_utilities.map(&:name)
|
|
175
|
+
assert_equal "DOM", fixture.doc_parent.name
|
|
176
|
+
assert_equal %w[DOM], fixture.ancestors.map(&:name)
|
|
177
|
+
assert_equal [], fixture.children
|
|
178
|
+
assert_equal [], fixture.descendants
|
|
179
|
+
|
|
180
|
+
fixture = fixtures.find_by_name("String")
|
|
181
|
+
assert_equal Klass, fixture.class
|
|
182
|
+
assert_equal %w[interpret], fixture.klass_methods.map(&:name)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_klass_method
|
|
186
|
+
fixture = fixtures.find_by_name("String.interpret")
|
|
187
|
+
assert_equal KlassMethod, fixture.class
|
|
188
|
+
assert_equal "interpret", fixture.name
|
|
189
|
+
assert_equal "String", fixture.namespace_string
|
|
190
|
+
assert_equal "String.interpret", fixture.full_name
|
|
191
|
+
assert_equal "String", fixture.klass_name
|
|
192
|
+
assert_equal Klass, fixture.klass.class
|
|
193
|
+
assert_equal "String", fixture.klass.full_name
|
|
194
|
+
assert_equal "lang", fixture.section.name
|
|
195
|
+
assert_equal Klass, fixture.namespace.class
|
|
196
|
+
assert_equal "String", fixture.namespace.full_name
|
|
197
|
+
assert !fixture.deprecated?
|
|
198
|
+
assert !fixture.alias?
|
|
199
|
+
assert_equal "String", fixture.doc_parent.name
|
|
200
|
+
assert_equal %w[String lang], fixture.ancestors.map(&:name)
|
|
201
|
+
assert_equal [], fixture.children
|
|
202
|
+
assert_equal [], fixture.descendants
|
|
203
|
+
|
|
204
|
+
fixture = fixtures.find_by_name("Ajax.getTransport")
|
|
205
|
+
assert_equal KlassMethod, fixture.class
|
|
206
|
+
assert_equal "getTransport", fixture.name
|
|
207
|
+
assert_equal "Ajax", fixture.namespace_string
|
|
208
|
+
assert_equal "Ajax.getTransport", fixture.full_name
|
|
209
|
+
assert_equal nil, fixture.klass_name
|
|
210
|
+
assert_equal "ajax", fixture.section.name
|
|
211
|
+
assert_equal Namespace, fixture.namespace.class
|
|
212
|
+
assert_equal "Ajax", fixture.namespace.full_name
|
|
213
|
+
assert !fixture.deprecated?
|
|
214
|
+
assert !fixture.alias?
|
|
215
|
+
assert_equal "Ajax", fixture.doc_parent.name
|
|
216
|
+
assert_equal %w[Ajax ajax], fixture.ancestors.map(&:name)
|
|
217
|
+
assert_equal [], fixture.children
|
|
218
|
+
assert_equal [], fixture.descendants
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def test_klass_properties
|
|
222
|
+
fixture = fixtures.find_by_name("Ajax.Request.classProp")
|
|
223
|
+
assert_equal KlassProperty, fixture.class
|
|
224
|
+
assert_equal "classProp", fixture.name
|
|
225
|
+
assert_equal "Ajax.Request", fixture.namespace_string
|
|
226
|
+
assert_equal "Ajax.Request.classProp", fixture.full_name
|
|
227
|
+
assert_equal "Request", fixture.klass_name
|
|
228
|
+
assert_equal Klass, fixture.klass.class
|
|
229
|
+
assert_equal "Ajax.Request", fixture.klass.full_name
|
|
230
|
+
assert_equal "ajax", fixture.section.name
|
|
231
|
+
assert_equal Klass, fixture.namespace.class
|
|
232
|
+
assert_equal "Ajax.Request", fixture.namespace.full_name
|
|
233
|
+
assert !fixture.deprecated?
|
|
234
|
+
assert !fixture.alias?
|
|
235
|
+
assert_equal "Request", fixture.doc_parent.name
|
|
236
|
+
assert_equal %w[Request Ajax ajax], fixture.ancestors.map(&:name)
|
|
237
|
+
assert_equal [], fixture.children
|
|
238
|
+
assert_equal [], fixture.descendants
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def test_utilities
|
|
242
|
+
fixture = fixtures.find_by_name("$")
|
|
243
|
+
assert_equal Utility, fixture.class
|
|
244
|
+
assert_equal "$", fixture.name
|
|
245
|
+
assert_equal "", fixture.namespace_string
|
|
246
|
+
assert_equal "$", fixture.full_name
|
|
247
|
+
assert_equal nil, fixture.klass_name
|
|
248
|
+
assert_equal "DOM", fixture.section.name
|
|
249
|
+
assert_equal fixtures.find_by_name("Element"), fixture.related_to
|
|
250
|
+
assert_equal nil, fixture.namespace
|
|
251
|
+
assert !fixture.deprecated?
|
|
252
|
+
assert !fixture.alias?
|
|
253
|
+
assert_equal "DOM", fixture.doc_parent.name
|
|
254
|
+
assert_equal %w[DOM], fixture.ancestors.map(&:name)
|
|
255
|
+
assert_equal [], fixture.children
|
|
256
|
+
assert_equal [], fixture.descendants
|
|
257
|
+
|
|
258
|
+
fixture = fixtures.find_by_name("$$")
|
|
259
|
+
assert_equal Utility, fixture.class
|
|
260
|
+
assert_equal "DOM", fixture.section.name
|
|
261
|
+
assert_equal nil, fixture.related_to
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def test_constants
|
|
265
|
+
fixture = fixtures.find_by_name("Ajax.Request.Events")
|
|
266
|
+
assert_equal Constant, fixture.class
|
|
267
|
+
assert_equal Klass, fixture.namespace.class
|
|
268
|
+
assert_equal "Events", fixture.name
|
|
269
|
+
assert_equal "Ajax.Request", fixture.namespace_string
|
|
270
|
+
assert_equal "Ajax.Request.Events", fixture.full_name
|
|
271
|
+
assert_equal "Request", fixture.klass_name
|
|
272
|
+
assert_equal Klass, fixture.klass.class
|
|
273
|
+
assert_equal "Ajax.Request", fixture.klass.full_name
|
|
274
|
+
assert_equal "ajax", fixture.section.name
|
|
275
|
+
assert_equal Klass, fixture.namespace.class
|
|
276
|
+
assert_equal "Ajax.Request", fixture.namespace.full_name
|
|
277
|
+
assert !fixture.deprecated?
|
|
278
|
+
assert !fixture.alias?
|
|
279
|
+
assert_equal "Request", fixture.doc_parent.name
|
|
280
|
+
assert_equal %w[Request Ajax ajax], fixture.ancestors.map(&:name)
|
|
281
|
+
assert_equal [], fixture.children
|
|
282
|
+
assert_equal [], fixture.descendants
|
|
283
|
+
|
|
284
|
+
fixture = fixtures.find_by_name("Ajax.Request.classProp")
|
|
285
|
+
assert_equal KlassProperty, fixture.class
|
|
286
|
+
assert_equal "classProp", fixture.name
|
|
287
|
+
assert_equal "Ajax.Request", fixture.namespace_string
|
|
288
|
+
assert_equal "Ajax.Request.classProp", fixture.full_name
|
|
289
|
+
assert_equal "Request", fixture.klass_name
|
|
290
|
+
assert_equal Klass, fixture.klass.class
|
|
291
|
+
assert_equal "Ajax.Request", fixture.klass.full_name
|
|
292
|
+
assert_equal "ajax", fixture.section.name
|
|
293
|
+
assert_equal Klass, fixture.namespace.class
|
|
294
|
+
assert_equal "Ajax.Request", fixture.namespace.full_name
|
|
295
|
+
assert !fixture.deprecated?
|
|
296
|
+
assert !fixture.alias?
|
|
297
|
+
assert_equal "Request", fixture.doc_parent.name
|
|
298
|
+
assert_equal %w[Request Ajax ajax], fixture.ancestors.map(&:name)
|
|
299
|
+
assert_equal [], fixture.children
|
|
300
|
+
assert_equal [], fixture.descendants
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def test_instance_properties
|
|
304
|
+
fixture = fixtures.find_by_name("Ajax.Request#dummy")
|
|
305
|
+
assert_equal InstanceProperty, fixture.class
|
|
306
|
+
assert_equal "dummy", fixture.name
|
|
307
|
+
assert_equal "Ajax.Request", fixture.namespace_string
|
|
308
|
+
assert_equal "Ajax.Request#dummy", fixture.full_name
|
|
309
|
+
assert_equal "Request", fixture.klass_name
|
|
310
|
+
assert_equal Klass, fixture.klass.class
|
|
311
|
+
assert_equal "Ajax.Request", fixture.klass.full_name
|
|
312
|
+
assert_equal "ajax", fixture.section.name
|
|
313
|
+
assert_equal Klass, fixture.namespace.class
|
|
314
|
+
assert_equal "Ajax.Request", fixture.namespace.full_name
|
|
315
|
+
assert !fixture.deprecated?
|
|
316
|
+
assert !fixture.alias?
|
|
317
|
+
assert_equal "Request", fixture.doc_parent.name
|
|
318
|
+
assert_equal %w[Request Ajax ajax], fixture.ancestors.map(&:name)
|
|
319
|
+
assert_equal [], fixture.children
|
|
320
|
+
assert_equal [], fixture.descendants
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def test_instance_method
|
|
324
|
+
fixture = fixtures.find_by_name("Ajax.Request#request")
|
|
325
|
+
assert_equal InstanceMethod, fixture.class
|
|
326
|
+
assert_equal "request", fixture.name
|
|
327
|
+
assert_equal "Ajax.Request", fixture.namespace_string
|
|
328
|
+
assert_equal "Ajax.Request#request", fixture.full_name
|
|
329
|
+
assert_equal "Request", fixture.klass_name
|
|
330
|
+
assert_equal Klass, fixture.klass.class
|
|
331
|
+
assert_equal "Ajax.Request", fixture.klass.full_name
|
|
332
|
+
assert_equal "ajax", fixture.section.name
|
|
333
|
+
assert_equal Klass, fixture.namespace.class
|
|
334
|
+
assert_equal "Ajax.Request", fixture.namespace.full_name
|
|
335
|
+
assert !fixture.deprecated?
|
|
336
|
+
assert !fixture.alias?
|
|
337
|
+
assert !fixture.methodized?
|
|
338
|
+
assert_equal "Request", fixture.doc_parent.name
|
|
339
|
+
assert_equal %w[Request Ajax ajax], fixture.ancestors.map(&:name)
|
|
340
|
+
assert_equal [], fixture.children
|
|
341
|
+
assert_equal [], fixture.descendants
|
|
342
|
+
|
|
343
|
+
fixture = fixtures.find_by_name("Element.setStyle")
|
|
344
|
+
assert_equal KlassMethod, fixture.class
|
|
345
|
+
assert_equal "setStyle", fixture.name
|
|
346
|
+
assert_equal "Element", fixture.namespace_string
|
|
347
|
+
assert_equal "Element.setStyle", fixture.full_name
|
|
348
|
+
assert_equal "Element", fixture.klass_name
|
|
349
|
+
assert_equal Klass, fixture.klass.class
|
|
350
|
+
assert_equal "Element", fixture.klass.full_name
|
|
351
|
+
assert_equal "DOM", fixture.section.name
|
|
352
|
+
assert_equal Klass, fixture.namespace.class
|
|
353
|
+
assert_equal "Element", fixture.namespace.full_name
|
|
354
|
+
assert !fixture.deprecated?
|
|
355
|
+
assert !fixture.alias?
|
|
356
|
+
assert fixture.methodized?
|
|
357
|
+
assert_equal "Element", fixture.doc_parent.name
|
|
358
|
+
assert_equal %w[Element DOM], fixture.ancestors.map(&:name)
|
|
359
|
+
assert_equal [], fixture.children
|
|
360
|
+
assert_equal [], fixture.descendants
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def test_constructor
|
|
364
|
+
fixture = fixtures.find_by_name("new Ajax.Request")
|
|
365
|
+
assert_equal Constructor, fixture.class
|
|
366
|
+
assert_equal "new", fixture.name
|
|
367
|
+
assert_equal "Ajax.Request", fixture.namespace_string
|
|
368
|
+
assert_equal "new Ajax.Request", fixture.full_name
|
|
369
|
+
assert_equal "Request", fixture.klass_name
|
|
370
|
+
assert_equal Klass, fixture.klass.class
|
|
371
|
+
assert_equal "Ajax.Request", fixture.klass.full_name
|
|
372
|
+
assert_equal "ajax", fixture.section.name
|
|
373
|
+
assert_equal Klass, fixture.namespace.class
|
|
374
|
+
assert_equal "Ajax.Request", fixture.namespace.full_name
|
|
375
|
+
assert !fixture.deprecated?
|
|
376
|
+
assert !fixture.alias?
|
|
377
|
+
assert !fixture.methodized?
|
|
378
|
+
assert_equal "Request", fixture.doc_parent.name
|
|
379
|
+
assert_equal %w[Request Ajax ajax], fixture.ancestors.map(&:name)
|
|
380
|
+
assert_equal [], fixture.children
|
|
381
|
+
assert_equal [], fixture.descendants
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def test_deprecated
|
|
385
|
+
fixture = fixtures.find_by_name("Toggle")
|
|
386
|
+
|
|
387
|
+
assert_equal Namespace, fixture.class
|
|
388
|
+
assert_equal [], fixture.mixins
|
|
389
|
+
assert_equal "Toggle", fixture.name
|
|
390
|
+
assert_equal nil, fixture.klass
|
|
391
|
+
assert_equal "DOM", fixture.section.name
|
|
392
|
+
assert_equal "", fixture.namespace_string
|
|
393
|
+
assert_equal nil, fixture.namespace
|
|
394
|
+
assert fixture.deprecated?
|
|
395
|
+
assert !fixture.alias?
|
|
396
|
+
assert_equal %w[display foo], fixture.klass_methods.map(&:name)
|
|
397
|
+
assert_equal [], fixture.klass_properties
|
|
398
|
+
assert_equal [], fixture.instance_methods
|
|
399
|
+
assert_equal [], fixture.instance_properties
|
|
400
|
+
assert_equal [], fixture.related_utilities
|
|
401
|
+
assert_equal "DOM", fixture.doc_parent.name
|
|
402
|
+
assert_equal %w[DOM], fixture.ancestors.map(&:name)
|
|
403
|
+
assert_equal %w[], fixture.children.map(&:name)
|
|
404
|
+
assert_equal %w[], fixture.descendants.map(&:name)
|
|
405
|
+
|
|
406
|
+
fixture = fixtures.find_by_name("Toggle.display")
|
|
407
|
+
assert_equal KlassMethod, fixture.class
|
|
408
|
+
assert_equal "display", fixture.name
|
|
409
|
+
assert_equal "Toggle", fixture.namespace_string
|
|
410
|
+
assert_equal "Toggle.display", fixture.full_name
|
|
411
|
+
assert_equal nil, fixture.klass_name
|
|
412
|
+
assert_equal "DOM", fixture.section.name
|
|
413
|
+
assert_equal Namespace, fixture.namespace.class
|
|
414
|
+
assert_equal "Toggle", fixture.namespace.full_name
|
|
415
|
+
assert fixture.deprecated?
|
|
416
|
+
assert !fixture.alias?
|
|
417
|
+
assert_equal "Toggle", fixture.doc_parent.name
|
|
418
|
+
assert_equal %w[Toggle DOM], fixture.ancestors.map(&:name)
|
|
419
|
+
assert_equal [], fixture.children
|
|
420
|
+
assert_equal [], fixture.descendants
|
|
421
|
+
|
|
422
|
+
fixture = fixtures.find_by_name("Toggle.foo")
|
|
423
|
+
assert_equal KlassMethod, fixture.class
|
|
424
|
+
assert_equal "foo", fixture.name
|
|
425
|
+
assert_equal "Toggle", fixture.namespace_string
|
|
426
|
+
assert_equal "Toggle.foo", fixture.full_name
|
|
427
|
+
assert_equal nil, fixture.klass_name
|
|
428
|
+
assert_equal "DOM", fixture.section.name
|
|
429
|
+
assert_equal Namespace, fixture.namespace.class
|
|
430
|
+
assert_equal "Toggle", fixture.namespace.full_name
|
|
431
|
+
assert fixture.deprecated?
|
|
432
|
+
assert !fixture.alias?
|
|
433
|
+
assert_equal "Toggle", fixture.doc_parent.name
|
|
434
|
+
assert_equal %w[Toggle DOM], fixture.ancestors.map(&:name)
|
|
435
|
+
assert_equal [], fixture.children
|
|
436
|
+
assert_equal [], fixture.descendants
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
def test_description
|
|
440
|
+
assert_equal "The Element class", fixtures.find_by_name("Element").description
|
|
441
|
+
assert_equal "Sets the style of element\nand returns it", fixtures.find_by_name("Element.setStyle").description
|
|
442
|
+
assert_equal "Calls `iterator` for each item in the collection.", fixtures.find_by_name("Enumerable#each").description
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
def test_arguments_descriptions
|
|
446
|
+
fixture = fixtures.find_by_name("Element.setStyle")
|
|
447
|
+
assert_equal %w[element styles], fixture.arguments.map(&:name)
|
|
448
|
+
assert_equal %w[String Element], fixture.arguments.first.types
|
|
449
|
+
assert_equal "an id or DOM node", fixture.arguments.first.description
|
|
450
|
+
assert_equal %w[String Object Hash], fixture.arguments.last.types
|
|
451
|
+
assert_equal "can be either a regular CSS string or a hash or regular object, in which case, properties need to be camelized",
|
|
452
|
+
fixture.arguments.last.description
|
|
453
|
+
|
|
454
|
+
assert_equal [], fixtures.find_by_name("Element#foo").arguments
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def test_event
|
|
458
|
+
assert_equal %w[element:style:updated], fixtures.find_by_name("Element.setStyle").fires
|
|
459
|
+
assert_equal [], fixtures.find_by_name("Element#foo").fires
|
|
460
|
+
assert_equal %w[click], fixtures.find_by_name("Element#bar").fires
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
def test_aliases
|
|
464
|
+
fixture = fixtures.find_by_name("Element.setStyle")
|
|
465
|
+
assert_equal [], fixture.aliases
|
|
466
|
+
assert !fixture.alias?
|
|
467
|
+
assert_equal nil, fixture.alias_of
|
|
468
|
+
|
|
469
|
+
fixture = fixtures.find_by_name("Element#foo")
|
|
470
|
+
assert_equal ["bar"], fixture.aliases.map(&:name)
|
|
471
|
+
assert !fixture.alias?
|
|
472
|
+
assert_equal nil, fixture.alias_of
|
|
473
|
+
|
|
474
|
+
fixture = fixtures.find_by_name("Element#bar")
|
|
475
|
+
assert_equal [], fixture.aliases.map(&:name)
|
|
476
|
+
assert fixture.alias?
|
|
477
|
+
assert_equal "foo", fixture.alias_of.name
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def test_weird
|
|
481
|
+
weird = parse(<<-EOS
|
|
482
|
+
|
|
483
|
+
/** section: DOM
|
|
484
|
+
* document
|
|
485
|
+
*
|
|
486
|
+
* Prototype extends the built-in `document` object with several convenience
|
|
487
|
+
* methods related to events.
|
|
488
|
+
**/
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
EOS
|
|
492
|
+
)
|
|
493
|
+
doc = weird.find_by_name("document")
|
|
494
|
+
assert_equal 'document', doc.name
|
|
495
|
+
assert_equal Documentation::Namespace, doc.class
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
def test_weirder
|
|
499
|
+
weird = parse(<<-EOS
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* document.viewport
|
|
503
|
+
*
|
|
504
|
+
* The `document.viewport` namespace contains methods that return information
|
|
505
|
+
* about the viewport — the rectangle that represents the portion of a web
|
|
506
|
+
* page within view. In other words, it's the browser window minus all chrome.
|
|
507
|
+
**/
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
EOS
|
|
511
|
+
)
|
|
512
|
+
doc = weird.find_by_name("document.viewport")
|
|
513
|
+
assert_equal 'viewport', doc.name
|
|
514
|
+
assert_equal Documentation::Namespace, doc.class
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
def test_weirdest
|
|
518
|
+
|
|
519
|
+
end
|
|
520
|
+
end
|