doxyparser 1.3 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/doxyparser.rb +31 -10
- data/lib/nodes/class.rb +1 -0
- data/lib/nodes/compound.rb +1 -4
- data/lib/nodes/enum.rb +21 -8
- data/lib/nodes/enum_value.rb +20 -0
- data/lib/nodes/friend.rb +3 -0
- data/lib/nodes/function.rb +35 -21
- data/lib/nodes/hfile.rb +31 -34
- data/lib/nodes/member.rb +1 -0
- data/lib/nodes/namespace.rb +26 -10
- data/lib/nodes/node.rb +13 -5
- data/lib/nodes/param.rb +4 -0
- data/lib/nodes/struct.rb +204 -67
- data/lib/nodes/type.rb +39 -7
- data/lib/nodes/typedef.rb +1 -0
- data/lib/nodes/variable.rb +1 -0
- data/lib/util.rb +22 -4
- data/spec/class_spec.rb +27 -5
- data/spec/doxyparser_spec.rb +1 -2
- data/spec/enum_spec.rb +6 -6
- data/spec/file_spec.rb +1 -1
- data/spec/method_spec.rb +17 -1
- data/spec/namespace_spec.rb +1 -1
- data/spec/type_spec.rb +1 -1
- metadata +14 -25
- data/lib/nodes/group.rb +0 -6
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ddb97c91354a56d85495ca4dd7fdda3be9d02806
|
4
|
+
data.tar.gz: 78a25a5f867401e60d7212433cdb8a9d36debf74
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db5492d5aef0f23620ea7cd3af58726feae425fa83389195eb25f6dca1ff498bef49e1f591b4ad26ee4d5148d7f42b5920f7f4df629a702a368a8da646c50600
|
7
|
+
data.tar.gz: 8f26ecc142d43c7f71d3de4df6970d3b260aff6ffe626d7761749946996f2bc78da3a184d479458fc4b12f3f700446cc09228e0380b61f77fdc7024bda14b107
|
data/lib/doxyparser.rb
CHANGED
@@ -13,10 +13,10 @@ require_relative 'nodes/typedef'
|
|
13
13
|
require_relative 'nodes/friend'
|
14
14
|
require_relative 'nodes/struct'
|
15
15
|
require_relative 'nodes/class'
|
16
|
+
require_relative 'nodes/enum_value'
|
16
17
|
require_relative 'nodes/enum'
|
17
18
|
require_relative 'nodes/hfile'
|
18
19
|
require_relative 'nodes/function'
|
19
|
-
require_relative 'nodes/group'
|
20
20
|
require_relative 'nodes/namespace'
|
21
21
|
require_relative 'nodes/variable'
|
22
22
|
|
@@ -24,27 +24,47 @@ require_relative 'nodes/variable'
|
|
24
24
|
module Doxyparser
|
25
25
|
|
26
26
|
class << self
|
27
|
+
|
28
|
+
# Retrieves metadata for a given Namespace
|
29
|
+
# @param basename [String] Name of the namespace to parse (for instance: NamespaceA::NamespaceB)
|
30
|
+
# @param xml_dir [String] Path to the directory with the generated intermediate XML representation
|
31
|
+
# @return [Namespace] A tree of objects representing the namespace and its members (classes, structs, enums, etc)
|
27
32
|
def parse_namespace basename, xml_dir
|
28
33
|
Doxyparser::Namespace.new :name => basename, :dir => xml_dir
|
29
34
|
end
|
30
35
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
# Retrieves metadata for a given Class
|
37
|
+
# @param basename [String] Name of the class to parse (for instance: MyNamespace::MyClass)
|
38
|
+
# @param xml_dir [String] Path to the directory with the generated intermediate XML representation
|
39
|
+
# @return [Class] A tree of objects representing the class and its members (attributes, methods, innerclasses, etc)
|
35
40
|
def parse_class basename, xml_dir
|
36
41
|
Doxyparser::Class.new :name => basename, :dir => xml_dir
|
37
42
|
end
|
38
43
|
|
39
|
-
|
44
|
+
# Retrieves metadata for a given Struct
|
45
|
+
# @param basename [String] Name of the struct to parse (for instance: MyNamespace::MyStruct)
|
46
|
+
# @param xml_dir [String] Path to the directory with the generated intermediate XML representation
|
47
|
+
# @return [Struct] A tree of objects representing the struct and its members (attributes, methods, enums, etc)
|
48
|
+
def parse_struct(basename, xml_dir)
|
40
49
|
Doxyparser::Struct.new :name => basename, :dir => xml_dir
|
41
50
|
end
|
42
|
-
|
43
|
-
|
51
|
+
|
52
|
+
# Retrieves metadata for a given header file
|
53
|
+
# @param basename [String] Name of the header file to parse (for instance: myheader.h)
|
54
|
+
# @param xml_dir [String] Path to the directory with the generated intermediate XML representation
|
55
|
+
# @return [HFile] A tree of objects representing the header file and its contents (classes, functions, enums, etc)
|
56
|
+
def parse_file(basename, xml_dir)
|
44
57
|
Doxyparser::HFile.new :name => basename, :dir => xml_dir
|
45
58
|
end
|
46
59
|
|
47
|
-
|
60
|
+
# Generates intermediate XML representation for a group of header files
|
61
|
+
# @param source_dirs [Array<String>, String] Input source directory (or directories)
|
62
|
+
# @param xml_dir [String] Output Directory for the generated XML documents
|
63
|
+
# @param recursive if present (and not nil) sets the RECURSIVE FLAG in Doxygen. Subdirectories will also be searched
|
64
|
+
# @param include_dirs [Array<String>, String] Adds given directories to Doxygen's INCLUDE_PATH (Doxyfile variable)
|
65
|
+
# @param generate_html if present (and not nil) HTML documentation will also be generated
|
66
|
+
# @param stl_support if present (and not nil) sets the BUILTIN_STL_SUPPORT flag in Doxygen. Special support for STL Libraries
|
67
|
+
def gen_xml_docs(source_dirs, xml_dir, recursive = nil, include_dirs = nil, generate_html = nil, stl_support = 1)
|
48
68
|
|
49
69
|
if include_dirs.nil? || include_dirs.empty?
|
50
70
|
inc_dirs = ''
|
@@ -66,10 +86,11 @@ module Doxyparser
|
|
66
86
|
recursive = recursive ? 'YES' : 'NO'
|
67
87
|
home_dir = Doxyparser::Util.home_dir
|
68
88
|
gen_html = generate_html ? 'YES' : 'NO'
|
89
|
+
stl_support = stl_support ? 'YES' : 'NO'
|
69
90
|
doxyfile = "# Doxyfile 1.7.6.1\n\n"
|
70
91
|
doxyfile << "# Project related configuration options\n\n"
|
71
92
|
doxyfile << %Q{PROJECT_NAME\t\t= "#{proj_name}"\nINPUT\t\t\t\t= #{src_dirs}\nGENERATE_HTML\t\t= #{gen_html}\n}
|
72
|
-
doxyfile << %Q{RECURSIVE\t\t\t= #{recursive}\nINCLUDE_PATH\t\t= #{inc_dirs}\
|
93
|
+
doxyfile << %Q{RECURSIVE\t\t\t= #{recursive}\nINCLUDE_PATH\t\t= #{inc_dirs}\nBUILTIN_STL_SUPPORT\t= #{stl_support}\n}
|
73
94
|
doxyfile << "# Default doxygen configuration options\n\n"
|
74
95
|
doxyfile << Doxyparser::Util.read_file(home_dir+'/resources/Doxyfile')
|
75
96
|
doxyfile_path = xml_dir+'/Doxyfile'
|
data/lib/nodes/class.rb
CHANGED
data/lib/nodes/compound.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# Representation of a 'high level' {Node} which is represented in its own XML file such as namespaces, classes, etc
|
3
4
|
class Compound < Node
|
4
5
|
|
5
6
|
attr_reader :xml_path
|
6
7
|
|
7
|
-
def new_unnamed
|
8
|
-
@unnamed += 1
|
9
|
-
end
|
10
|
-
|
11
8
|
private
|
12
9
|
|
13
10
|
def init_attributes
|
data/lib/nodes/enum.rb
CHANGED
@@ -1,20 +1,33 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# A C/C++ Enumeration
|
3
4
|
class Enum < Member
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
xpath("enumvalue/name").each { |v| ret << v.child.content }
|
8
|
-
ret
|
9
|
-
end
|
6
|
+
# [Array<EnumValue>] List of values
|
7
|
+
attr_reader :values
|
10
8
|
|
11
9
|
private
|
12
10
|
|
11
|
+
def init_attributes
|
12
|
+
super
|
13
|
+
@values= []
|
14
|
+
all_values = self.xpath("enumvalue")
|
15
|
+
return if all_values.nil? || all_values.empty?
|
16
|
+
all_values.each { |enumvalue|
|
17
|
+
@values << Doxyparser::EnumValue.new(node: enumvalue, parent: self)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
13
21
|
def find_name
|
14
22
|
super.gsub(/@\d*/) {
|
15
|
-
|
16
|
-
|
23
|
+
prefix = (parent.class == Doxyparser::Namespace) ? 'ns_' : ''
|
24
|
+
if (parent.class == Doxyparser::HFile)
|
25
|
+
enum_name = 'file_' + escape_file_name(parent.basename.gsub(/\.\w+$/, ''))
|
26
|
+
else
|
27
|
+
enum_name = parent.basename
|
28
|
+
end
|
29
|
+
"#{prefix}#{enum_name}_Enum"
|
17
30
|
}
|
18
31
|
end
|
19
32
|
end
|
20
|
-
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Doxyparser
|
2
|
+
|
3
|
+
# Every one of the members of an {Enum}
|
4
|
+
class EnumValue < Node
|
5
|
+
|
6
|
+
attr_reader :initializer
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def find_name
|
11
|
+
@parent.name + '::' + @node.xpath("name")[0].child.content
|
12
|
+
end
|
13
|
+
|
14
|
+
def init_attributes
|
15
|
+
super
|
16
|
+
aux_initializer = @node.xpath("initializer")
|
17
|
+
@initializer = aux_initializer[0].child.content.strip unless (aux_initializer.nil? || aux_initializer.empty?)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/nodes/friend.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# A friend member declared inside a C++ {Class}. Can itself refer to an external {Function} or {Class}
|
3
4
|
class Friend < Member
|
4
5
|
|
6
|
+
# @return true if the friend declaration refers to a {Class} false if refers to a {Function}
|
5
7
|
def is_class?
|
6
8
|
args.nil? || args == ""
|
7
9
|
end
|
8
10
|
|
11
|
+
# @return true if the name used in the declaration is fully qualified (using the '::' operator) false otherwise
|
9
12
|
def is_qualified?
|
10
13
|
basename.include? '::'
|
11
14
|
end
|
data/lib/nodes/function.rb
CHANGED
@@ -1,35 +1,27 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# A C/C++ function with its parameters und return type
|
3
4
|
class Function < Member
|
4
5
|
|
5
|
-
|
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
|
-
|
6
|
+
# @return true if the function is a constructor of a {Struct} or {Class}
|
23
7
|
def constructor?
|
24
8
|
@basename == parent.basename
|
25
9
|
end
|
26
10
|
|
11
|
+
# @return true if the function is a destructor of a {Struct} or {Class}
|
27
12
|
def destructor?
|
28
13
|
@basename.start_with? %Q{~}
|
29
14
|
end
|
30
15
|
|
31
|
-
|
32
|
-
|
16
|
+
# Finds the name of the -hypothetical- property this method refers to in case this {Function} complies
|
17
|
+
# with the 'getter' naming convention and has no parameters.
|
18
|
+
# Getter examples for 'myProperty' are: getMyProperty, get_myProperty, GetMyProperty, Get_MyProperty, etc
|
19
|
+
# Getter examples for 'booleanProp' are: isBooleanProp, is_booleanProp, get_booleanProp, etc
|
20
|
+
# @return [String] name of the property
|
21
|
+
def getter_for
|
22
|
+
return nil if @type.name == 'void'
|
23
|
+
|
24
|
+
if @params.empty? || (@params.size == 1 && @params[0].type.name.strip == 'void')
|
33
25
|
if @basename.start_with?('get') || @basename.start_with?('Get')
|
34
26
|
ret = @basename.gsub(/^get[_]?(\w)/i) { |match| $1.downcase }
|
35
27
|
ret.prepend('_') if ret =~ %r{^\d}
|
@@ -46,8 +38,12 @@ module Doxyparser
|
|
46
38
|
return nil
|
47
39
|
end
|
48
40
|
|
41
|
+
# Finds the name of the -hypothetical- property this method refers to in case this {Function} complies
|
42
|
+
# with the 'setter' naming convention and has no return value (void).
|
43
|
+
# Setter examples for 'myProperty' are: setMyProperty, set_myProperty, SetMyProperty, Set_MyProperty, etc
|
44
|
+
# @return [String] name of the property
|
49
45
|
def setter_for
|
50
|
-
if (@type.name == 'void') && (@params.size == 1)
|
46
|
+
if (@type.name == 'void') && (@params.size == 1 && @params[0].type.name.strip != 'void')
|
51
47
|
if @basename.start_with?('set') || @basename.start_with?('Set')
|
52
48
|
ret = @basename.gsub(/^set[_]?(\w)/i) { |match| $1.downcase }
|
53
49
|
ret.prepend('_') if ret =~ %r{^\d}
|
@@ -56,5 +52,23 @@ module Doxyparser
|
|
56
52
|
end
|
57
53
|
return nil
|
58
54
|
end
|
55
|
+
|
56
|
+
def == another
|
57
|
+
super
|
58
|
+
self.args == another.args
|
59
|
+
end
|
60
|
+
|
61
|
+
def eql?(another)
|
62
|
+
super
|
63
|
+
self.args == another.args
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_str
|
67
|
+
super + @args
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_s
|
71
|
+
super + @args
|
72
|
+
end
|
59
73
|
end
|
60
74
|
end
|
data/lib/nodes/hfile.rb
CHANGED
@@ -1,64 +1,61 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# Representation of a C/C++ header file
|
3
4
|
class HFile < Compound
|
4
5
|
|
6
|
+
# @return [Array<String>] names for all header files which are listed as include statements in this header file
|
5
7
|
def list_included
|
6
|
-
|
7
|
-
lst.map { |f| f.child.content }
|
8
|
+
@list_included ||= doc.xpath(%Q{/doxygen/compounddef/includes}).map { |f| f.child.content }
|
8
9
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
|
11
|
+
# @return [Array<HFile>] local header files which are listed as include statements in this header file
|
12
|
+
def files_included
|
13
|
+
@files_included ||= doc.xpath(%Q{/doxygen/compounddef/includes[@local="yes"]}).map { |f| Doxyparser::HFile.new(dir: @dir, node: f) }
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Doxyparser::HFile.new(dir: @dir, node: f)
|
19
|
-
}
|
16
|
+
# @return [Array<String>] names for all header files which refer to this one in their include statements
|
17
|
+
def list_including
|
18
|
+
@list_including ||= doc.xpath(%Q{/doxygen/compounddef/includedby}).map { |f| f[:refid].nil? ? f.child.content : escape_file_name(f[:refid]) }
|
20
19
|
end
|
21
20
|
|
21
|
+
# @return [Array<HFile>] local header files which refer to this one in their include statements
|
22
22
|
def files_including
|
23
|
-
|
24
|
-
lst.map { |f| Doxyparser::HFile.new(dir: @dir, node: f) }
|
23
|
+
@files_including ||= doc.xpath(%Q{/doxygen/compounddef/includedby[@local="yes"]}).map { |f| Doxyparser::HFile.new(dir: @dir, node: f) }
|
25
24
|
end
|
26
|
-
|
25
|
+
|
26
|
+
# @return [Array<Struct>] structs declared inside this header file
|
27
27
|
def structs
|
28
|
-
|
29
|
-
lst = lst.select { |c| c["refid"].start_with?("struct") }
|
30
|
-
lst.map { |node| Doxyparser::Struct.new(dir: @dir, node: node) }
|
28
|
+
@structs ||= doc.xpath(%Q{/doxygen/compounddef/innerclass}).select { |c| c["refid"].start_with?("struct") }.map { |node| Doxyparser::Struct.new(dir: @dir, node: node) }
|
31
29
|
end
|
32
30
|
|
31
|
+
# @return [Array<Class>] classes declared inside this header file
|
33
32
|
def classes
|
34
|
-
|
35
|
-
lst = lst.select { |c| c["refid"].start_with?("class") }
|
36
|
-
lst.map { |node| Doxyparser::Class.new(dir: @dir, node: node) }
|
33
|
+
@classes ||= doc.xpath(%Q{/doxygen/compounddef/innerclass}).select { |c| c["refid"].start_with?("class") }.map { |node| Doxyparser::Class.new(dir: @dir, node: node) }
|
37
34
|
end
|
38
|
-
|
35
|
+
|
36
|
+
# @return [Array<Namespace>] namespaces declared inside this header file
|
39
37
|
def namespaces
|
40
|
-
|
41
|
-
lst.map { |node| Doxyparser::Namespace.new(dir: @dir, node: node) }
|
38
|
+
@namespaces ||= doc.xpath(%Q{/doxygen/compounddef/innernamespace}).map { |node| Doxyparser::Namespace.new(dir: @dir, node: node) }
|
42
39
|
end
|
43
|
-
|
40
|
+
|
41
|
+
# @return [Array<Function>] functions declared inside this header file
|
44
42
|
def functions
|
45
|
-
|
46
|
-
lst.map { |node| Doxyparser::Function.new(parent: self, node: node) }
|
43
|
+
@functions ||= doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]}).map { |node| Doxyparser::Function.new(parent: self, node: node) }
|
47
44
|
end
|
48
|
-
|
45
|
+
|
46
|
+
# @return [Array<Variable>] variables declared inside this header file
|
49
47
|
def variables
|
50
|
-
|
51
|
-
lst.map { |node| Doxyparser::Variable.new(parent: self, node: node) }
|
48
|
+
@variables ||= doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]}).map { |node| Doxyparser::Variable.new(parent: self, node: node) }
|
52
49
|
end
|
53
|
-
|
50
|
+
|
51
|
+
# @return [Array<Enum>] enums declared inside this header file
|
54
52
|
def enums
|
55
|
-
|
56
|
-
lst.map { |node| Doxyparser::Enum.new(parent: self, node: node) }
|
53
|
+
@enums ||= doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="enum"]/memberdef[@kind="enum"]}).map { |node| Doxyparser::Enum.new(parent: self, node: node) }
|
57
54
|
end
|
58
55
|
|
56
|
+
# @return [Array<Typedef>] typedefs declared inside this header file
|
59
57
|
def typedefs
|
60
|
-
|
61
|
-
lst.map { |node| Doxyparser::Typedef.new(parent: self, node: node) }
|
58
|
+
@typedefs ||= doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="typedef"]/memberdef[@kind="typedef"]}).map { |node| Doxyparser::Typedef.new(parent: self, node: node) }
|
62
59
|
end
|
63
60
|
|
64
61
|
private
|
data/lib/nodes/member.rb
CHANGED
data/lib/nodes/namespace.rb
CHANGED
@@ -1,59 +1,75 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# A C/C++ Namespace
|
3
4
|
class Namespace < Compound
|
4
5
|
|
6
|
+
# @return [Array<Function>] list of functions defined inside this namespace but outside any {Class} or {Struct}
|
5
7
|
def functions(filter=nil)
|
8
|
+
return @functions if @functions
|
6
9
|
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="func"]/memberdef[@kind="function"]})
|
7
|
-
do_filter(filter, lst, Doxyparser::Function) { |node|
|
10
|
+
@functions = do_filter(filter, lst, Doxyparser::Function) { |node|
|
8
11
|
node.xpath("name")[0].child.content.strip
|
9
12
|
}
|
10
13
|
end
|
11
14
|
|
15
|
+
# @return [Array<Enum>] list of enums defined inside this namespace but outside any {Class} or {Struct}
|
12
16
|
def enums(filter=nil)
|
17
|
+
return @enums if @enums
|
13
18
|
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="enum"]/memberdef[@kind="enum"]})
|
14
|
-
filter.map! { |exp| exp =~
|
15
|
-
do_filter(filter, lst, Doxyparser::Enum) { |node|
|
19
|
+
filter.map! { |exp| exp =~ /^#{@basename}_Enum/ ? /@\d*/ : exp } unless filter.nil?
|
20
|
+
@enums = do_filter(filter, lst, Doxyparser::Enum) { |node|
|
16
21
|
node.xpath("name")[0].child.content.strip
|
17
22
|
}
|
18
23
|
end
|
19
24
|
|
20
|
-
|
25
|
+
# @return [Array<Variable>] list of variables defined inside this namespace but are not attributes of any {Class} or {Struct}
|
26
|
+
def variables(filter=nil)
|
27
|
+
return @variables if @variables
|
21
28
|
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="var"]/memberdef[@kind="variable"]})
|
22
|
-
do_filter(filter, lst, Doxyparser::Variable) { |node|
|
29
|
+
@variables = do_filter(filter, lst, Doxyparser::Variable) { |node|
|
23
30
|
node.xpath("name")[0].child.content.strip
|
24
31
|
}
|
25
32
|
end
|
26
33
|
|
34
|
+
# @return [Array<Typedef>] list of typedefs defined inside this namespace but outside any {Class} or {Struct}
|
27
35
|
def typedefs(filter=nil)
|
36
|
+
return @typedefs if @typedefs
|
28
37
|
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="typedef"]/memberdef[@kind="typedef"]})
|
29
|
-
do_filter(filter, lst, Doxyparser::Typedef) { |node|
|
38
|
+
@typedefs = do_filter(filter, lst, Doxyparser::Typedef) { |node|
|
30
39
|
del_spaces(node.xpath("name")[0].child.content)
|
31
40
|
}
|
32
41
|
end
|
33
|
-
|
42
|
+
|
43
|
+
# @return [Array<Namespace>] list of namespaces defined inside this one
|
34
44
|
def innernamespaces(filter=nil)
|
45
|
+
return @innernamespaces if @innernamespaces
|
35
46
|
lst = doc.xpath(%Q{/doxygen/compounddef/innernamespace})
|
36
|
-
do_filter(filter, lst, Doxyparser::Namespace) { |node|
|
47
|
+
@innernamespaces = do_filter(filter, lst, Doxyparser::Namespace) { |node|
|
37
48
|
del_spaces del_prefix_class(node.child.content)
|
38
49
|
}
|
39
50
|
end
|
40
51
|
|
52
|
+
# @return [Array<Struct>] list of structs defined in this namespace
|
41
53
|
def structs(filter=nil)
|
54
|
+
return @structs if @structs
|
42
55
|
lst = doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
43
56
|
lst = lst.select { |c| c["refid"].start_with?("struct") }
|
44
|
-
do_filter(filter, lst, Doxyparser::Struct) { |node|
|
57
|
+
@structs = do_filter(filter, lst, Doxyparser::Struct) { |node|
|
45
58
|
del_spaces del_prefix_class(node.child.content)
|
46
59
|
}
|
47
60
|
end
|
48
61
|
|
62
|
+
# @return [Array<Class>] list of classes defined in this namespace
|
49
63
|
def classes(filter=nil)
|
64
|
+
return @classes if @classes
|
50
65
|
lst = doc.xpath(%Q{/doxygen/compounddef/innerclass})
|
51
66
|
lst = lst.select { |c| c["refid"].start_with?("class") }
|
52
|
-
do_filter(filter, lst, Doxyparser::Class) { |node|
|
67
|
+
@classes = do_filter(filter, lst, Doxyparser::Class) { |node|
|
53
68
|
del_spaces del_prefix_class(node.child.content)
|
54
69
|
}
|
55
70
|
end
|
56
71
|
|
72
|
+
# @return nil always
|
57
73
|
def file
|
58
74
|
nil
|
59
75
|
end
|
data/lib/nodes/node.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# A Node can be any member of the tree-like structure of a C/C++ header file.
|
4
|
+
# examples are namespaces, classes, methods, params, etc
|
3
5
|
class Node
|
4
6
|
include Doxyparser::Util
|
5
|
-
|
7
|
+
|
6
8
|
attr_reader :dir
|
7
9
|
attr_reader :name
|
8
10
|
attr_reader :basename
|
9
11
|
attr_reader :node
|
10
12
|
attr_reader :doc
|
11
|
-
|
13
|
+
attr_accessor :parent
|
12
14
|
|
13
15
|
def == another
|
14
16
|
self.name == another.name
|
@@ -31,24 +33,30 @@ module Doxyparser
|
|
31
33
|
@dir = hash[:dir]
|
32
34
|
@name = hash[:name]
|
33
35
|
if hash[:node] # If a reference to an xml declaration (node) is given
|
34
|
-
# then...
|
35
36
|
@node = hash[:node]
|
36
37
|
@parent = hash[:parent]
|
37
38
|
@name = find_name
|
39
|
+
if @name =~ /PxVec3.h/
|
40
|
+
@name = find_name
|
41
|
+
end
|
38
42
|
@dir ||= @parent.dir unless @parent.nil?
|
39
43
|
end
|
40
44
|
raise "No name given for node: #{self.class.name}" unless @name
|
41
45
|
raise "No xml directory given for node: #{self.class.name}" unless @dir
|
42
46
|
init_attributes
|
43
47
|
end
|
48
|
+
|
49
|
+
def escaped_name
|
50
|
+
name
|
51
|
+
end
|
44
52
|
|
45
53
|
private
|
46
54
|
|
47
55
|
def method_missing(sym, *args)
|
48
56
|
if @node.respond_to?(sym)
|
49
|
-
|
57
|
+
@node.send(sym, *args)
|
50
58
|
else
|
51
|
-
|
59
|
+
@node[sym.to_s] || super
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
data/lib/nodes/param.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# Each of the input parameters of a {Function}
|
3
4
|
class Param < Node
|
4
5
|
|
6
|
+
# Type of parameter
|
5
7
|
attr_reader :type
|
8
|
+
# Declared name of parameter
|
6
9
|
attr_reader :declname
|
10
|
+
# Default value of parameter
|
7
11
|
attr_reader :value
|
8
12
|
|
9
13
|
private
|
data/lib/nodes/struct.rb
CHANGED
@@ -1,60 +1,105 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# A plain old OOP Class
|
3
4
|
class Struct < Compound
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
HFile.new(dir: @dir, node: n)
|
5
|
+
|
6
|
+
# @return [bool] true if any of its methods is 'pure virtual'
|
7
|
+
def abstract?
|
8
|
+
@is_abstract ||= methods(:all).any? { |m| m.virt == 'pure-virtual'}
|
9
9
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
|
11
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
12
|
+
# @return [Array<Function>] declared constructors
|
13
|
+
def constructors(access = :public)
|
14
|
+
return case access
|
15
|
+
when :public
|
16
|
+
@public_constructors ||= methods(:public, nil, [@basename])
|
17
|
+
when :protected
|
18
|
+
@protected_constructors ||= methods(:protected, nil, [@basename])
|
19
|
+
when :private
|
20
|
+
@private_constructors ||= methods(:private, nil, [@basename])
|
21
|
+
when :all
|
22
|
+
constructors(:public) + constructors(:protected) + constructors(:private)
|
23
|
+
end
|
16
24
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
|
26
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
27
|
+
# @return [Array<Function>] declared destructors
|
28
|
+
def destructors(access = :public)
|
29
|
+
return case access
|
30
|
+
when :public
|
31
|
+
@public_destructors ||= methods(:public, nil, [/^~/])
|
32
|
+
when :protected
|
33
|
+
@protected_destructors ||= methods(:protected, nil, [/^~/])
|
34
|
+
when :private
|
35
|
+
@private_destructors ||= methods(:private, nil, [/^~/])
|
36
|
+
when :all
|
37
|
+
destructors(:public) + destructors(:protected) + destructors(:private)
|
38
|
+
end
|
23
39
|
end
|
24
|
-
|
40
|
+
|
41
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
42
|
+
# @param static If nil are static members excluded. If not nil only static members are returned
|
43
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
44
|
+
# @return [Array<Function>] declared methods
|
25
45
|
def methods(access = :public, static = nil, filter = nil)
|
26
46
|
if access == :all
|
27
47
|
return methods(:public, static, filter) + methods(:protected, static, filter) + methods(:private, static, filter)
|
28
48
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
49
|
+
if access == :public && filter.nil? # Caches public methods
|
50
|
+
if static.nil?
|
51
|
+
@public_methods ||= _methods(:public, nil, nil)
|
52
|
+
return @public_methods
|
53
|
+
end
|
54
|
+
@public_static_methods ||= _methods(:public, true, nil)
|
55
|
+
return @public_static_methods
|
56
|
+
end
|
57
|
+
_methods(access, static, filter)
|
39
58
|
end
|
40
59
|
|
60
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
61
|
+
# @param static If nil are static members excluded. If not nil only static members are returned
|
62
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
63
|
+
# @return [Array<Variable>] declared attributes
|
41
64
|
def attributes(access = :public, static = nil, filter = nil)
|
42
65
|
if access == :all
|
43
66
|
return attributes(:public, static, filter) + attributes(:protected, static, filter) + attributes(:private, static, filter)
|
44
67
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
68
|
+
if access == :public && filter.nil? # Caches public attributes
|
69
|
+
if static.nil?
|
70
|
+
@public_attributes ||= _attributes(:public, nil, nil)
|
71
|
+
return @public_attributes
|
72
|
+
end
|
73
|
+
@public_static_attributes ||= _attributes(:public, true, nil)
|
74
|
+
return @public_static_attributes
|
75
|
+
end
|
76
|
+
_attributes(access, static, filter)
|
55
77
|
end
|
56
|
-
|
78
|
+
|
79
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
80
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
81
|
+
# @return [Array<Struct>] declared inner-classes and inner-structs
|
57
82
|
def innerclasses(access = :public, filter = nil)
|
83
|
+
if filter.nil?
|
84
|
+
if access == :all
|
85
|
+
@all_innerclasses ||= innerclasses(:public) + innerclasses(:protected) + innerclasses(:private)
|
86
|
+
return @all_innerclasses
|
87
|
+
end
|
88
|
+
if access == :public
|
89
|
+
@public_innerclasses ||= only_innerclasses(:public) + only_innerstructs(:public)
|
90
|
+
return @public_innerclasses
|
91
|
+
end
|
92
|
+
end
|
93
|
+
if access == :all
|
94
|
+
return innerclasses(:public, filter) + innerclasses(:protected, filter) + innerclasses(:private, filter)
|
95
|
+
end
|
96
|
+
only_innerclasses(access, filter) + only_innerstructs(access, filter)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
100
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
101
|
+
# @return [Array<Struct>] declared inner-classes (inner-structs are excluded)
|
102
|
+
def only_innerclasses(access = :public, filter = nil)
|
58
103
|
if access == :all
|
59
104
|
return innerclasses(:public, filter) + innerclasses(:protected, filter) + innerclasses(:private, filter)
|
60
105
|
end
|
@@ -64,18 +109,11 @@ module Doxyparser
|
|
64
109
|
del_prefix(node.child.content)
|
65
110
|
}
|
66
111
|
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
|
77
112
|
|
78
|
-
|
113
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
114
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
115
|
+
# @return [Array<Struct>] declared inner-structs (inner-classes are excluded)
|
116
|
+
def only_innerstructs(access = :public, filter = nil)
|
79
117
|
if access == :all
|
80
118
|
return innerstructs(:public, filter) + innerstructs(:protected, filter) + innerstructs(:private, filter)
|
81
119
|
end
|
@@ -85,35 +123,134 @@ module Doxyparser
|
|
85
123
|
del_prefix(node.child.content)
|
86
124
|
}
|
87
125
|
end
|
88
|
-
|
89
|
-
|
126
|
+
|
127
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
128
|
+
# @return [Array<Type>] declared super-types for this struct/class
|
129
|
+
def parent_types(access = :public)
|
130
|
+
if access == :public
|
131
|
+
@public_parent_types ||= _parent_types(:public)
|
132
|
+
return @public_parent_types
|
133
|
+
end
|
90
134
|
if access == :all
|
91
|
-
|
135
|
+
@all_parent_types ||= parent_types(:public) + parent_types(:protected) + parent_types(:private)
|
136
|
+
return @all_parent_types
|
92
137
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
138
|
+
_parent_types(access)
|
139
|
+
end
|
140
|
+
|
141
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
142
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
143
|
+
# @return [Array<Enum>] declared enums
|
144
|
+
def enums(access = :public, filter = nil)
|
145
|
+
if access == :public && filter.nil?
|
146
|
+
@public_enums ||= _enums(:public)
|
147
|
+
return @public_enums
|
148
|
+
end
|
149
|
+
if access == :all && filter.nil?
|
150
|
+
@all_enums ||= enums(:public) + enums(:protected) + enums(:private)
|
151
|
+
return @all_enums
|
152
|
+
end
|
153
|
+
_enums(access, filter)
|
154
|
+
end
|
155
|
+
|
156
|
+
# @param access [Symbol] access modifier (:public, :protected, :private, :all)
|
157
|
+
# @param filter [Array<String>] list of Regex. Members whose name does not match any of the regexes will be excluded
|
158
|
+
# @return [Array<Typedef>] declared typedefs
|
159
|
+
def typedefs(access = :public, filter = nil)
|
160
|
+
if access == :public && filter.nil?
|
161
|
+
@public_typedefs ||= _typedefs(:public)
|
162
|
+
return @public_typedefs
|
163
|
+
end
|
164
|
+
if access == :all && filter.nil?
|
165
|
+
@all_typedefs ||= typedefs(:public) + typedefs(:protected) + typedefs(:private)
|
166
|
+
return @all_typedefs
|
167
|
+
end
|
168
|
+
_typedefs(access, filter)
|
169
|
+
end
|
170
|
+
|
171
|
+
private
|
172
|
+
|
173
|
+
attr_reader :file
|
174
|
+
attr_reader :friends
|
175
|
+
attr_reader :template_params
|
176
|
+
|
177
|
+
|
178
|
+
def _methods(access = :public, static = nil, filter = nil)
|
179
|
+
if static.nil?
|
180
|
+
static = "-"
|
181
|
+
else
|
182
|
+
static = "-static-"
|
183
|
+
end
|
184
|
+
sectiondef = %Q{#{access}#{static}func}
|
185
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="function"][@prot="#{access}"]})
|
186
|
+
do_filter(filter, lst, Doxyparser::Function) { |node|
|
187
|
+
node.xpath("name")[0].child.content
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
191
|
+
def _attributes(access = :public, static = nil, filter = nil)
|
192
|
+
if static.nil?
|
193
|
+
static = "-"
|
194
|
+
else
|
195
|
+
static = "-static-"
|
196
|
+
end
|
197
|
+
sectiondef = %Q{#{access}#{static}attrib}
|
198
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="variable"][@prot="#{access}"]})
|
199
|
+
do_filter(filter, lst, Doxyparser::Variable) { |node|
|
97
200
|
node.xpath("name")[0].child.content
|
98
201
|
}
|
99
202
|
end
|
100
203
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
204
|
+
def compute_path
|
205
|
+
aux = escape_class_name(@name)
|
206
|
+
@xml_path = %Q{#{@dir}/struct#{aux}.xml}
|
207
|
+
end
|
208
|
+
|
209
|
+
def _typedefs(access, filter=nil)
|
210
|
+
sectiondef = %Q{#{access}-type}
|
106
211
|
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="typedef"][@prot="#{access}"]})
|
107
212
|
do_filter(filter, lst, Doxyparser::Typedef) { |node|
|
108
213
|
del_spaces node.xpath("name")[0].child.content
|
109
214
|
}
|
110
215
|
end
|
216
|
+
|
217
|
+
def _enums(access, filter=nil)
|
218
|
+
sectiondef = %Q{#{access}-type}
|
219
|
+
lst = doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="#{sectiondef}"]/memberdef[@kind="enum"][@prot="#{access}"]})
|
220
|
+
filter.map!{ |exp| exp =~ /^#{@basename}_Enum/ ? /@\d*/ : exp} unless filter.nil?
|
221
|
+
do_filter(filter, lst, Doxyparser::Enum) { |node|
|
222
|
+
node.xpath("name")[0].child.content
|
223
|
+
}
|
224
|
+
end
|
225
|
+
|
226
|
+
def _parent_types(access)
|
227
|
+
doc.xpath(%Q{/doxygen/compounddef/basecompoundref[@prot="#{access}"]}).map { |t| Doxyparser::Type.new(name: t.child.content, dir: @dir) }
|
228
|
+
end
|
229
|
+
|
230
|
+
def init_attributes
|
231
|
+
super
|
232
|
+
@file = init_file
|
233
|
+
@friends = init_friends
|
234
|
+
@template_params = init_template_params
|
235
|
+
end
|
111
236
|
|
112
|
-
|
237
|
+
def init_file
|
238
|
+
n = doc.xpath("/doxygen/compounddef/includes")[0]
|
239
|
+
return n ? HFile.new(dir: @dir, node: n) : nil
|
240
|
+
end
|
113
241
|
|
114
|
-
def
|
115
|
-
|
116
|
-
|
242
|
+
def init_friends
|
243
|
+
lst=doc.xpath(%Q{/doxygen/compounddef/sectiondef[@kind="friend"]/memberdef[@kind="friend"]})
|
244
|
+
lst.map { |node|
|
245
|
+
Doxyparser::Friend.new(parent: self, node: node)
|
246
|
+
}
|
247
|
+
end
|
248
|
+
|
249
|
+
def init_template_params
|
250
|
+
params=doc.xpath(%Q{/doxygen/compounddef/templateparamlist/param})
|
251
|
+
params.map { |param|
|
252
|
+
Doxyparser::Param.new(parent: self, node: param)
|
253
|
+
}
|
117
254
|
end
|
118
255
|
end
|
119
|
-
end
|
256
|
+
end
|
data/lib/nodes/type.rb
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
+
# Type of the parameters and return value of a {Function}. Parent Type of a {Class} or {Struct}.
|
4
|
+
# Supports type parameters (aka. generics)
|
3
5
|
class Type < Node
|
6
|
+
|
7
|
+
# Name of this {Type} without any reference/pointer symbols '* &' or 'const' modifiers
|
8
|
+
attr_reader :escaped_name
|
4
9
|
|
10
|
+
# If this {Type} has type parameters (aka. template params) finds nested {Type}s
|
11
|
+
# for other {Classes} or {Structs} parsed by Doxyparser.
|
12
|
+
# The 'main' type is always included, so for templates two or more types will be returned.
|
13
|
+
# Example: for MyNamespace::map<std::string, MyClass> the result is: [MyNamespace::map, MyNamespace::MyClass]
|
14
|
+
# @return [Array<Type>] Nested types
|
5
15
|
def nested_local_types
|
6
16
|
return [] if @node.nil?
|
7
17
|
refs = @node.xpath("ref")
|
@@ -9,35 +19,57 @@ module Doxyparser
|
|
9
19
|
refs.map { |r| Type.new(node: r, dir: @dir) }
|
10
20
|
end
|
11
21
|
|
22
|
+
# If this {Type} has type parameters (aka. template params), returns the names for
|
23
|
+
# types nested in this type's name
|
24
|
+
# The 'main' type is always included, so for templates two or more names will be returned.
|
25
|
+
# Example: for MyNamespace::map<std::string, MyClass, 4> the result is: [MyNamespace::map, std::string, MyClass]
|
26
|
+
# @return [Array<String>] Names of nested types
|
12
27
|
def nested_typenames
|
13
|
-
Type.nested_typenames(@
|
28
|
+
Type.nested_typenames(@escaped_name)
|
14
29
|
end
|
15
30
|
|
31
|
+
# Returns the names for types nested in the parameter.
|
32
|
+
# The 'main' type is always included, so for templates two or more names will be returned.
|
33
|
+
# Example: for mymap<std::string, MyClass, 4> the result is: [mymap, std::string, MyClass]
|
34
|
+
# @param typename [String] Type name
|
35
|
+
# @return [Array<String>] Names of nested types
|
16
36
|
def self.nested_typenames(typename)
|
17
|
-
|
18
|
-
|
37
|
+
escaped_typename = Doxyparser::Util.escape_const_ref_ptr(typename)
|
38
|
+
escaped_typename.split(%r{[<,>]}).map{ |s|
|
39
|
+
Doxyparser::Util.escape_const_ref_ptr(s)
|
19
40
|
}.reject { |s|
|
20
41
|
s.nil? || !valid_type?(s)
|
21
|
-
|
42
|
+
}
|
22
43
|
end
|
23
44
|
|
45
|
+
# @return true if this type has type parameters, false otherwise
|
24
46
|
def template?
|
25
|
-
Type.template?(@
|
47
|
+
Type.template?(@escaped_name)
|
26
48
|
end
|
27
49
|
|
50
|
+
# @param typename [String] Type name
|
51
|
+
# @return true if the given type name has type parameters, false otherwise
|
28
52
|
def self.template?(typename)
|
29
53
|
typename.include? '<'
|
30
54
|
end
|
55
|
+
|
56
|
+
# Setter for the name of this {Type}. Use at your own risk!
|
57
|
+
def name=(new_name)
|
58
|
+
@name = new_name
|
59
|
+
@escaped_name = escape_const_ref_ptr(@name)
|
60
|
+
@basename = del_prefix_class(escape_template(@escaped_name))
|
61
|
+
end
|
31
62
|
|
32
63
|
private
|
33
64
|
|
34
65
|
def init_attributes
|
35
|
-
@
|
66
|
+
@escaped_name = escape_const_ref_ptr(@name)
|
67
|
+
@basename = del_prefix_class(escape_template(@escaped_name))
|
36
68
|
end
|
37
69
|
|
38
70
|
def find_name
|
39
71
|
return '' if @node.nil?
|
40
|
-
@node.content
|
72
|
+
@node.content.gsub('friend', '').strip
|
41
73
|
end
|
42
74
|
|
43
75
|
def self.valid_type?(str)
|
data/lib/nodes/typedef.rb
CHANGED
data/lib/nodes/variable.rb
CHANGED
data/lib/util.rb
CHANGED
@@ -9,8 +9,24 @@ module Doxyparser
|
|
9
9
|
def del_spaces(n)
|
10
10
|
n.gsub(/\s+/, "")
|
11
11
|
end
|
12
|
-
|
13
|
-
def
|
12
|
+
|
13
|
+
def escape_all(typename)
|
14
|
+
return del_prefix_class(escape_template(escape_const_ref_ptr(typename)))
|
15
|
+
end
|
16
|
+
|
17
|
+
def escape_template(typename)
|
18
|
+
typename.gsub(/<.+$/,'').strip
|
19
|
+
end
|
20
|
+
|
21
|
+
def escape_const_ref_ptr(typename)
|
22
|
+
typename.gsub(/^ *const /,'').gsub(/ +(const)* *[&*]* *(const)* *$/,'').strip
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.escape_const_ref_ptr(typename)
|
26
|
+
typename.gsub(/^ *const /,'').gsub(/ +(const)* *[&*]* *(const)* *$/,'').strip
|
27
|
+
end
|
28
|
+
|
29
|
+
def del_prefix_class(n) # Previuously escaped for const
|
14
30
|
n.gsub(%r{^[^<]*[:]}, "")
|
15
31
|
end
|
16
32
|
|
@@ -54,8 +70,10 @@ module Doxyparser
|
|
54
70
|
filtered_lst = []
|
55
71
|
filter.each { |val|
|
56
72
|
found = lst.select { |node| match(val, yield(node)) }
|
57
|
-
|
58
|
-
|
73
|
+
unless found.nil? || found.empty?
|
74
|
+
filtered_lst.push(*found)
|
75
|
+
end
|
76
|
+
#puts "The object: #{val} #{clazz} could not be found while parsing" # TODO Log this?
|
59
77
|
}
|
60
78
|
else
|
61
79
|
filtered_lst=lst
|
data/spec/class_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
|
-
|
3
|
+
require_relative '../lib/doxyparser'
|
4
4
|
|
5
5
|
require_relative 'custom_spec_helper'
|
6
6
|
|
@@ -77,8 +77,8 @@ describe "Doxyparser::Class" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should correctly create inner classes and structs" do
|
80
|
-
innerstruct = @class.
|
81
|
-
innerclass = @class.
|
80
|
+
innerstruct = @class.only_innerstructs
|
81
|
+
innerclass = @class.only_innerclasses
|
82
82
|
innerstruct.size.should eql 1
|
83
83
|
innerclass.size.should eql 1
|
84
84
|
innerstruct= innerstruct[0]
|
@@ -97,6 +97,28 @@ describe "Doxyparser::Class" do
|
|
97
97
|
compare_members methods, expected_methods
|
98
98
|
end
|
99
99
|
|
100
|
+
it "should correctly create destructors" do
|
101
|
+
@class.destructors(:protected).should be_empty
|
102
|
+
expected_methods=['~MyClass']
|
103
|
+
methods = @class.destructors(:all)
|
104
|
+
methods.size.should eql 1
|
105
|
+
compare_members methods, expected_methods
|
106
|
+
methods = @class.destructors(:public)
|
107
|
+
methods.size.should eql 1
|
108
|
+
compare_members methods, expected_methods
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should correctly create constructors" do
|
112
|
+
@class.constructors(:protected).should be_empty
|
113
|
+
expected_methods=['MyClass']
|
114
|
+
methods = @class.constructors(:all)
|
115
|
+
methods.size.should eql 2
|
116
|
+
compare_members methods, expected_methods
|
117
|
+
methods = @class.constructors(:public)
|
118
|
+
methods.size.should eql 2
|
119
|
+
compare_members methods, expected_methods
|
120
|
+
end
|
121
|
+
|
100
122
|
it "should correctly create static methods " do
|
101
123
|
expected_methods=['publicStaticMethod', 'getStaticProp', 'setStaticProp']
|
102
124
|
methods = @class.methods(:public, :static)
|
@@ -134,8 +156,8 @@ describe "Doxyparser::Class" do
|
|
134
156
|
end
|
135
157
|
|
136
158
|
it "should correctly create public enums " do
|
137
|
-
expected_enums=[
|
138
|
-
enums = @class.
|
159
|
+
expected_enums=["MyClass_Enum", 'InnerEnum']
|
160
|
+
enums = @class.enums
|
139
161
|
compare_members enums, expected_enums, Doxyparser::Enum
|
140
162
|
end
|
141
163
|
|
data/spec/doxyparser_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
|
-
|
3
|
+
require_relative '../lib/doxyparser'
|
4
4
|
|
5
5
|
require_relative 'custom_spec_helper'
|
6
6
|
|
@@ -13,7 +13,6 @@ describe "Doxyparser" do
|
|
13
13
|
hfile=Doxyparser::parse_file("test.h", xml_dir)
|
14
14
|
output = Doxyparser::gen_xml_docs(home_dir + '/spec/headers', home_dir + '/spec/test_gen', true, ['usr/local/include', 'usr/gato'])
|
15
15
|
output.should_not be_empty
|
16
|
-
FileUtils.rm_r(home_dir + '/spec/test_gen')
|
17
16
|
clazz.name.should_not be_empty
|
18
17
|
namespace.name.should_not be_empty
|
19
18
|
struct.name.should_not be_empty
|
data/spec/enum_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
|
-
|
3
|
+
require_relative '../lib/doxyparser'
|
4
4
|
|
5
5
|
require_relative 'custom_spec_helper'
|
6
6
|
|
7
7
|
describe "Doxyparser::Enum" do
|
8
8
|
|
9
9
|
it "should create consistently enums" do
|
10
|
-
|
11
10
|
clazz = Doxyparser::parse_class('MyNamespace::MyClass', xml_dir)
|
12
|
-
enum = clazz.
|
11
|
+
enum = clazz.enums(:public, ["MyClass_Enum"])
|
13
12
|
enum.size.should eql 1
|
14
|
-
enum[0].values.should eql ['value1', 'value2','value3']
|
15
|
-
enum = clazz.
|
16
|
-
enum[0].values.should eql ['A', 'B','C']
|
13
|
+
enum[0].values.map{ |v| v.basename}.should eql ['value1', 'value2','value3']
|
14
|
+
enum = clazz.enums(:public, ['InnerEnum'])
|
15
|
+
enum[0].values.map{ |v| v.basename}.should eql ['A', 'B','C']
|
16
|
+
enum[0].values.map{ |v| v.initializer}.should eql ['23', 'A + 1','A + B']
|
17
17
|
end
|
18
18
|
end
|
data/spec/file_spec.rb
CHANGED
data/spec/method_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
|
-
|
3
|
+
require_relative '../lib/doxyparser'
|
4
4
|
|
5
5
|
require_relative 'custom_spec_helper'
|
6
6
|
|
@@ -45,6 +45,10 @@ describe "Doxyparser::Method" do
|
|
45
45
|
setter.setter_for.should eql 'prop2set_2'
|
46
46
|
setter.getter_for.should be_nil
|
47
47
|
setter.static.should be_nil
|
48
|
+
|
49
|
+
getter = @class.methods(:private, nil, ['getIndeedAProp'])[0]
|
50
|
+
getter.getter_for.should eql 'indeedAProp'
|
51
|
+
getter.setter_for.should be_nil
|
48
52
|
end
|
49
53
|
|
50
54
|
it "should create standard Uppercase getters and setters" do
|
@@ -64,6 +68,18 @@ describe "Doxyparser::Method" do
|
|
64
68
|
setter = @class.methods(:private, nil, ['setNotAProp'])[0]
|
65
69
|
setter.setter_for.should be_nil
|
66
70
|
setter.getter_for.should be_nil
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should ignore malformed getters and setters Pt. 3" do
|
75
|
+
|
76
|
+
getter = @class.methods(:private, nil, ['getAgainNotAProp'])[0]
|
77
|
+
getter.getter_for.should be_nil
|
78
|
+
getter.setter_for.should be_nil
|
79
|
+
setter = @class.methods(:private, nil, ['setAgainNotAProp'])[0]
|
80
|
+
setter.setter_for.should be_nil
|
81
|
+
setter.getter_for.should be_nil
|
82
|
+
|
67
83
|
end
|
68
84
|
|
69
85
|
it "should ignore malformed getters and setters Pt. 2" do
|
data/spec/namespace_spec.rb
CHANGED
data/spec/type_spec.rb
CHANGED
metadata
CHANGED
@@ -1,31 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doxyparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
5
|
-
prerelease:
|
4
|
+
version: '1.5'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Fuenmayor
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
16
|
-
This library is based on Nokogiri (http://nokogiri.org) and takes as input the xml
|
17
|
-
files
|
18
|
-
|
19
|
-
Parsing with Doxygen allows us to parse even a set of non-compilable include files.
|
20
|
-
This is very useful in case you need to parse only a subset of a big library which
|
21
|
-
won''t normally compile because of being incomplete or needing further build configuration
|
22
|
-
(e.g Makefiles, VS, SCons, etc).
|
23
|
-
|
24
|
-
By using other tools which rely on a real C/C++ processor like gccxml or swig, you
|
25
|
-
would normally get lots of compilation-related errors (which is undesired because
|
26
|
-
we don''t want to compile anything!!). Doxyparser is, in such cases, the lean alternative.
|
27
|
-
|
28
|
-
'
|
13
|
+
description: |
|
14
|
+
Ruby Gem for parsing C++ header files.
|
15
|
+
This library is based on Nokogiri (http://nokogiri.org) and takes as input the xml files generated by Doxygen (www.doxygen.org).
|
16
|
+
Parsing with Doxygen allows us to parse even a set of non-compilable include files. This is very useful in case you need to extract metadata for a big library which won't normally compile because of being incomplete or needing further build configuration (think of Makefiles, Visual Studio and similar).
|
17
|
+
By using other tools which rely on a real C/C++ processor like gccxml or swig, you would normally get lots of compilation-related errors (which is undesired because we don't want to compile anything!). Doxyparser is, in such cases, the lean alternative.
|
29
18
|
email:
|
30
19
|
- davfuenmayor@gmail.com
|
31
20
|
executables: []
|
@@ -39,8 +28,8 @@ files:
|
|
39
28
|
- lib/nodes/function.rb
|
40
29
|
- lib/nodes/variable.rb
|
41
30
|
- lib/nodes/type.rb
|
31
|
+
- lib/nodes/enum_value.rb
|
42
32
|
- lib/nodes/class.rb
|
43
|
-
- lib/nodes/group.rb
|
44
33
|
- lib/nodes/friend.rb
|
45
34
|
- lib/nodes/struct.rb
|
46
35
|
- lib/nodes/compound.rb
|
@@ -62,27 +51,26 @@ files:
|
|
62
51
|
homepage: https://github.com/davfuenmayor/ruby-doxygen-parser
|
63
52
|
licenses:
|
64
53
|
- MIT
|
54
|
+
metadata: {}
|
65
55
|
post_install_message:
|
66
56
|
rdoc_options: []
|
67
57
|
require_paths:
|
68
58
|
- lib
|
69
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
60
|
requirements:
|
72
|
-
- -
|
61
|
+
- - ">="
|
73
62
|
- !ruby/object:Gem::Version
|
74
63
|
version: '0'
|
75
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
65
|
requirements:
|
78
|
-
- -
|
66
|
+
- - ">="
|
79
67
|
- !ruby/object:Gem::Version
|
80
68
|
version: '0'
|
81
69
|
requirements: []
|
82
70
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 2.1.9
|
84
72
|
signing_key:
|
85
|
-
specification_version:
|
73
|
+
specification_version: 4
|
86
74
|
summary: Library for parsing C++ header files
|
87
75
|
test_files:
|
88
76
|
- spec/namespace_spec.rb
|
@@ -93,3 +81,4 @@ test_files:
|
|
93
81
|
- spec/doxyparser_spec.rb
|
94
82
|
- spec/class_spec.rb
|
95
83
|
- spec/type_spec.rb
|
84
|
+
has_rdoc:
|