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.
@@ -1,61 +1,65 @@
1
1
  module Doxyparser
2
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
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
@@ -2,55 +2,57 @@ module Doxyparser
2
2
 
3
3
  class Namespace < Compound
4
4
 
5
- def functions filter=nil
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
- node.xpath("name")[0].child.content.strip
8
+ node.xpath("name")[0].child.content.strip
9
9
  }
10
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?
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
- node.xpath("name")[0].child.content.strip
16
+ node.xpath("name")[0].child.content.strip
17
17
  }
18
18
  end
19
19
 
20
- def variables filter=nil
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 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 }
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 filter=nil
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 del_prefix(node.child.content)
37
+ del_spaces del_prefix_class(node.child.content)
36
38
  }
37
39
  end
38
-
39
- def structs filter=nil
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 del_prefix(node.child.content)
45
+ del_spaces del_prefix_class(node.child.content)
44
46
  }
45
47
  end
46
48
 
47
- def classes filter=nil
48
- lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
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 del_prefix(node.child.content)
53
+ del_spaces del_prefix_class(node.child.content)
52
54
  }
53
- end
55
+ end
54
56
 
55
57
  def file
56
58
  nil
@@ -1,63 +1,68 @@
1
1
  module Doxyparser
2
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
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
@@ -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 node: type_temp[0], parent: @parent
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")
@@ -1,89 +1,119 @@
1
1
  module Doxyparser
2
2
 
3
- class Struct < Compound
3
+ class Struct < Compound
4
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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- 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
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
- private
112
+ private
83
113
 
84
- def compute_path
85
- aux = escape_class_name @name
86
- @xml_path = %Q{#{@dir}/struct#{aux}.xml}
87
- end
88
- end
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