yard-mruby 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -9
  3. data/.rspec +2 -2
  4. data/.travis.yml +4 -4
  5. data/CODE_OF_CONDUCT.md +13 -13
  6. data/Gemfile +4 -4
  7. data/LICENSE.txt +21 -21
  8. data/README.md +31 -31
  9. data/Rakefile +6 -6
  10. data/bin/console +14 -14
  11. data/bin/setup +7 -7
  12. data/exe/mrbdoc +5 -5
  13. data/lib/yard-mruby.rb +1 -1
  14. data/lib/yard/mruby.rb +9 -9
  15. data/lib/yard/mruby/cli.rb +1 -1
  16. data/lib/yard/mruby/cli/yardoc.rb +14 -14
  17. data/lib/yard/mruby/code_objects.rb +6 -6
  18. data/lib/yard/mruby/code_objects/define_object.rb +8 -8
  19. data/lib/yard/mruby/code_objects/function_object.rb +72 -72
  20. data/lib/yard/mruby/code_objects/header_base_object.rb +15 -15
  21. data/lib/yard/mruby/code_objects/header_object.rb +30 -30
  22. data/lib/yard/mruby/code_objects/headers_root.rb +14 -14
  23. data/lib/yard/mruby/code_objects/typedef_object.rb +8 -8
  24. data/lib/yard/mruby/handlers.rb +1 -1
  25. data/lib/yard/mruby/handlers/c.rb +4 -4
  26. data/lib/yard/mruby/handlers/c/header.rb +5 -5
  27. data/lib/yard/mruby/handlers/c/header/base.rb +30 -30
  28. data/lib/yard/mruby/handlers/c/header/define_handler.rb +23 -23
  29. data/lib/yard/mruby/handlers/c/header/function_handler.rb +33 -33
  30. data/lib/yard/mruby/handlers/c/header/header_decl_handler.rb +20 -20
  31. data/lib/yard/mruby/handlers/c/header/typedef_handler.rb +31 -31
  32. data/lib/yard/mruby/handlers/c/source.rb +7 -7
  33. data/lib/yard/mruby/handlers/c/source/base.rb +56 -56
  34. data/lib/yard/mruby/handlers/c/source/class_handler.rb +35 -35
  35. data/lib/yard/mruby/handlers/c/source/init_handler.rb +16 -16
  36. data/lib/yard/mruby/handlers/c/source/method_handler.rb +25 -25
  37. data/lib/yard/mruby/handlers/c/source/module_handler.rb +34 -34
  38. data/lib/yard/mruby/handlers/c/source/symbol_handler.rb +16 -16
  39. data/lib/yard/mruby/parser.rb +1 -1
  40. data/lib/yard/mruby/parser/c.rb +4 -4
  41. data/lib/yard/mruby/parser/c/directive_statement.rb +6 -6
  42. data/lib/yard/mruby/parser/c/header_parser.rb +49 -49
  43. data/lib/yard/mruby/parser/c/parser.rb +10 -10
  44. data/lib/yard/mruby/parser/c/source_parser.rb +9 -9
  45. data/lib/yard/mruby/tags.rb +2 -2
  46. data/lib/yard/mruby/templates.rb +9 -9
  47. data/lib/yard/mruby/templates/helpers.rb +1 -1
  48. data/lib/yard/mruby/templates/helpers/html_helper.rb +32 -32
  49. data/lib/yard/mruby/version.rb +5 -5
  50. data/sample/.gitignore +5 -5
  51. data/sample/.inch.yml +3 -3
  52. data/sample/.travis.yml +2 -2
  53. data/sample/.yardopts +4 -4
  54. data/sample/CODE_OF_CONDUCT.md +13 -13
  55. data/sample/Gemfile +5 -5
  56. data/sample/LICENSE.txt +21 -21
  57. data/sample/README.md +12 -12
  58. data/sample/build_config.rb +9 -9
  59. data/sample/include/sample.h +37 -37
  60. data/sample/mrbgem.rake +15 -15
  61. data/sample/mrblib/sample.rb +14 -14
  62. data/sample/src/sample.c +34 -34
  63. data/sample/test/sample_spec.rb +11 -11
  64. data/templates/default/fulldoc/html/full_list_functions.erb +10 -10
  65. data/templates/default/fulldoc/html/full_list_headers.erb +10 -10
  66. data/templates/default/fulldoc/html/setup.rb +62 -62
  67. data/templates/default/function_details/html/function_signature.erb +10 -10
  68. data/templates/default/function_details/html/header.erb +3 -3
  69. data/templates/default/function_details/html/source.erb +10 -10
  70. data/templates/default/function_details/setup.rb +12 -12
  71. data/templates/default/header/html/define_summary.erb +11 -11
  72. data/templates/default/header/html/function_details_list.erb +7 -7
  73. data/templates/default/header/html/function_summary.erb +12 -12
  74. data/templates/default/header/html/functions.erb +1 -1
  75. data/templates/default/header/html/header.erb +1 -1
  76. data/templates/default/header/html/includes.erb +1 -1
  77. data/templates/default/header/html/item_summary.erb +19 -19
  78. data/templates/default/header/html/pre_docstring.erb +1 -1
  79. data/templates/default/header/html/setup.rb +32 -32
  80. data/templates/default/header/html/typedef_summary.erb +11 -11
  81. data/templates/default/headersroot/html/headers_list.erb +6 -6
  82. data/templates/default/headersroot/html/setup.rb +10 -10
  83. data/templates/default/layout/html/footer.erb +5 -5
  84. data/templates/default/layout/html/setup.rb +52 -52
  85. data/templates/default/tags/html/iso.erb +3 -3
  86. data/templates/default/tags/html/mrbgem.erb +3 -3
  87. data/templates/default/tags/setup.rb +10 -10
  88. data/yard-mruby.gemspec +27 -27
  89. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67619c176c6d3eac1b48180db76798a1904f24e8
