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,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 src_dir, xml_dir, recursive = nil, include_dirs = nil, generate_html = nil
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
- inc_dirs = include_dirs.join(', ')
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= #{src_dir}\nGENERATE_HTML\t\t= #{gen_html}\n}
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')
@@ -1,13 +1,13 @@
1
1
  module Doxyparser
2
2
 
3
- class Class < Struct
3
+ class Class < Struct
4
4
 
5
- private
5
+ private
6
6
 
7
- def compute_path
8
- aux = escape_class_name @name
9
- @xml_path = %Q{#{@dir}/class#{aux}.xml}
10
- end
7
+ def compute_path
8
+ aux = escape_class_name(@name)
9
+ @xml_path = %Q{#{@dir}/class#{aux}.xml}
10
+ end
11
11
 
12
- end
12
+ end
13
13
  end
@@ -1,42 +1,42 @@
1
1
  module Doxyparser
2
2
 
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
17
- @xml_path = %Q{#{@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
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
@@ -1,20 +1,20 @@
1
1
  module Doxyparser
2
2
 
3
- class Enum < Member
3
+ class Enum < Member
4
4
 
5
- def values
6
- ret=[]
7
- xpath("enumvalue/name").each { |v| ret << v.child.content }
8
- ret
9
- end
5
+ def values
6
+ ret=[]
7
+ xpath("enumvalue/name").each { |v| ret << v.child.content }
8
+ ret
9
+ end
10
10
 
11
- private
11
+ private
12
12
 
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
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
@@ -1,20 +1,20 @@
1
1
  module Doxyparser
2
2
 
3
- class Friend < Member
3
+ class Friend < Member
4
4
 
5
- def is_class?
6
- args.nil? || args == ""
7
- end
5
+ def is_class?
6
+ args.nil? || args == ""
7
+ end
8
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
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
@@ -1,54 +1,60 @@
1
1
  module Doxyparser
2
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
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
@@ -1,6 +1,6 @@
1
1
  module Doxyparser
2
2
 
3
3
  class Group < Compound
4
-
4
+
5
5
  end
6
6
  end
@@ -1,73 +1,83 @@
1
1
  module Doxyparser
2
2
 
3
- class HFile < Compound
3
+ class HFile < Compound
4
4
 
5
- def list_included
6
- lst=doc.xpath(%Q{/doxygen/compounddef/includes})
7
- lst.map { |f| f.child.content }
8
- end
5
+ def list_included
6
+ lst=doc.xpath(%Q{/doxygen/compounddef/includes})
7
+ lst.map { |f| f.child.content }
8
+ end
9
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
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
- 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
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
- 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
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
- 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
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
- 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
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
- def namespaces
38
- lst=doc.xpath(%Q{/doxygen/compounddef/innernamespace})
39
- lst.map { |node| Doxyparser::Namespace.new(dir: @dir, node: node) }
40
- end
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
- 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
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
- 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
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
- 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
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
- 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
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
- private
63
-
64
- def find_name
65
- escape_file_name self.refid
66
- end
64
+ private
67
65
 
68
- def compute_path
69
- aux= escape_file_name @name
70
- @xml_path = %Q{#{@dir}/#{aux}.xml}
71
- end
72
- end
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