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,29 +1,48 @@
1
1
  module Doxyparser
2
2
 
3
- class Type < Node
4
-
5
- def nested_local_types
6
- refs = @node.xpath("ref")
7
- return [] if refs.nil? || refs.empty?
8
- refs.map { |r| Type.new(node: r, dir: @dir) }
9
- end
10
-
11
- def nested_typenames
12
- splitted = @name.split(%r{[<,>]}).map{|s| s.strip}.reject!{|s| s.nil? || !(s =~ /^\D[\w:]*\w$/)}
13
- end
14
-
15
- def template?
16
- @name.include? '<'
17
- end
18
-
19
- private
20
-
21
- def init_attributes
22
- @basename = @name
23
- end
24
-
25
- def find_name
26
- @node.content
27
- end
28
- end
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
@@ -1,69 +1,74 @@
1
1
  module Doxyparser
2
2
 
3
- module Util
3
+ module Util
4
4
 
5
- def self.home_dir
6
- File.expand_path('..', File.dirname(__FILE__))
7
- end
5
+ def self.home_dir
6
+ File.expand_path('..', File.dirname(__FILE__))
7
+ end
8
8
 
9
- def del_spaces n
10
- n.gsub(/\s+/, "")
11
- end
9
+ def del_spaces(n)
10
+ n.gsub(/\s+/, "")
11
+ end
12
12
 
13
- def del_prefix n
14
- n.gsub(%r{.*[:/]}, "")
15
- end
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
- def escape_file_name filename
18
- if filename =~ %r{[\./]}
19
- return filename.gsub('.', '_8').gsub('/', '_2')
20
- else
21
- return filename.gsub('_8', '.').gsub('_2', '/')
22
- end
23
- end
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
- def escape_class_name filename
26
- if filename.include? '::'
27
- return filename.gsub('::','_1_1')
28
- else
29
- return filename.gsub('_1_1','::')
30
- end
31
- end
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
- def self.read_file file_name
34
- file = File.open(file_name, "r")
35
- data = file.read
36
- file.close
37
- return data
38
- end
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
- def self.write_file file_name, data
41
- file = File.open(file_name, "w")
42
- count = file.write(data)
43
- file.close
44
- return count
45
- end
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
- def do_filter filter, lst, clazz
48
- if filter
49
- filtered_lst = []
50
- filter.each { |val|
51
- found = lst.select { |node| match(val, yield(node)) }
52
- raise "The object: #{val} #{clazz} could not be found while parsing" if found.nil? || found.empty?
53
- filtered_lst.push(*found)
54
- }
55
- else
56
- filtered_lst=lst
57
- end
58
- filtered_lst.map { |node| clazz.new(parent: self, node: node) }
59
- end
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
- def match val, aux_name
62
- if val.is_a? Regexp
63
- return aux_name =~ val
64
- else
65
- return aux_name == val
66
- end
67
- end
68
- end
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
@@ -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", "std"]
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
 
@@ -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, ['isBoolProp'])
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::isBoolProp'
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, ['getProp'])[0]
28
- getter.getter_for.should eql 'prop'
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, ['setProp'])[0]
31
- setter.setter_for.should eql 'prop'
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, ['isBoolProp'])[0]
36
- getter.getter_for.should eql 'boolProp'
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, ['get_Prop2'])[0]
42
- getter.getter_for.should eql 'prop2'
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, ['set_Prop2'])[0]
45
- setter.setter_for.should eql 'prop2'
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, ['GetProp3'])[0]
52
- getter.getter_for.should eql 'prop3'
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, ['SetProp3'])[0]
55
- setter.setter_for.should eql 'prop3'
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
@@ -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, TemplateClass< OuterStruct,::noNsClass, 8 > >'
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.2'
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-25 00:00:00.000000000 Z
12
+ date: 2013-07-05 00:00:00.000000000 Z
12
13
  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.
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: 2.0.2
83
+ rubygems_version: 1.8.25
72
84
  signing_key:
73
- specification_version: 4
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