4
- data.tar.gz: 7500da8ca06456e333cd484bdbc63f1a7ebb8436
3
+ metadata.gz: 190f5ff1d85a7da50b2cf177931e3cabb4def6c8
4
+ data.tar.gz: 51db17c11ee8a3cd9f09e97f8f6681e070c61fdd
5
5
  SHA512:
6
- metadata.gz: 1a38d3bbe50d358eb3d2d1e6f90ac09189b453ef828c8086b6b2e06623196642efda390196b50ddaec2d51ddc93aca4ae123c2105988c037b6c62d6d15f6fb3f
7
- data.tar.gz: 7b29d3f900dd59db364a8b02e7d6e16b4abbb08999de3d4424dae80131b701344b79828faaba3d76ac4bffc9c46ce5e1ea577c54e08348687ab00e2d31dd751e
6
+ metadata.gz: b458bfb91fde2f55187fc990206c9006dc743452d47da17db0ff4127ffcca29b3519d0a5fe7d169d14ddec8c155a6a9e0224bde9a0c64bd7a2ded62f6a6775e8
7
+ data.tar.gz: 3dd0739fc2a4ad829ebb55fdc19ede5db7f9321f8bd37083cc5ebf6b5833422ed7edcdfb6285c1da6f04a9789f3ba8d446d8bb387863e6aa1965731da11cc595
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
2
- --color
1
+ --format documentation
2
+ --color
@@ -1,4 +1,4 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.1
4
- before_install: gem install bundler -v 1.10.6
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -1,13 +1,13 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in yard-mruby.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yard-mruby.gemspec
4
+ gemspec
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Seba Gamboa
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Seba Gamboa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # yard-mruby
2
-
3
- [![Gem](https://img.shields.io/gem/v/yard-mruby.svg)](https://rubygems.org/gems/yard-mruby)
4
- [![Travis](https://img.shields.io/travis/sagmor/yard-mruby.svg)](https://travis-ci.org/sagmor/yard-mruby)
5
-
6
- This is a plugin that allows YARD to parse and generate documentation for MRuby sources as well as documenting it's C APIs.
7
-
8
- It still has it's [rough edges and missing features](https://github.com/sagmor/yard-mruby/issues) but you can see a [sample from it's current state when executed on MRuby's core here](https://sagmor.com/mruby/)
9
-
10
- ## Usage
11
-
12
- Install with rubygems
13
-
14
- $ gem install yard-mruby
15
-
16
- And execute `mrbdoc` to generate the docs
17
-
18
- ## Development
19
-
20
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
21
- To install this gem onto your local machine, run `bundle exec rake install`.
22
-
23
- ## Contributing
24
-
25
- Bug reports and pull requests are welcome on GitHub at https://github.com/sagmor/yard-mruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
26
-
27
-
28
- ## License
29
-
30
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
31
-
1
+ # yard-mruby
2
+
3
+ [![Gem](https://img.shields.io/gem/v/yard-mruby.svg)](https://rubygems.org/gems/yard-mruby)
4
+ [![Travis](https://img.shields.io/travis/sagmor/yard-mruby.svg)](https://travis-ci.org/sagmor/yard-mruby)
5
+
6
+ This is a plugin that allows YARD to parse and generate documentation for MRuby sources as well as documenting it's C APIs.
7
+
8
+ It still has it's [rough edges and missing features](https://github.com/sagmor/yard-mruby/issues) but you can see a [sample from it's current state when executed on MRuby's core here](https://sagmor.com/mruby/)
9
+
10
+ ## Usage
11
+
12
+ Install with rubygems
13
+
14
+ $ gem install yard-mruby
15
+
16
+ And execute `mrbdoc` to generate the docs
17
+
18
+ ## Development
19
+
20
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
21
+ To install this gem onto your local machine, run `bundle exec rake install`.
22
+
23
+ ## Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sagmor/yard-mruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
26
+
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
31
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "yard/mruby"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yard/mruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,7 +1,7 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/mrbdoc CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/yard/mruby'
4
-
5
- YARD::CLI::Yardoc.run(*ARGV)
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/yard/mruby'
4
+
5
+ YARD::CLI::Yardoc.run(*ARGV)
@@ -1 +1 @@
1
- require 'yard/mruby' unless Kernel.const_defined?(:YARD) && YARD.const_defined?(:MRuby)
1
+ require 'yard/mruby' unless Kernel.const_defined?(:YARD) && YARD.const_defined?(:MRuby)
@@ -1,9 +1,9 @@
1
- require 'yard'
2
-
3
- require_relative "mruby/version"
4
- require_relative "mruby/code_objects"
5
- require_relative "mruby/parser"
6
- require_relative "mruby/handlers"
7
- require_relative "mruby/tags"
8
- require_relative "mruby/templates"
9
- require_relative "mruby/cli"
1
+ require 'yard'
2
+
3
+ require_relative "mruby/version"
4
+ require_relative "mruby/code_objects"
5
+ require_relative "mruby/parser"
6
+ require_relative "mruby/handlers"
7
+ require_relative "mruby/tags"
8
+ require_relative "mruby/templates"
9
+ require_relative "mruby/cli"
@@ -1 +1 @@
1
- require_relative 'cli/yardoc'
1
+ require_relative 'cli/yardoc'
@@ -1,14 +1,14 @@
1
- module YARD::MRuby::CLI
2
- module Yardoc
3
-
4
- # Redefines default files for YARD::CLI::Yardoc
5
- def parse_arguments(*args)
6
- super(*args)
7
- self.files = %w{src/**/*.c mrblib/**/*.rb include/**/*.h} if self.files.empty?
8
- end
9
- end
10
-
11
- # Load Above modifications into YARD::CLI::Yardoc
12
- YARD::CLI::Yardoc.include Yardoc
13
- end
14
-
1
+ module YARD::MRuby::CLI
2
+ module Yardoc
3
+
4
+ # Redefines default files for YARD::CLI::Yardoc
5
+ def parse_arguments(*args)
6
+ super(*args)
7
+ self.files = %w{src/**/*.c mrblib/**/*.rb include/**/*.h} if self.files.empty?
8
+ end
9
+ end
10
+
11
+ # Load Above modifications into YARD::CLI::Yardoc
12
+ YARD::CLI::Yardoc.include Yardoc
13
+ end
14
+
@@ -1,6 +1,6 @@
1
- require_relative 'code_objects/headers_root'
2
- require_relative 'code_objects/header_base_object'
3
- require_relative 'code_objects/header_object'
4
- require_relative 'code_objects/function_object'
5
- require_relative 'code_objects/define_object'
6
- require_relative 'code_objects/typedef_object'
1
+ require_relative 'code_objects/headers_root'
2
+ require_relative 'code_objects/header_base_object'
3
+ require_relative 'code_objects/header_object'
4
+ require_relative 'code_objects/function_object'
5
+ require_relative 'code_objects/define_object'
6
+ require_relative 'code_objects/typedef_object'
@@ -1,8 +1,8 @@
1
- module YARD::MRuby::CodeObjects
2
-
3
- # A DefineObject represents a MRuby C API define macro declaration inside a header inside an include directory
4
- class DefineObject < HeaderBaseObject
5
- end
6
- end
7
-
8
-
1
+ module YARD::MRuby::CodeObjects
2
+
3
+ # A DefineObject represents a MRuby C API define macro declaration inside a header inside an include directory
4
+ class DefineObject < HeaderBaseObject
5
+ end
6
+ end
7
+
8
+
@@ -1,72 +1,72 @@
1
- module YARD::MRuby::CodeObjects
2
-
3
- # A FunctionObject represents a MRuby C API function declaration inside a header inside an include directory
4
- class FunctionObject < HeaderBaseObject
5
- ParameterType = Struct.new(:type,:name)
6
-
7
- # Returns the list of parameters parsed out of the method signature
8
- # with their default values.
9
- #
10
- # @return [Array<Array(String, String)>] a list of parameter names followed
11
- # by their default values (or nil)
12
- attr_accessor :parameters
13
-
14
- def initialize(header, name, &block)
15
- super
16
- end
17
-
18
- def attr_info
19
- nil
20
- end
21
-
22
- def scope
23
- ''
24
- end
25
-
26
- def return_type
27
- @return_type
28
- end
29
-
30
- def return_type=(type)
31
- @return_type = (type == 'void' ? nil : type)
32
- end
33
-
34
- # Returns the list of parameters parsed out of the method signature
35
- # with their default values.
36
- #
37
- # @return [Array<Array(String, String)>] a list of parameter names followed
38
- # by their default values (or nil)
39
- def parameters
40
- parameter_types.map{|t| [(t.type == '...' ? '...' : t.name), nil] }
41
- end
42
-
43
- def parameter_types
44
- @parameter_types || []
45
- end
46
-
47
- def parse_parameter_types(parameters)
48
- @parameter_types = []
49
- return if parameters.match /^\s*void\s*$/
50
-
51
- parameters.split(',').each do |parameter|
52
- parameter.scan(/((?:const\s+)?(?:struct\s+)?(?:\w+|\.\.\.)(?:\s*\*)?)\s*(\w+)?/) do |type,name|
53
- @parameter_types << ParameterType.new(type,name)
54
- end
55
- end
56
-
57
- end
58
-
59
-
60
- # Returns all alias names of the object
61
- # @return [Array<Symbol>] the alias names
62
- def aliases
63
- list = []
64
- return list unless namespace.is_a?(HeaderObject)
65
- namespace.aliases.each do |o, aname|
66
- list << o if aname == name && o.scope == scope
67
- end
68
- list
69
- end
70
- end
71
- end
72
-
1
+ module YARD::MRuby::CodeObjects
2
+
3
+ # A FunctionObject represents a MRuby C API function declaration inside a header inside an include directory
4
+ class FunctionObject < HeaderBaseObject
5
+ ParameterType = Struct.new(:type,:name)
6
+
7
+ # Returns the list of parameters parsed out of the method signature
8
+ # with their default values.
9
+ #
10
+ # @return [Array<Array(String, String)>] a list of parameter names followed
11
+ # by their default values (or nil)
12
+ attr_accessor :parameters
13
+
14
+ def initialize(header, name, &block)
15
+ super
16
+ end
17
+
18
+ def attr_info
19
+ nil
20
+ end
21
+
22
+ def scope
23
+ ''
24
+ end
25
+
26
+ def return_type
27
+ @return_type
28
+ end
29
+
30
+ def return_type=(type)
31
+ @return_type = (type == 'void' ? nil : type)
32
+ end
33
+
34
+ # Returns the list of parameters parsed out of the method signature
35
+ # with their default values.
36
+ #
37
+ # @return [Array<Array(String, String)>] a list of parameter names followed
38
+ # by their default values (or nil)
39
+ def parameters
40
+ parameter_types.map{|t| [(t.type == '...' ? '...' : t.name), nil] }
41
+ end
42
+
43
+ def parameter_types
44
+ @parameter_types || []
45
+ end
46
+
47
+ def parse_parameter_types(parameters)
48
+ @parameter_types = []
49
+ return if parameters.match /^\s*void\s*$/
50
+
51
+ parameters.split(',').each do |parameter|
52
+ parameter.scan(/((?:const\s+)?(?:struct\s+)?(?:\w+|\.\.\.)(?:\s*\*)?)\s*(\w+)?/) do |type,name|
53
+ @parameter_types << ParameterType.new(type,name)
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+
60
+ # Returns all alias names of the object
61
+ # @return [Array<Symbol>] the alias names
62
+ def aliases
63
+ list = []
64
+ return list unless namespace.is_a?(HeaderObject)
65
+ namespace.aliases.each do |o, aname|
66
+ list << o if aname == name && o.scope == scope
67
+ end
68
+ list
69
+ end
70
+ end
71
+ end
72
+