doxyparser 1.2 → 1.3
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/lib/doxyparser.rb +15 -6
- data/lib/nodes/class.rb +7 -7
- data/lib/nodes/compound.rb +39 -39
- data/lib/nodes/enum.rb +14 -14
- data/lib/nodes/friend.rb +15 -15
- data/lib/nodes/function.rb +57 -51
- data/lib/nodes/group.rb +1 -1
- data/lib/nodes/hfile.rb +67 -57
- data/lib/nodes/member.rb +62 -58
- data/lib/nodes/namespace.rb +28 -26
- data/lib/nodes/node.rb +65 -60
- data/lib/nodes/param.rb +3 -5
- data/lib/nodes/struct.rb +105 -75
- data/lib/nodes/type.rb +45 -26
- data/lib/util.rb +62 -57
- data/spec/file_spec.rb +1 -1
- data/spec/method_spec.rb +16 -16
- data/spec/type_spec.rb +2 -2
- metadata +24 -12
- checksums.yaml +0 -7
data/lib/nodes/member.rb
CHANGED
@@ -1,61 +1,65 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
3
|
+
class Member < Node
|
4
|
+
|
5
|
+
attr_reader :location
|
6
|
+
attr_reader :definition
|
7
|
+
attr_reader :args
|
8
|
+
attr_reader :type
|
9
|
+
attr_reader :static
|
10
|
+
attr_reader :params
|
11
|
+
|
12
|
+
def file
|
13
|
+
Doxyparser::HFile.new(:name => @filename, :dir => @dir)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def init_attributes
|
19
|
+
super
|
20
|
+
raise "No XML node was associated to this member" if @node.nil?
|
21
|
+
@xml_path = parent.xml_path
|
22
|
+
|
23
|
+
if @node['static'] && @node['static'] == 'yes'
|
24
|
+
@static = 'static'
|
25
|
+
else
|
26
|
+
@static = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
aux = self.xpath("location")[0]
|
30
|
+
@filename = File.basename(aux["file"])
|
31
|
+
@location = "#{aux["file"]}:#{aux["line"]}"
|
32
|
+
temp = self.xpath("definition")
|
33
|
+
if temp == nil || temp.empty? || temp[0].child==nil
|
34
|
+
@definition = ""
|
35
|
+
else
|
36
|
+
@definition = temp[0].child.content
|
37
|
+
end
|
38
|
+
temp = self.xpath("argsstring")
|
39
|
+
if temp == nil || temp.empty? || temp[0].child==nil
|
40
|
+
@args = ""
|
41
|
+
else
|
42
|
+
@args = temp[0].child.content
|
43
|
+
end
|
44
|
+
@type = find_type(@node)
|
45
|
+
|
46
|
+
@params = []
|
47
|
+
all_params = self.xpath("param")
|
48
|
+
return if all_params == nil || all_params.empty? || all_params[0].child==nil
|
49
|
+
|
50
|
+
all_params.each { |param|
|
51
|
+
@params << Doxyparser::Param.new(node: param, parent: self, name: 'param')
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_name
|
56
|
+
@parent.name + '::' + @node.xpath("name")[0].child.content
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_type(n)
|
60
|
+
type = n.xpath("type")
|
61
|
+
return Doxyparser::Type.new(name: '', dir: @dir) if type.nil? || type.empty? || type[0].child == nil
|
62
|
+
Doxyparser::Type.new(node: type[0], dir: @dir)
|
63
|
+
end
|
64
|
+
end
|
61
65
|
end
|
data/lib/nodes/namespace.rb
CHANGED
@@ -2,55 +2,57 @@ module Doxyparser
|
|
2
2
|
|
3
3
|
class Namespace < Compound
|
4
4
|
|
5
|
-
def functions
|
6
|
-
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]})
|
5
|
+
def functions(filter=nil)
|
6
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]})
|
7
7
|
do_filter(filter, lst, Doxyparser::Function) { |node|
|
8
|
-
|
8
|
+
node.xpath("name")[0].child.content.strip
|
9
9
|
}
|
10
10
|
end
|
11
|
-
|
12
|
-
def enums
|
13
|
-
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="enum"]/memberdef[@kind="enum"]})
|
14
|
-
filter.map!{ |exp| exp =~ /^_Enum/ ? /@\d*/ : exp} unless filter.nil?
|
11
|
+
|
12
|
+
def enums(filter=nil)
|
13
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="enum"]/memberdef[@kind="enum"]})
|
14
|
+
filter.map! { |exp| exp =~ /^_Enum/ ? /@\d*/ : exp } unless filter.nil?
|
15
15
|
do_filter(filter, lst, Doxyparser::Enum) { |node|
|
16
|
-
|
16
|
+
node.xpath("name")[0].child.content.strip
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
def variables
|
21
|
-
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]})
|
20
|
+
def variables(filter=nil)
|
21
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]})
|
22
22
|
do_filter(filter, lst, Doxyparser::Variable) { |node|
|
23
23
|
node.xpath("name")[0].child.content.strip
|
24
24
|
}
|
25
25
|
end
|
26
|
-
|
27
|
-
def typedefs
|
28
|
-
|
29
|
-
do_filter(filter, lst, Doxyparser::Typedef) { |node|
|
26
|
+
|
27
|
+
def typedefs(filter=nil)
|
28
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="typedef"]/memberdef[@kind="typedef"]})
|
29
|
+
do_filter(filter, lst, Doxyparser::Typedef) { |node|
|
30
|
+
del_spaces(node.xpath("name")[0].child.content)
|
31
|
+
}
|
30
32
|
end
|
31
|
-
|
32
|
-
def innernamespaces
|
33
|
-
lst=doc.xpath(%Q{/doxygen/compounddef/innernamespace})
|
33
|
+
|
34
|
+
def innernamespaces(filter=nil)
|
35
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/innernamespace})
|
34
36
|
do_filter(filter, lst, Doxyparser::Namespace) { |node|
|
35
|
-
del_spaces
|
37
|
+
del_spaces del_prefix_class(node.child.content)
|
36
38
|
}
|
37
39
|
end
|
38
|
-
|
39
|
-
def structs
|
40
|
-
lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
40
|
+
|
41
|
+
def structs(filter=nil)
|
42
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
41
43
|
lst = lst.select { |c| c["refid"].start_with?("struct") }
|
42
44
|
do_filter(filter, lst, Doxyparser::Struct) { |node|
|
43
|
-
del_spaces
|
45
|
+
del_spaces del_prefix_class(node.child.content)
|
44
46
|
}
|
45
47
|
end
|
46
48
|
|
47
|
-
def classes
|
48
|
-
|
49
|
+
def classes(filter=nil)
|
50
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
49
51
|
lst = lst.select { |c| c["refid"].start_with?("class") }
|
50
52
|
do_filter(filter, lst, Doxyparser::Class) { |node|
|
51
|
-
del_spaces
|
53
|
+
del_spaces del_prefix_class(node.child.content)
|
52
54
|
}
|
53
|
-
end
|
55
|
+
end
|
54
56
|
|
55
57
|
def file
|
56
58
|
nil
|
data/lib/nodes/node.rb
CHANGED
@@ -1,63 +1,68 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
3
|
+
class Node
|
4
|
+
include Doxyparser::Util
|
5
|
+
|
6
|
+
attr_reader :dir
|
7
|
+
attr_reader :name
|
8
|
+
attr_reader :basename
|
9
|
+
attr_reader :node
|
10
|
+
attr_reader :doc
|
11
|
+
attr_reader :parent
|
12
|
+
|
13
|
+
def == another
|
14
|
+
self.name == another.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def eql?(another)
|
18
|
+
self.name == another.name
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_str
|
22
|
+
@name
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
@name
|
27
|
+
end
|
28
|
+
|
29
|
+
# Takes a hash as input with following keys: :node, :parent, :dir, :name
|
30
|
+
def initialize(hash)
|
31
|
+
@dir = hash[:dir]
|
32
|
+
@name = hash[:name]
|
33
|
+
if hash[:node] # If a reference to an xml declaration (node) is given
|
34
|
+
# then...
|
35
|
+
@node = hash[:node]
|
36
|
+
@parent = hash[:parent]
|
37
|
+
@name = find_name
|
38
|
+
@dir ||= @parent.dir unless @parent.nil?
|
39
|
+
end
|
40
|
+
raise "No name given for node: #{self.class.name}" unless @name
|
41
|
+
raise "No xml directory given for node: #{self.class.name}" unless @dir
|
42
|
+
init_attributes
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def method_missing(sym, *args)
|
48
|
+
if @node.respond_to?(sym)
|
49
|
+
@node.send(sym, *args)
|
50
|
+
else
|
51
|
+
@node[sym.to_s] || super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def init_attributes
|
56
|
+
@basename ||= del_prefix_for(@name)
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_name
|
60
|
+
# For Inheritance
|
61
|
+
end
|
62
|
+
|
63
|
+
def del_prefix_for(str)
|
64
|
+
del_prefix_class(str)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
63
68
|
end
|
data/lib/nodes/param.rb
CHANGED
@@ -15,15 +15,13 @@ module Doxyparser
|
|
15
15
|
def init_attributes
|
16
16
|
type_temp = @node.xpath("type")
|
17
17
|
return if type_temp.nil? || type_temp.empty?
|
18
|
-
@type = Type.new
|
18
|
+
@type = Type.new(node: type_temp[0], parent: @parent)
|
19
19
|
@name = @type.name
|
20
20
|
|
21
21
|
declname_temp = @node.xpath("declname")
|
22
22
|
return if declname_temp.nil? || declname_temp.empty?
|
23
|
-
@declname = declname_temp[0].content
|
24
|
-
|
25
|
-
@name += @declname
|
26
|
-
|
23
|
+
@declname = declname_temp[0].content
|
24
|
+
@name += @declname
|
27
25
|
@basename = @declname
|
28
26
|
|
29
27
|
value_temp = @node.xpath("defval")
|
data/lib/nodes/struct.rb
CHANGED
@@ -1,89 +1,119 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
3
|
+
class Struct < Compound
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def file
|
6
|
+
n=doc.xpath("/doxygen/compounddef/includes")[0]
|
7
|
+
raise "#{self.name} #{self.class.name} does not have correctly generated documentation. Use 'EXTRACT_ALL' Doxygen flag" unless n
|
8
|
+
HFile.new(dir: @dir, node: n)
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def friends
|
12
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="friend"]/memberdef[@kind="friend"]})
|
13
|
+
lst.map { |node|
|
14
|
+
Doxyparser::Friend.new(parent: self, node: node)
|
15
|
+
}
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
def template_params
|
19
|
+
params=doc.xpath(%Q{/doxygen/compounddef/templateparamlist/param})
|
20
|
+
params.map { |param|
|
21
|
+
Doxyparser::Param.new(parent: self, node: param)
|
22
|
+
}
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
def methods(access = :public, static = nil, filter = nil)
|
26
|
+
if access == :all
|
27
|
+
return methods(:public, static, filter) + methods(:protected, static, filter) + methods(:private, static, filter)
|
28
|
+
end
|
29
|
+
if static.nil?
|
30
|
+
static = "-"
|
31
|
+
else
|
32
|
+
static = "-static-"
|
33
|
+
end
|
34
|
+
sectiondef = %Q{#{access}#{static}func}
|
35
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="function"][@prot="#{access}"]})
|
36
|
+
do_filter(filter, lst, Doxyparser::Function) { |node|
|
37
|
+
node.xpath("name")[0].child.content
|
38
|
+
}
|
39
|
+
end
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
def attributes(access = :public, static = nil, filter = nil)
|
42
|
+
if access == :all
|
43
|
+
return attributes(:public, static, filter) + attributes(:protected, static, filter) + attributes(:private, static, filter)
|
44
|
+
end
|
45
|
+
if static.nil?
|
46
|
+
static = "-"
|
47
|
+
else
|
48
|
+
static = "-static-"
|
49
|
+
end
|
50
|
+
sectiondef = %Q{#{access}#{static}attrib}
|
51
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="variable"][@prot="#{access}"]})
|
52
|
+
do_filter(filter, lst, Doxyparser::Variable) { |node|
|
53
|
+
node.xpath("name")[0].child.content
|
54
|
+
}
|
55
|
+
end
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
def innerclasses(access = :public, filter = nil)
|
58
|
+
if access == :all
|
59
|
+
return innerclasses(:public, filter) + innerclasses(:protected, filter) + innerclasses(:private, filter)
|
60
|
+
end
|
61
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/innerclass[@prot="#{access}"]})
|
62
|
+
lst = lst.select { |c| c["refid"].start_with?("class") }
|
63
|
+
do_filter(filter, lst, Doxyparser::Class) { |node|
|
64
|
+
del_prefix(node.child.content)
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def parent_types(access = :public, filter = nil)
|
69
|
+
if access == :all
|
70
|
+
return parent_types(:public, filter) + parent_types(:protected, filter) + parent_types(:private, filter)
|
71
|
+
end
|
72
|
+
types = doc.xpath(%Q{/doxygen/compounddef/basecompoundref[@prot="#{access}"]})
|
73
|
+
types.map { |t|
|
74
|
+
Doxyparser::Type.new(name: t.child.content, dir: @dir)
|
75
|
+
}
|
76
|
+
end
|
58
77
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
def innerstructs(access = :public, filter = nil)
|
79
|
+
if access == :all
|
80
|
+
return innerstructs(:public, filter) + innerstructs(:protected, filter) + innerstructs(:private, filter)
|
81
|
+
end
|
82
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/innerclass[@prot="#{access}"]})
|
83
|
+
lst = lst.select { |c| c["refid"].start_with?("struct") }
|
84
|
+
do_filter(filter, lst, Doxyparser::Struct) { |node|
|
85
|
+
del_prefix(node.child.content)
|
86
|
+
}
|
87
|
+
end
|
66
88
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
89
|
+
def innerenums(access = :public, filter = nil)
|
90
|
+
if access == :all
|
91
|
+
return innerenums(:public, filter) + innerenums(:protected, filter) + innerenums(:private, filter)
|
92
|
+
end
|
93
|
+
sectiondef = %Q{#{access}-type}
|
94
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="enum"][@prot="#{access}"]})
|
95
|
+
filter.map!{ |exp| exp =~ /^_Enum/ ? /@\d*/ : exp} unless filter.nil?
|
96
|
+
do_filter(filter, lst, Doxyparser::Enum) { |node|
|
97
|
+
node.xpath("name")[0].child.content
|
98
|
+
}
|
99
|
+
end
|
75
100
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
101
|
+
def typedefs(access = :public, filter = nil)
|
102
|
+
if access == :all
|
103
|
+
return typedefs(:public, filter) + typedefs(:protected, filter) + typedefs(:private, filter)
|
104
|
+
end
|
105
|
+
sectiondef = %Q{#{access}-type}
|
106
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="typedef"][@prot="#{access}"]})
|
107
|
+
do_filter(filter, lst, Doxyparser::Typedef) { |node|
|
108
|
+
del_spaces node.xpath("name")[0].child.content
|
109
|
+
}
|
110
|
+
end
|
81
111
|
|
82
|
-
|
112
|
+
private
|
83
113
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
114
|
+
def compute_path
|
115
|
+
aux = escape_class_name(@name)
|
116
|
+
@xml_path = %Q{#{@dir}/struct#{aux}.xml}
|
117
|
+
end
|
118
|
+
end
|
89
119
|
end
|