tobie / pdoc

JavaScript inline documentation parser

This URL has Read+Write access

pdoc / lib / pdoc / parser / ebnf_expression_nodes.rb
b1711004 » tobie 2008-04-07 Moving exported PDoc to git... 1 module EbnfExpression
2 class Base < Treetop::Runtime::SyntaxNode
3 def klass_name
4 js_namespace.to_a.last
5 end
6
7 def name
8 js_variable.value
9 end
10
11 def full_name
12 js_namespace.text_value
13 end
14
15 def namespace
16 js_namespace.text_value
17 end
18
19 def returns
20 return_value.value.text_value.strip
21 end
22
23 def to_s
24 text_value
25 end
26
27 def inspect
28 "#<#{self.class} @input=#{@input.inspect}>"
29 end
30 end
31
32 class Method < Base
33 def methodized?
34 args.methodize.text_value == "@"
35 end
36
37 def arguments
38 args.arguments.to_a
39 end
40
41 def methodized_arguments
42 arguments.slice(1..-1)
43 end
44 end
45
46 class KlassMethod < Method
f46ae687 » tobie 2008-05-04 Allow lowercased namespaces. 47 def klass_name
48 js_namespace.to_a.slice(-2)
49 end
50
51 def name
52 js_namespace.to_a.last
53 end
54
55 def namespace
56 js_namespace.to_a.slice(0..-2).join(".")
b1711004 » tobie 2008-04-07 Moving exported PDoc to git... 57 end
58 end
59
60 class Utility < Method
61 def klass_name
62 nil
63 end
64
65 def name
66 utility_name.text_value
67 end
68
69 def full_name
70 "#{name}"
71 end
72
73 def namespace
74 ""
75 end
76 end
77
78 class InstanceMethod < Method
79 def full_name
80 "#{super}##{name}"
81 end
82 end
83
84 class Constructor < Method
85 def name
86 "new"
87 end
88
89 def full_name
90 "new #{super}"
91 end
92 end
93
94 class KlassProperty < Base
f46ae687 » tobie 2008-05-04 Allow lowercased namespaces. 95 def klass_name
96 js_namespace.to_a.slice(-2)
97 end
98
99 def name
100 js_namespace.to_a.last
101 end
102
103 def namespace
104 js_namespace.to_a.slice(0..-2).join(".")
b1711004 » tobie 2008-04-07 Moving exported PDoc to git... 105 end
106 end
107
108 class InstanceProperty < Base
109 def full_name
110 "#{super}##{name}"
111 end
112 end
113
114 class Constant < Base
115 def klass_name
116 nil
117 end
118
119 def name
120 js_namespace.to_a.last
121 end
122
123 def namespace
124 js_namespace.to_a.slice(0..-2).join(".")
125 end
126
127 def returns
128 value.text_value.strip
129 end
130 end
131
132 class Namespace < Base
133 def klass_name
134 nil
135 end
136
137 def name
138 js_namespace.to_a.last
139 end
140
141 def namespace
142 js_namespace.to_a.slice(0..-2).join(".")
143 end
144
145 def mixins
146 second_line = elements.last
147 if second_line.empty?
148 []
149 else
150 [second_line.js_namespace].concat(second_line.more.elements.map{|e| e.elements.last})
151 end
152 end
153 end
154
155 class Klass < Namespace
156 def subklass?
157 !extends.elements.nil?
158 end
159
160 def superklass
161 subklass? ? extends.elements.last : nil
162 end
163 end
164
165 class Mixin < Namespace
166 end
167 end