doxyparser 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT_LICENSE +19 -0
- data/README.md +271 -0
- data/lib/doxyparser.rb +75 -0
- data/lib/nodes/class.rb +13 -0
- data/lib/nodes/compound.rb +42 -0
- data/lib/nodes/enum.rb +20 -0
- data/lib/nodes/friend.rb +20 -0
- data/lib/nodes/function.rb +54 -0
- data/lib/nodes/group.rb +6 -0
- data/lib/nodes/hfile.rb +73 -0
- data/lib/nodes/member.rb +61 -0
- data/lib/nodes/namespace.rb +66 -0
- data/lib/nodes/node.rb +63 -0
- data/lib/nodes/param.rb +34 -0
- data/lib/nodes/struct.rb +89 -0
- data/lib/nodes/type.rb +29 -0
- data/lib/nodes/typedef.rb +6 -0
- data/lib/nodes/variable.rb +6 -0
- data/lib/util.rb +69 -0
- data/spec/class_spec.rb +166 -0
- data/spec/custom_spec_helper.rb +21 -0
- data/spec/doxyparser_spec.rb +23 -0
- data/spec/enum_spec.rb +18 -0
- data/spec/file_spec.rb +108 -0
- data/spec/method_spec.rb +86 -0
- data/spec/namespace_spec.rb +165 -0
- data/spec/type_spec.rb +34 -0
- metadata +83 -0
data/spec/method_spec.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'doxyparser'
|
4
|
+
|
5
|
+
require_relative 'custom_spec_helper'
|
6
|
+
|
7
|
+
describe "Doxyparser::Method" do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
@class=Doxyparser::parse_class("AccessorsClass", xml_dir)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create consistently methods" do
|
14
|
+
method = @class.methods(:private, nil, ['isBoolProp'])
|
15
|
+
method.size.should eql 1
|
16
|
+
method = method[0]
|
17
|
+
method.type.name.should eql 'bool'
|
18
|
+
method.args.should eql '()'
|
19
|
+
method.location.should match /test2.h:\d+$/
|
20
|
+
method.file.basename.should eql 'test2.h'
|
21
|
+
method.params.should be_empty
|
22
|
+
method.static.should be_nil
|
23
|
+
method.definition.should eql 'bool AccessorsClass::isBoolProp'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should create standard getters and setters" do
|
27
|
+
getter = @class.methods(:private, nil, ['getProp'])[0]
|
28
|
+
getter.getter_for.should eql 'prop'
|
29
|
+
getter.setter_for.should be_nil
|
30
|
+
setter = @class.methods(:private, nil, ['setProp'])[0]
|
31
|
+
setter.setter_for.should eql 'prop'
|
32
|
+
setter.getter_for.should be_nil
|
33
|
+
setter.static.should be_nil
|
34
|
+
|
35
|
+
getter = @class.methods(:private, nil, ['isBoolProp'])[0]
|
36
|
+
getter.getter_for.should eql 'boolProp'
|
37
|
+
getter.setter_for.should be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should create non standard getters and setters" do
|
41
|
+
getter = @class.methods(:private, nil, ['get_Prop2'])[0]
|
42
|
+
getter.getter_for.should eql 'prop2'
|
43
|
+
getter.setter_for.should be_nil
|
44
|
+
setter = @class.methods(:private, nil, ['set_Prop2'])[0]
|
45
|
+
setter.setter_for.should eql 'prop2'
|
46
|
+
setter.getter_for.should be_nil
|
47
|
+
setter.static.should be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should create standard Uppercase getters and setters" do
|
51
|
+
getter = @class.methods(:private, nil, ['GetProp3'])[0]
|
52
|
+
getter.getter_for.should eql 'prop3'
|
53
|
+
getter.setter_for.should be_nil
|
54
|
+
setter = @class.methods(:private, nil, ['SetProp3'])[0]
|
55
|
+
setter.setter_for.should eql 'prop3'
|
56
|
+
setter.getter_for.should be_nil
|
57
|
+
setter.static.should be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should ignore malformed getters and setters" do
|
61
|
+
getter = @class.methods(:private, nil, ['getNotAProp'])[0]
|
62
|
+
getter.getter_for.should be_nil
|
63
|
+
getter.setter_for.should be_nil
|
64
|
+
setter = @class.methods(:private, nil, ['setNotAProp'])[0]
|
65
|
+
setter.setter_for.should be_nil
|
66
|
+
setter.getter_for.should be_nil
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should ignore malformed getters and setters Pt. 2" do
|
70
|
+
getter = @class.methods(:private, nil, ['isNotAProp'])[0]
|
71
|
+
getter.getter_for.should be_nil
|
72
|
+
getter.setter_for.should be_nil
|
73
|
+
setter = @class.methods(:private, nil, ['isAlsoNotAProp'])[0]
|
74
|
+
setter.setter_for.should be_nil
|
75
|
+
setter.getter_for.should be_nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should create static getters and setters" do
|
79
|
+
static_getter = @class.methods(:private, true, ['getStaticProp'])[0]
|
80
|
+
static_getter.getter_for.should eql 'staticProp'
|
81
|
+
static_getter.setter_for.should be_nil
|
82
|
+
static_setter = @class.methods(:private, :x, ['setStaticProp'])[0]
|
83
|
+
static_setter.setter_for.should eql 'staticProp'
|
84
|
+
static_setter.getter_for.should be_nil
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'doxyparser'
|
4
|
+
|
5
|
+
require_relative 'custom_spec_helper'
|
6
|
+
|
7
|
+
describe "Doxyparser::Namespace" do
|
8
|
+
|
9
|
+
context "Basic" do
|
10
|
+
|
11
|
+
before(:all) do
|
12
|
+
@namespace=Doxyparser::parse_namespace("Ogre", xml_dir)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be created consistently from name and directory" do
|
16
|
+
namespace_data = {name: "Ogre", basename: "Ogre", node: nil, parent: nil, path: xml_dir+'/namespaceOgre.xml'}
|
17
|
+
@namespace.class.should eql Doxyparser::Namespace
|
18
|
+
@namespace.name.should eql namespace_data[:name]
|
19
|
+
@namespace.basename.should eql namespace_data[:basename]
|
20
|
+
@namespace.xml_path.should eql namespace_data[:path]
|
21
|
+
@namespace.file.should be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should create the right typedefs according to a specified list" do
|
25
|
+
expected_typedefs=['AnimableValuePtr', 'AnimationStateMap', 'ConstAnimationStateIterator']
|
26
|
+
ns_typedefs = @namespace.typedefs(expected_typedefs)
|
27
|
+
ns_typedefs.size.should eql expected_typedefs.size
|
28
|
+
ns_typedefs.uniq.should eql ns_typedefs
|
29
|
+
ns_typedefs.each{|t|
|
30
|
+
t.class.should eql Doxyparser::Typedef # Class must be correct
|
31
|
+
t.parent.should eql @namespace # Parent must be correct
|
32
|
+
expected_typedefs.should include t.basename
|
33
|
+
t.name.should be_start_with("#{@namespace.name}::")
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create the right functions according to a specified list" do
|
38
|
+
expected_functions=['operator>', 'operator<=', 'intersect', 'advanceRawPointer', 'any_cast']
|
39
|
+
ns_functions = @namespace.functions(expected_functions)
|
40
|
+
# Should return more elements than the list (because any_cast() is overloaded)
|
41
|
+
ns_functions.size.should be.>expected_functions.size
|
42
|
+
ns_functions.uniq.should eql ns_functions# Function overrides "==" and therefore
|
43
|
+
# no element should be repeated
|
44
|
+
ns_functions.each{|f|
|
45
|
+
f.class.should eql Doxyparser::Function# Class must be correct
|
46
|
+
f.parent.should eql @namespace# Parent must be correct
|
47
|
+
expected_functions.should include f.basename# Each function must be included in
|
48
|
+
# the given list
|
49
|
+
f.name.should be_start_with("#{@namespace.name}::")
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should create the right enums according to a specified list" do
|
54
|
+
expected_enums=['LayerBlendOperationEx', 'ShadowTechnique', 'GpuConstantType', 'MeshChunkID']
|
55
|
+
ns_enums = @namespace.enums(expected_enums)
|
56
|
+
ns_enums.size.should eql expected_enums.size# Should return same number of
|
57
|
+
# elements as the list
|
58
|
+
ns_enums.uniq.should eql ns_enums# No element should be repeated
|
59
|
+
ns_enums.each{|e|
|
60
|
+
e.class.should eql Doxyparser::Enum# Class must be correct
|
61
|
+
e.parent.should eql @namespace# Parent must be correct
|
62
|
+
expected_enums.should include e.basename# Each function must be included in the
|
63
|
+
# given list
|
64
|
+
e.name.should be_start_with("#{@namespace.name}::")
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should create the right variables according to a specified list" do
|
69
|
+
expected_vars=['pi', 'SPOT_SHADOW_FADE_PNG', 'RENDER_QUEUE_COUNT']
|
70
|
+
ns_vars = @namespace.variables(expected_vars)
|
71
|
+
ns_vars.size.should eql expected_vars.size# Should return same number of elements
|
72
|
+
# as the list
|
73
|
+
ns_vars.uniq.should eql ns_vars# No element should be repeated
|
74
|
+
ns_vars.each{ |v|
|
75
|
+
v.class.should eql Doxyparser::Variable# Class must be correct
|
76
|
+
v.parent.should eql @namespace# Parent must be correct
|
77
|
+
expected_vars.should include v.basename# Each function must be included in the
|
78
|
+
# given list
|
79
|
+
v.name.should be_start_with("#{@namespace.name}::")
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should correctly create the right classes and structs according to a specified list" do
|
84
|
+
|
85
|
+
expected_classes=['AnimationTrack', "Root", "RibbonTrail", "SceneManager"]
|
86
|
+
expected_structs=["isPodLike", "ViewPoint", "RenderablePass"]
|
87
|
+
|
88
|
+
ns_classes = @namespace.classes(expected_classes)
|
89
|
+
ns_structs = @namespace.structs(expected_structs)
|
90
|
+
ns_classes.size.should eql expected_classes.size
|
91
|
+
ns_structs.size.should eql expected_structs.size#
|
92
|
+
|
93
|
+
ns_all = ns_classes + ns_structs
|
94
|
+
ns_all.uniq.should eql ns_all# No element should be repeated among classes and
|
95
|
+
# structs
|
96
|
+
|
97
|
+
ns_classes.each{|c|
|
98
|
+
c.class.should eql Doxyparser::Class
|
99
|
+
expected_classes.should include c.basename
|
100
|
+
}
|
101
|
+
ns_structs.each{|c|
|
102
|
+
c.class.should eql Doxyparser::Struct
|
103
|
+
expected_structs.should include c.basename
|
104
|
+
}
|
105
|
+
ns_all.each{|c|
|
106
|
+
c.parent.should eql @namespace
|
107
|
+
c.xml_path.should eql xml_dir+"/#{c.refid}.xml"
|
108
|
+
c.name.should be_start_with("#{@namespace.name}::")
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should correctly create the right inner namespaces according to a specified list" do
|
113
|
+
expected_inner_ns=['EmitterCommands', 'OverlayElementCommands']
|
114
|
+
inner_ns = @namespace.innernamespaces(expected_inner_ns)
|
115
|
+
inner_ns.size.should eql expected_inner_ns.size# Should return same name of
|
116
|
+
# elements as expected...
|
117
|
+
inner_ns.uniq.should eql inner_ns# ... and no element should be repeated
|
118
|
+
|
119
|
+
inner_ns.each{|ns|
|
120
|
+
# Class must be correct
|
121
|
+
ns.class.should eql Doxyparser::Namespace
|
122
|
+
|
123
|
+
# Class should have a correct parent
|
124
|
+
ns.parent.should eql @namespace
|
125
|
+
|
126
|
+
# XML File path must be correct
|
127
|
+
ns.xml_path.should eql xml_dir+%Q{/#{ns.refid}.xml}
|
128
|
+
|
129
|
+
# The classes must be included in the given filter
|
130
|
+
expected_inner_ns.should include ns.basename
|
131
|
+
ns.name.should be_start_with("#{@namespace.name}::")
|
132
|
+
}
|
133
|
+
end
|
134
|
+
end
|
135
|
+
context "Advanced" do
|
136
|
+
|
137
|
+
before(:all) do
|
138
|
+
@myNamespace=Doxyparser::parse_namespace("MyNamespace", xml_dir)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should correctly create nested inner-namespace hierarchies" do
|
142
|
+
@myNamespace=Doxyparser::parse_namespace("MyNamespace", xml_dir)
|
143
|
+
inner_ns = @myNamespace.innernamespaces
|
144
|
+
inner_ns.size.should eql 1
|
145
|
+
myInnerNamespace = inner_ns[0]
|
146
|
+
myInnerNamespace.parent.should eql @myNamespace
|
147
|
+
myInnerNamespace.xml_path.should eql xml_dir+%Q{/#{myInnerNamespace.refid}.xml}
|
148
|
+
myInnerNamespace.name.should eql "#{@myNamespace.name}::MyInnerNamespace"
|
149
|
+
|
150
|
+
inner_ns = myInnerNamespace.innernamespaces
|
151
|
+
inner_ns.size.should eql 1
|
152
|
+
myMostInnerNamespace = inner_ns[0]
|
153
|
+
myMostInnerNamespace.parent.should eql myInnerNamespace
|
154
|
+
myMostInnerNamespace.xml_path.should eql xml_dir+%Q{/#{myMostInnerNamespace.refid}.xml}
|
155
|
+
myMostInnerNamespace.name.should eql "#{myInnerNamespace.name}::MyMostInnerNamespace"
|
156
|
+
|
157
|
+
myClass = myMostInnerNamespace.classes[0]
|
158
|
+
myEnum = myMostInnerNamespace.enums[0]
|
159
|
+
|
160
|
+
myClass.name.should eql "#{myMostInnerNamespace.name}::MyClass"
|
161
|
+
myEnum.name.should eql "#{myMostInnerNamespace.name}::MyEnum"
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
data/spec/type_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'doxyparser'
|
4
|
+
|
5
|
+
require_relative 'custom_spec_helper'
|
6
|
+
|
7
|
+
describe "Doxyparser::Type" do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
@class=Doxyparser::parse_class('MyNamespace::MyClass', xml_dir)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create consistently simple types" do
|
14
|
+
typedef = @class.typedefs(:public, ['MapShortVectorInt'])[0]
|
15
|
+
type = typedef.type
|
16
|
+
type.name.should eql 'std::map< unsigned short, std::vector< int * > >'
|
17
|
+
type.should be_template
|
18
|
+
|
19
|
+
typedef = @class.typedefs(:public, ['VectorMapShortVectorInt'])[0]
|
20
|
+
type = typedef.type
|
21
|
+
type.name.should eql 'std::vector< MapShortVectorInt >'
|
22
|
+
type.should be_template
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should create consistently complex types" do
|
26
|
+
typedef = @class.typedefs(:private, ['privateTypedef'])[0]
|
27
|
+
type = typedef.type
|
28
|
+
type.name.should eql 'std::map< MyMostInnerClass, TemplateClass< OuterStruct,::noNsClass, 8 > >'
|
29
|
+
type.should be_template
|
30
|
+
type.nested_local_types.map{|t| t.name}.should eql ['MyMostInnerClass', 'TemplateClass', 'OuterStruct', 'noNsClass']
|
31
|
+
type.nested_typenames.should eql ['std::map', 'MyMostInnerClass' , 'TemplateClass', 'OuterStruct', '::noNsClass']
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doxyparser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Fuenmayor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
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 parse only a subset of a big library which won't normally compile because of being incomplete or needing further build configuration (e.g Makefiles, VS, SCons, etc).
|
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.
|
18
|
+
email:
|
19
|
+
- davfuenmayor@gmail.com
|
20
|
+
executables: []
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- README.md
|
25
|
+
- MIT_LICENSE
|
26
|
+
- lib/util.rb
|
27
|
+
- lib/nodes/hfile.rb
|
28
|
+
- lib/nodes/function.rb
|
29
|
+
- lib/nodes/variable.rb
|
30
|
+
- lib/nodes/type.rb
|
31
|
+
- lib/nodes/class.rb
|
32
|
+
- lib/nodes/group.rb
|
33
|
+
- lib/nodes/friend.rb
|
34
|
+
- lib/nodes/struct.rb
|
35
|
+
- lib/nodes/compound.rb
|
36
|
+
- lib/nodes/enum.rb
|
37
|
+
- lib/nodes/node.rb
|
38
|
+
- lib/nodes/member.rb
|
39
|
+
- lib/nodes/param.rb
|
40
|
+
- lib/nodes/namespace.rb
|
41
|
+
- lib/nodes/typedef.rb
|
42
|
+
- lib/doxyparser.rb
|
43
|
+
- spec/namespace_spec.rb
|
44
|
+
- spec/enum_spec.rb
|
45
|
+
- spec/custom_spec_helper.rb
|
46
|
+
- spec/file_spec.rb
|
47
|
+
- spec/method_spec.rb
|
48
|
+
- spec/doxyparser_spec.rb
|
49
|
+
- spec/class_spec.rb
|
50
|
+
- spec/type_spec.rb
|
51
|
+
homepage: https://github.com/davfuenmayor/ruby-doxygen-parser
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 2.0.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Library for parsing C++ header files
|
75
|
+
test_files:
|
76
|
+
- spec/namespace_spec.rb
|
77
|
+
- spec/enum_spec.rb
|
78
|
+
- spec/custom_spec_helper.rb
|
79
|
+
- spec/file_spec.rb
|
80
|
+
- spec/method_spec.rb
|
81
|
+
- spec/doxyparser_spec.rb
|
82
|
+
- spec/class_spec.rb
|
83
|
+
- spec/type_spec.rb
|