doxyparser 1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ module Doxyparser
2
+
3
+ class Friend < Member
4
+
5
+ def is_class?
6
+ args.nil? || args == ""
7
+ end
8
+
9
+ def is_qualified?
10
+ basename.include? '::'
11
+ end
12
+
13
+ private
14
+
15
+ def find_name
16
+ @basename = @node.xpath("name")[0].child.content
17
+ @parent.name + '::' + @basename
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ module Doxyparser
2
+
3
+ class Function < Member
4
+
5
+ def == another
6
+ super
7
+ self.args == another.args
8
+ end
9
+
10
+ def eql? another
11
+ super
12
+ self.args == another.args
13
+ end
14
+
15
+ def to_str
16
+ super + @args
17
+ end
18
+
19
+ def to_s
20
+ super + @args
21
+ end
22
+
23
+ def constructor?
24
+ @basename==parent.basename
25
+ end
26
+
27
+ def destructor?
28
+ @basename.start_with? %Q{~}
29
+ end
30
+
31
+ def getter_for
32
+ if @params.empty? || (@params.size == 1 && @params[0].type.name =~ /\s*void\s*/)
33
+ if @basename.start_with?('get') || @basename.start_with?('Get')
34
+ return @basename.gsub(/get[_]?(\w)/i){|match| $1.downcase}
35
+ end
36
+ if @type.name == 'bool'
37
+ if @basename.start_with?('is') || @basename.start_with?('Is')
38
+ return @basename.gsub(/is[_]?(\w)/i){|match| $1.downcase}
39
+ end
40
+ end
41
+ end
42
+ return nil
43
+ end
44
+
45
+ def setter_for
46
+ if @type.name == 'void'
47
+ if @basename.start_with?('set') || @basename.start_with?('Set')
48
+ return @basename.gsub(/set[_]?(\w)/i){|match| $1.downcase}
49
+ end
50
+ end
51
+ return nil
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,6 @@
1
+ module Doxyparser
2
+
3
+ class Group < Compound
4
+
5
+ end
6
+ end
@@ -0,0 +1,73 @@
1
+ module Doxyparser
2
+
3
+ class HFile < Compound
4
+
5
+ def list_included
6
+ lst=doc.xpath(%Q{/doxygen/compounddef/includes})
7
+ lst.map { |f| f.child.content }
8
+ end
9
+
10
+ def list_including
11
+ lst=doc.xpath(%Q{/doxygen/compounddef/includedby})
12
+ lst.map { |f| f[:refid].nil? ? f.child.content : escape_file_name(f[:refid]) }
13
+ end
14
+
15
+ def files_included
16
+ lst=doc.xpath(%Q{/doxygen/compounddef/includes[@local="yes"]})
17
+ lst.map { |f| Doxyparser::HFile.new(dir: @dir, node: f) }
18
+ end
19
+
20
+ def files_including
21
+ lst=doc.xpath(%Q{/doxygen/compounddef/includedby[@local="yes"]})
22
+ lst.map { |f| Doxyparser::HFile.new(dir: @dir, node: f) }
23
+ end
24
+
25
+ def structs
26
+ lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
27
+ lst = lst.select { |c| c["refid"].start_with?("struct") }
28
+ lst.map { |node| Doxyparser::Struct.new(dir: @dir, node: node) }
29
+ end
30
+
31
+ def classes
32
+ lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
33
+ lst = lst.select { |c| c["refid"].start_with?("class") }
34
+ lst.map { |node| Doxyparser::Class.new(dir: @dir, node: node) }
35
+ end
36
+
37
+ def namespaces
38
+ lst=doc.xpath(%Q{/doxygen/compounddef/innernamespace})
39
+ lst.map { |node| Doxyparser::Namespace.new(dir: @dir, node: node) }
40
+ end
41
+
42
+ def functions
43
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]})
44
+ lst.map { |node| Doxyparser::Function.new(parent: self, node: node) }
45
+ end
46
+
47
+ def variables
48
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]})
49
+ lst.map { |node| Doxyparser::Variable.new(parent: self, node: node) }
50
+ end
51
+
52
+ def enums
53
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="enum"]/memberdef[@kind="enum"]})
54
+ lst.map { |node| Doxyparser::Enum.new(parent: self, node: node) }
55
+ end
56
+
57
+ def typedefs
58
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="typedef"]/memberdef[@kind="typedef"]})
59
+ lst.map { |node| Doxyparser::Typedef.new(parent: self, node: node) }
60
+ end
61
+
62
+ private
63
+
64
+ def find_name
65
+ escape_file_name self.refid
66
+ end
67
+
68
+ def compute_path
69
+ aux= escape_file_name @name
70
+ @xml_path = %Q{#{@dir}/#{aux}.xml}
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,61 @@
1
+ module Doxyparser
2
+
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
+ 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
+ if @node['static']
23
+ @static = (@node['static'] == 'yes') ? 'static' : nil
24
+ end
25
+ aux= self.xpath("location")[0]
26
+ @filename=File.basename(aux["file"])
27
+ @location="#{aux["file"]}:#{aux["line"]}"
28
+ temp=self.xpath("definition")
29
+ if temp == nil || temp.empty? || temp[0].child==nil
30
+ @definition = ""
31
+ else
32
+ @definition = temp[0].child.content
33
+ end
34
+ temp = self.xpath("argsstring")
35
+ if temp == nil || temp.empty? || temp[0].child==nil
36
+ @args = ""
37
+ else
38
+ @args = temp[0].child.content
39
+ end
40
+ @type = find_type @node
41
+
42
+ @params=[]
43
+ all_params= self.xpath("param")
44
+ return if all_params == nil || all_params.empty? || all_params[0].child==nil
45
+
46
+ all_params.each { |param|
47
+ @params << Doxyparser::Param.new(node: param, parent: self, name: 'param''param')
48
+ }
49
+ end
50
+
51
+ def find_name
52
+ @parent.name + '::' + @node.xpath("name")[0].child.content
53
+ end
54
+
55
+ def find_type n
56
+ type = n.xpath("type")
57
+ return "" if type.nil? || type.empty? || type[0].child==nil
58
+ Type.new node: type[0], dir: @dir
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,66 @@
1
+ module Doxyparser
2
+
3
+ class Namespace < Compound
4
+
5
+ def functions filter=nil
6
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]})
7
+ do_filter(filter, lst, Doxyparser::Function) { |node|
8
+ node.xpath("name")[0].child.content.strip
9
+ }
10
+ end
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
+ do_filter(filter, lst, Doxyparser::Enum) { |node|
16
+ node.xpath("name")[0].child.content.strip
17
+ }
18
+ end
19
+
20
+ def variables filter=nil
21
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]})
22
+ do_filter(filter, lst, Doxyparser::Variable) { |node|
23
+ node.xpath("name")[0].child.content.strip
24
+ }
25
+ end
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| del_spaces node.xpath("name")[0].child.content }
30
+ end
31
+
32
+ def innernamespaces filter=nil
33
+ lst=doc.xpath(%Q{/doxygen/compounddef/innernamespace})
34
+ do_filter(filter, lst, Doxyparser::Namespace) { |node|
35
+ del_spaces del_prefix(node.child.content)
36
+ }
37
+ end
38
+
39
+ def structs filter=nil
40
+ lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
41
+ lst = lst.select { |c| c["refid"].start_with?("struct") }
42
+ do_filter(filter, lst, Doxyparser::Struct) { |node|
43
+ del_spaces del_prefix(node.child.content)
44
+ }
45
+ end
46
+
47
+ def classes filter=nil
48
+ lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
49
+ lst = lst.select { |c| c["refid"].start_with?("class") }
50
+ do_filter(filter, lst, Doxyparser::Class) { |node|
51
+ del_spaces del_prefix(node.child.content)
52
+ }
53
+ end
54
+
55
+ def file
56
+ nil
57
+ end
58
+
59
+ private
60
+
61
+ def compute_path
62
+ aux = escape_class_name(@name)
63
+ @xml_path = %Q{#{@dir}/namespace#{aux}.xml}
64
+ end
65
+ end
66
+ end
data/lib/nodes/node.rb ADDED
@@ -0,0 +1,63 @@
1
+ module Doxyparser
2
+
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 then...
34
+ @node = hash[:node]
35
+ @parent = hash[:parent]
36
+ @name = find_name
37
+ @dir ||= @parent.dir unless @parent.nil?
38
+ end
39
+ raise "No name given for node: #{self.class.name}" unless @name
40
+ raise "No xml directory given for node: #{self.class.name}" unless @dir
41
+ init_attributes
42
+ end
43
+
44
+ private
45
+
46
+ def method_missing sym, *args
47
+ if @node.respond_to? sym
48
+ @node.send(sym, *args)
49
+ else
50
+ @node[sym.to_s] || super
51
+ end
52
+ end
53
+
54
+ def init_attributes
55
+ @basename ||= del_prefix @name
56
+ end
57
+
58
+ def find_name
59
+ # For Inheritance
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,34 @@
1
+ module Doxyparser
2
+
3
+ class Param < Node
4
+
5
+ attr_reader :type
6
+ attr_reader :declname
7
+ attr_reader :value
8
+
9
+ private
10
+
11
+ def find_name
12
+ 'param' # Default name if nothing else
13
+ end
14
+
15
+ def init_attributes
16
+ type_temp = @node.xpath("type")
17
+ return if type_temp.nil? || type_temp.empty?
18
+ @type = Type.new node: type_temp[0], parent: @parent
19
+ @name = @type.name
20
+
21
+ declname_temp = @node.xpath("declname")
22
+ return if declname_temp.nil? || declname_temp.empty?
23
+ @declname = declname_temp[0].content
24
+
25
+ @name += @declname
26
+
27
+ @basename = @declname
28
+
29
+ value_temp = @node.xpath("defval")
30
+ return if value_temp.nil? || value_temp.empty?
31
+ @value = value_temp[0].content
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,89 @@
1
+ module Doxyparser
2
+
3
+ class Struct < Compound
4
+
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
+
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
+
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
+
25
+ def methods access=:public, static=nil, filter=nil
26
+ if static.nil?
27
+ static="-"
28
+ else
29
+ static="-static-"
30
+ end
31
+ sectiondef=%Q{#{access}#{static}func}
32
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="function"][@prot="#{access}"]})
33
+ do_filter(filter, lst, Doxyparser::Function) { |node|
34
+ node.xpath("name")[0].child.content
35
+ }
36
+ end
37
+
38
+ def attributes access=:public, static=nil, filter=nil
39
+ if static.nil?
40
+ static="-"
41
+ else
42
+ static="-static-"
43
+ end
44
+ sectiondef=%Q{#{access}#{static}attrib}
45
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="variable"][@prot="#{access}"]})
46
+ do_filter(filter, lst, Doxyparser::Variable) { |node|
47
+ node.xpath("name")[0].child.content
48
+ }
49
+ end
50
+
51
+ def innerclasses access=:public, filter=nil
52
+ lst=doc.xpath(%Q{/doxygen/compounddef/innerclass[@prot="#{access}"]})
53
+ lst = lst.select { |c| c["refid"].start_with?("class") }
54
+ do_filter(filter, lst, Doxyparser::Class) { |node|
55
+ del_prefix(node.child.content)
56
+ }
57
+ end
58
+
59
+ def innerstructs access=:public, filter=nil
60
+ lst=doc.xpath(%Q{/doxygen/compounddef/innerclass[@prot="#{access}"]})
61
+ lst = lst.select { |c| c["refid"].start_with?("struct") }
62
+ do_filter(filter, lst, Doxyparser::Struct) { |node|
63
+ del_prefix(node.child.content)
64
+ }
65
+ end
66
+
67
+ def innerenums access=:public, filter=nil
68
+ sectiondef=%Q{#{access}-type}
69
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="enum"][@prot="#{access}"]})
70
+ filter.map!{ |exp| exp =~ /^_Enum/ ? /@\d*/ : exp} unless filter.nil?
71
+ do_filter(filter, lst, Doxyparser::Enum) { |node|
72
+ node.xpath("name")[0].child.content
73
+ }
74
+ end
75
+
76
+ def typedefs access=:public, filter=nil
77
+ sectiondef=%Q{#{access}-type}
78
+ lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="typedef"][@prot="#{access}"]})
79
+ do_filter(filter, lst, Doxyparser::Typedef) { |node| del_spaces node.xpath("name")[0].child.content }
80
+ end
81
+
82
+ private
83
+
84
+ def compute_path
85
+ aux = escape_class_name @name
86
+ @xml_path = %Q{#{@dir}/struct#{aux}.xml}
87
+ end
88
+ end
89
+ end