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/doxyparser.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
2
|
|
4
3
|
require 'nokogiri'
|
5
4
|
require 'fileutils'
|
@@ -45,21 +44,31 @@ module Doxyparser
|
|
45
44
|
Doxyparser::HFile.new :name => basename, :dir => xml_dir
|
46
45
|
end
|
47
46
|
|
48
|
-
def gen_xml_docs
|
47
|
+
def gen_xml_docs source_dirs, xml_dir, recursive = nil, include_dirs = nil, generate_html = nil
|
49
48
|
|
50
49
|
if include_dirs.nil? || include_dirs.empty?
|
51
50
|
inc_dirs = ''
|
52
51
|
else
|
53
|
-
|
52
|
+
if include_dirs.is_a? Array
|
53
|
+
inc_dirs = include_dirs.join(' ')
|
54
|
+
else
|
55
|
+
inc_dirs = include_dirs
|
56
|
+
end
|
57
|
+
end
|
58
|
+
if source_dirs.is_a? Array
|
59
|
+
proj_name = File.basename(source_dirs[0])
|
60
|
+
src_dirs = source_dirs.join(' ')
|
61
|
+
else
|
62
|
+
proj_name = File.basename(source_dirs)
|
63
|
+
src_dirs = source_dirs
|
54
64
|
end
|
55
|
-
recursive = recursive ? 'YES' : 'NO'
|
56
65
|
|
66
|
+
recursive = recursive ? 'YES' : 'NO'
|
57
67
|
home_dir = Doxyparser::Util.home_dir
|
58
68
|
gen_html = generate_html ? 'YES' : 'NO'
|
59
|
-
proj_name = File.basename src_dir
|
60
69
|
doxyfile = "# Doxyfile 1.7.6.1\n\n"
|
61
70
|
doxyfile << "# Project related configuration options\n\n"
|
62
|
-
doxyfile << %Q{PROJECT_NAME\t\t= "#{proj_name}"\nINPUT\t\t\t\t= #{
|
71
|
+
doxyfile << %Q{PROJECT_NAME\t\t= "#{proj_name}"\nINPUT\t\t\t\t= #{src_dirs}\nGENERATE_HTML\t\t= #{gen_html}\n}
|
63
72
|
doxyfile << %Q{RECURSIVE\t\t\t= #{recursive}\nINCLUDE_PATH\t\t= #{inc_dirs}\n\n}
|
64
73
|
doxyfile << "# Default doxygen configuration options\n\n"
|
65
74
|
doxyfile << Doxyparser::Util.read_file(home_dir+'/resources/Doxyfile')
|
data/lib/nodes/class.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
3
|
+
class Class < Struct
|
4
4
|
|
5
|
-
|
5
|
+
private
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def compute_path
|
8
|
+
aux = escape_class_name(@name)
|
9
|
+
@xml_path = %Q{#{@dir}/class#{aux}.xml}
|
10
|
+
end
|
11
11
|
|
12
|
-
|
12
|
+
end
|
13
13
|
end
|
data/lib/nodes/compound.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
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
|
-
|
3
|
+
class Compound < Node
|
4
|
+
|
5
|
+
attr_reader :xml_path
|
6
|
+
|
7
|
+
def new_unnamed
|
8
|
+
@unnamed += 1
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def init_attributes
|
14
|
+
super
|
15
|
+
@unnamed = 0
|
16
|
+
if @node && !@node['refid'].nil?
|
17
|
+
@xml_path = "#{@dir}/#{self.refid}.xml"
|
18
|
+
else
|
19
|
+
compute_path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_name
|
24
|
+
@node.child.content
|
25
|
+
end
|
26
|
+
|
27
|
+
def doc
|
28
|
+
if @doc.nil?
|
29
|
+
parse
|
30
|
+
end
|
31
|
+
@doc
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse
|
35
|
+
raise "No file found at this location: #{@xml_path} for node #{self.class.name} #{@name}" unless File.exists? @xml_path
|
36
|
+
File.open(@xml_path) { |xml_doc|
|
37
|
+
@doc=Nokogiri::XML(xml_doc)
|
38
|
+
}
|
39
|
+
self
|
40
|
+
end
|
41
|
+
end
|
42
42
|
end
|
data/lib/nodes/enum.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
3
|
+
class Enum < Member
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def values
|
6
|
+
ret=[]
|
7
|
+
xpath("enumvalue/name").each { |v| ret << v.child.content }
|
8
|
+
ret
|
9
|
+
end
|
10
10
|
|
11
|
-
|
11
|
+
private
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
def find_name
|
14
|
+
super.gsub(/@\d*/) {
|
15
|
+
num = parent.new_unnamed
|
16
|
+
'_Enum' + (num == 1 ? '' : num.to_s)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
data/lib/nodes/friend.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
3
|
+
class Friend < Member
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def is_class?
|
6
|
+
args.nil? || args == ""
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
20
|
end
|
data/lib/nodes/function.rb
CHANGED
@@ -1,54 +1,60 @@
|
|
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
|
-
|
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
|
+
ret = @basename.gsub(/^get[_]?(\w)/i) { |match| $1.downcase }
|
35
|
+
ret.prepend('_') if ret =~ %r{^\d}
|
36
|
+
return ret
|
37
|
+
end
|
38
|
+
if @type.name == 'bool'
|
39
|
+
if @basename.start_with?('is') || @basename.start_with?('Is')
|
40
|
+
ret = @basename.gsub(/^is[_]?(\w)/i) { |match| $1.downcase }
|
41
|
+
ret.prepend('_') if ret =~ %r{^\d}
|
42
|
+
return ret
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def setter_for
|
50
|
+
if (@type.name == 'void') && (@params.size == 1)
|
51
|
+
if @basename.start_with?('set') || @basename.start_with?('Set')
|
52
|
+
ret = @basename.gsub(/^set[_]?(\w)/i) { |match| $1.downcase }
|
53
|
+
ret.prepend('_') if ret =~ %r{^\d}
|
54
|
+
return ret
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
end
|
54
60
|
end
|
data/lib/nodes/group.rb
CHANGED
data/lib/nodes/hfile.rb
CHANGED
@@ -1,73 +1,83 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
3
|
+
class HFile < Compound
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def list_included
|
6
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/includes})
|
7
|
+
lst.map { |f| f.child.content }
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def files_included
|
16
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/includes[@local="yes"]})
|
17
|
+
lst.map { |f|
|
18
|
+
Doxyparser::HFile.new(dir: @dir, node: f)
|
19
|
+
}
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def files_including
|
23
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/includedby[@local="yes"]})
|
24
|
+
lst.map { |f| Doxyparser::HFile.new(dir: @dir, node: f) }
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def structs
|
28
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
29
|
+
lst = lst.select { |c| c["refid"].start_with?("struct") }
|
30
|
+
lst.map { |node| Doxyparser::Struct.new(dir: @dir, node: node) }
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def classes
|
34
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
35
|
+
lst = lst.select { |c| c["refid"].start_with?("class") }
|
36
|
+
lst.map { |node| Doxyparser::Class.new(dir: @dir, node: node) }
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
def namespaces
|
40
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/innernamespace})
|
41
|
+
lst.map { |node| Doxyparser::Namespace.new(dir: @dir, node: node) }
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
def functions
|
45
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]})
|
46
|
+
lst.map { |node| Doxyparser::Function.new(parent: self, node: node) }
|
47
|
+
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def variables
|
50
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]})
|
51
|
+
lst.map { |node| Doxyparser::Variable.new(parent: self, node: node) }
|
52
|
+
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def enums
|
55
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="enum"]/memberdef[@kind="enum"]})
|
56
|
+
lst.map { |node| Doxyparser::Enum.new(parent: self, node: node) }
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
def typedefs
|
60
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="typedef"]/memberdef[@kind="typedef"]})
|
61
|
+
lst.map { |node| Doxyparser::Typedef.new(parent: self, node: node) }
|
62
|
+
end
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
def find_name
|
65
|
-
escape_file_name self.refid
|
66
|
-
end
|
64
|
+
private
|
67
65
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
def find_name
|
67
|
+
if @node['refid'].nil?
|
68
|
+
@node.child.content
|
69
|
+
else
|
70
|
+
escape_file_name(self.refid)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def del_prefix_for(str)
|
75
|
+
del_prefix_file(str)
|
76
|
+
end
|
77
|
+
|
78
|
+
def compute_path
|
79
|
+
aux= escape_file_name(@name)
|
80
|
+
@xml_path = %Q{#{@dir}/#{aux}.xml}
|
81
|
+
end
|
82
|
+
end
|
73
83
|
end
|