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/nodes/type.rb
CHANGED
@@ -1,29 +1,48 @@
|
|
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
|
-
|
3
|
+
class Type < Node
|
4
|
+
|
5
|
+
def nested_local_types
|
6
|
+
return [] if @node.nil?
|
7
|
+
refs = @node.xpath("ref")
|
8
|
+
return [] if refs.nil? || refs.empty?
|
9
|
+
refs.map { |r| Type.new(node: r, dir: @dir) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def nested_typenames
|
13
|
+
Type.nested_typenames(@name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.nested_typenames(typename)
|
17
|
+
typename.split(%r{[<,>]}).map{ |s|
|
18
|
+
s.gsub(/^ *const /,'').gsub(/ +(const)* *[&*] *(const)* *$/,'').strip
|
19
|
+
}.reject { |s|
|
20
|
+
s.nil? || !valid_type?(s)
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def template?
|
25
|
+
Type.template?(@name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.template?(typename)
|
29
|
+
typename.include? '<'
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def init_attributes
|
35
|
+
@basename = @name
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_name
|
39
|
+
return '' if @node.nil?
|
40
|
+
@node.content
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.valid_type?(str)
|
44
|
+
str =~ /^\D[\w_ :*&]*$/
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
29
48
|
end
|
data/lib/util.rb
CHANGED
@@ -1,69 +1,74 @@
|
|
1
1
|
module Doxyparser
|
2
2
|
|
3
|
-
|
3
|
+
module Util
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def self.home_dir
|
6
|
+
File.expand_path('..', File.dirname(__FILE__))
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def del_spaces(n)
|
10
|
+
n.gsub(/\s+/, "")
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def del_prefix_class(n)
|
14
|
+
n.gsub(%r{^[^<]*[:]}, "")
|
15
|
+
end
|
16
|
+
|
17
|
+
def del_prefix_file(n)
|
18
|
+
n.gsub(%r{/$}, "")
|
19
|
+
n.gsub(%r{.*[/]}, "")
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def escape_file_name(filename)
|
23
|
+
if filename =~ %r{[\./]}
|
24
|
+
return filename.gsub('.', '_8').gsub('/', '_2')
|
25
|
+
else
|
26
|
+
return filename.gsub('_8', '.').gsub('_2', '/')
|
27
|
+
end
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def escape_class_name(filename)
|
31
|
+
if filename.include? '::'
|
32
|
+
return filename.gsub('::','_1_1')
|
33
|
+
else
|
34
|
+
return filename.gsub('_1_1','::')
|
35
|
+
end
|
36
|
+
end
|
32
37
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
def self.read_file(file_name)
|
39
|
+
file = File.open(file_name, "r")
|
40
|
+
data = file.read
|
41
|
+
file.close
|
42
|
+
return data
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
def self.write_file(file_name, data)
|
46
|
+
file = File.open(file_name, "w")
|
47
|
+
count = file.write(data)
|
48
|
+
file.close
|
49
|
+
return count
|
50
|
+
end
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
def do_filter(filter, lst, clazz)
|
53
|
+
if filter
|
54
|
+
filtered_lst = []
|
55
|
+
filter.each { |val|
|
56
|
+
found = lst.select { |node| match(val, yield(node)) }
|
57
|
+
raise "The object: #{val} #{clazz} could not be found while parsing" if found.nil? || found.empty?
|
58
|
+
filtered_lst.push(*found)
|
59
|
+
}
|
60
|
+
else
|
61
|
+
filtered_lst=lst
|
62
|
+
end
|
63
|
+
filtered_lst.map { |node| clazz.new(parent: self, node: node) }
|
64
|
+
end
|
60
65
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
def match(val, aux_name)
|
67
|
+
if val.is_a?(Regexp)
|
68
|
+
return aux_name =~ val
|
69
|
+
else
|
70
|
+
return aux_name == val
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
69
74
|
end
|
data/spec/file_spec.rb
CHANGED
@@ -64,7 +64,7 @@ describe "Doxyparser::HFile" do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should create the right namespaces" do
|
67
|
-
expected_namespaces=['MyNamespace', "MyNamespace::MyInnerNamespace", "MyNamespace::MyInnerNamespace::MyMostInnerNamespace"
|
67
|
+
expected_namespaces=['MyNamespace', "MyNamespace::MyInnerNamespace", "MyNamespace::MyInnerNamespace::MyMostInnerNamespace"]
|
68
68
|
file_namespaces = @file.namespaces
|
69
69
|
file_namespaces.size.should eql expected_namespaces.size
|
70
70
|
|
data/spec/method_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe "Doxyparser::Method" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should create consistently methods" do
|
14
|
-
method = @class.methods(:private, nil, ['
|
14
|
+
method = @class.methods(:private, nil, ['isBoolPropis'])
|
15
15
|
method.size.should eql 1
|
16
16
|
method = method[0]
|
17
17
|
method.type.name.should eql 'bool'
|
@@ -20,39 +20,39 @@ describe "Doxyparser::Method" do
|
|
20
20
|
method.file.basename.should eql 'test2.h'
|
21
21
|
method.params.should be_empty
|
22
22
|
method.static.should be_nil
|
23
|
-
method.definition.should eql 'bool AccessorsClass::
|
23
|
+
method.definition.should eql 'bool AccessorsClass::isBoolPropis'
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should create standard getters and setters" do
|
27
|
-
getter = @class.methods(:private, nil, ['
|
28
|
-
getter.getter_for.should eql '
|
27
|
+
getter = @class.methods(:private, nil, ['getPropget'])[0]
|
28
|
+
getter.getter_for.should eql 'propget'
|
29
29
|
getter.setter_for.should be_nil
|
30
|
-
setter = @class.methods(:private, nil, ['
|
31
|
-
setter.setter_for.should eql '
|
30
|
+
setter = @class.methods(:private, nil, ['setPropset'])[0]
|
31
|
+
setter.setter_for.should eql 'propset'
|
32
32
|
setter.getter_for.should be_nil
|
33
33
|
setter.static.should be_nil
|
34
34
|
|
35
|
-
getter = @class.methods(:private, nil, ['
|
36
|
-
getter.getter_for.should eql '
|
35
|
+
getter = @class.methods(:private, nil, ['isBoolPropis'])[0]
|
36
|
+
getter.getter_for.should eql 'boolPropis'
|
37
37
|
getter.setter_for.should be_nil
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should create non standard getters and setters" do
|
41
|
-
getter = @class.methods(:private, nil, ['
|
42
|
-
getter.getter_for.should eql '
|
41
|
+
getter = @class.methods(:private, nil, ['get_Prop2get_'])[0]
|
42
|
+
getter.getter_for.should eql 'prop2get_'
|
43
43
|
getter.setter_for.should be_nil
|
44
|
-
setter = @class.methods(:private, nil, ['
|
45
|
-
setter.setter_for.should eql '
|
44
|
+
setter = @class.methods(:private, nil, ['set_Prop2set_2'])[0]
|
45
|
+
setter.setter_for.should eql 'prop2set_2'
|
46
46
|
setter.getter_for.should be_nil
|
47
47
|
setter.static.should be_nil
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should create standard Uppercase getters and setters" do
|
51
|
-
getter = @class.methods(:private, nil, ['
|
52
|
-
getter.getter_for.should eql '
|
51
|
+
getter = @class.methods(:private, nil, ['Get3DProp3'])[0]
|
52
|
+
getter.getter_for.should eql '_3DProp3'
|
53
53
|
getter.setter_for.should be_nil
|
54
|
-
setter = @class.methods(:private, nil, ['
|
55
|
-
setter.setter_for.should eql '
|
54
|
+
setter = @class.methods(:private, nil, ['Set3DProp3'])[0]
|
55
|
+
setter.setter_for.should eql '_3DProp3'
|
56
56
|
setter.getter_for.should be_nil
|
57
57
|
setter.static.should be_nil
|
58
58
|
end
|
data/spec/type_spec.rb
CHANGED
@@ -18,14 +18,14 @@ describe "Doxyparser::Type" do
|
|
18
18
|
|
19
19
|
typedef = @class.typedefs(:public, ['VectorMapShortVectorInt'])[0]
|
20
20
|
type = typedef.type
|
21
|
-
type.name.should eql 'std::vector< MapShortVectorInt >'
|
21
|
+
type.name.should eql 'std::vector< MapShortVectorInt & >'
|
22
22
|
type.should be_template
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should create consistently complex types" do
|
26
26
|
typedef = @class.typedefs(:private, ['privateTypedef'])[0]
|
27
27
|
type = typedef.type
|
28
|
-
type.name.should eql 'std::map< MyMostInnerClass
|
28
|
+
type.name.should eql 'std::map< MyMostInnerClass *, TemplateClass< const OuterStruct &,::noNsClass, 8 > >'
|
29
29
|
type.should be_template
|
30
30
|
type.nested_local_types.map{|t| t.name}.should eql ['MyMostInnerClass', 'TemplateClass', 'OuterStruct', 'noNsClass']
|
31
31
|
type.nested_typenames.should eql ['std::map', 'MyMostInnerClass' , 'TemplateClass', 'OuterStruct', '::noNsClass']
|
metadata
CHANGED
@@ -1,20 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doxyparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.3'
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- David Fuenmayor
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-05
|
12
|
+
date: 2013-07-05 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
This library is based on Nokogiri (http://nokogiri.org) and takes as input the xml
|
16
|
-
|
17
|
-
|
14
|
+
description: ! 'Ruby Gem for parsing C++ header files.
|
15
|
+
|
16
|
+
This library is based on Nokogiri (http://nokogiri.org) and takes as input the xml
|
17
|
+
files generated by Doxygen (www.doxygen.org).
|
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
|
+
'
|
18
29
|
email:
|
19
30
|
- davfuenmayor@gmail.com
|
20
31
|
executables: []
|
@@ -51,26 +62,27 @@ files:
|
|
51
62
|
homepage: https://github.com/davfuenmayor/ruby-doxygen-parser
|
52
63
|
licenses:
|
53
64
|
- MIT
|
54
|
-
metadata: {}
|
55
65
|
post_install_message:
|
56
66
|
rdoc_options: []
|
57
67
|
require_paths:
|
58
68
|
- lib
|
59
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
60
71
|
requirements:
|
61
|
-
- - '>='
|
72
|
+
- - ! '>='
|
62
73
|
- !ruby/object:Gem::Version
|
63
74
|
version: '0'
|
64
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
65
77
|
requirements:
|
66
|
-
- - '>='
|
78
|
+
- - ! '>='
|
67
79
|
- !ruby/object:Gem::Version
|
68
80
|
version: '0'
|
69
81
|
requirements: []
|
70
82
|
rubyforge_project:
|
71
|
-
rubygems_version:
|
83
|
+
rubygems_version: 1.8.25
|
72
84
|
signing_key:
|
73
|
-
specification_version:
|
85
|
+
specification_version: 3
|
74
86
|
summary: Library for parsing C++ header files
|
75
87
|
test_files:
|
76
88
|
- spec/namespace_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 529b48f43c4fd9b2bbc9acb11ab140d9e6150e09
|
4
|
-
data.tar.gz: df41fcf999c92693df3cf2f9dfee73f1b1b095ce
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 9a22858cbfdfe61b3d7248736ccbdc7f8ca22f03c415e6f30905e10ea3a820ce1dbb2db4e51e6fb0f307463422aa154eb24194bf8458fa4ac8cd7d5da6bcbc94
|
7
|
-
data.tar.gz: 8bec965f048166cc90ac92dcd2fb7beede9ea6a9e1b0e5cee343d6c1753918d9305971ca2b3c8fcc6613199d51089faedb61f7497a14047befb4958804b6cf8d
|