yard-mruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +41 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/lib/yard-mruby.rb +1 -0
  13. data/lib/yard/handlers.rb +2 -0
  14. data/lib/yard/handlers/c.rb +6 -0
  15. data/lib/yard/handlers/c/mruby_base.rb +47 -0
  16. data/lib/yard/handlers/c/mruby_class_handler.rb +35 -0
  17. data/lib/yard/handlers/c/mruby_method_handler.rb +25 -0
  18. data/lib/yard/handlers/c/mruby_module_handler.rb +34 -0
  19. data/lib/yard/handlers/c/mruby_symbol_handler.rb +15 -0
  20. data/lib/yard/handlers/header.rb +1 -0
  21. data/lib/yard/handlers/header/base.rb +11 -0
  22. data/lib/yard/handlers/header/define_handler.rb +0 -0
  23. data/lib/yard/handlers/header/function_handler.rb +0 -0
  24. data/lib/yard/handlers/header/header_handler.rb +0 -0
  25. data/lib/yard/mruby.rb +3 -0
  26. data/lib/yard/mruby/code_objects.rb +3 -0
  27. data/lib/yard/mruby/code_objects/define_object.rb +8 -0
  28. data/lib/yard/mruby/code_objects/function_object.rb +7 -0
  29. data/lib/yard/mruby/code_objects/header_object.rb +7 -0
  30. data/lib/yard/mruby/version.rb +5 -0
  31. data/sample/.gitignore +5 -0
  32. data/sample/.inch.yml +3 -0
  33. data/sample/.travis.yml +2 -0
  34. data/sample/.yardopts +3 -0
  35. data/sample/CODE_OF_CONDUCT.md +13 -0
  36. data/sample/Gemfile +5 -0
  37. data/sample/LICENSE.txt +21 -0
  38. data/sample/README.md +12 -0
  39. data/sample/build_config.rb +9 -0
  40. data/sample/include/sample.h +37 -0
  41. data/sample/mrbgem.rake +15 -0
  42. data/sample/mrblib/sample.rb +14 -0
  43. data/sample/src/sample.c +34 -0
  44. data/sample/test/sample_spec.rb +11 -0
  45. data/yard-mruby.gemspec +27 -0
  46. metadata +145 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e3468feb795ec8df9a061393de6d06130dcfa10
4
+ data.tar.gz: af22a19aebc351efb2dd5cb6d7c6d8b96e1981e2
5
+ SHA512:
6
+ metadata.gz: c89235ff1ffacc1ff1361baa8293a2be73682bf98c7814eb8c9fe1e4b52270a6e10a213f9bd547ab702e30af566018558f61d93a1b7c1641e0931bcf61e02bba
7
+ data.tar.gz: fae8caf9251763d8fa92eeea5cd4c7b68d878f7c525436bf503c8ac6e1710512c11efc46a2b0741b1cfb8ec284eb3d7f3a7fceff16b6f075cc5cbbc54f79463b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +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/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yard-mruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +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.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Yard::Mruby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yard/mruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'yard-mruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install yard-mruby
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yard-mruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +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
data/bin/console ADDED
@@ -0,0 +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
data/bin/setup ADDED
@@ -0,0 +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
data/lib/yard-mruby.rb ADDED
@@ -0,0 +1 @@
1
+ require 'yard/mruby'
@@ -0,0 +1,2 @@
1
+ require_relative 'handlers/c'
2
+ #require_relative 'handlers/header'
@@ -0,0 +1,6 @@
1
+ require_relative 'c/mruby_base'
2
+ require_relative 'c/mruby_symbol_handler'
3
+ require_relative 'c/mruby_class_handler'
4
+ require_relative 'c/mruby_module_handler'
5
+ require_relative 'c/mruby_method_handler'
6
+
@@ -0,0 +1,47 @@
1
+ module YARD::Handlers::C
2
+ class MRubyBase < Base
3
+
4
+ DEFAULT_NAMESPACES = {
5
+ # 'mrb->top_self' => '',
6
+ 'object_class' => 'Object',
7
+ 'class_class' => 'Class',
8
+ 'module_class' => 'Module',
9
+ 'proc_class' => 'Proc',
10
+ 'string_class' => 'String',
11
+ 'array_class' => 'Array',
12
+ 'hash_class' => 'Hash',
13
+ 'float_class' => 'Float',
14
+ 'fixnum_class' => 'Fixnum',
15
+ 'true_class' => 'TrueClass',
16
+ 'false_class' => 'FalseClass',
17
+ 'nil_class' => 'NilClass',
18
+ 'symbol_class' => 'Symbol',
19
+ 'kernel_module' => 'Kernel'
20
+ }
21
+
22
+ def namespace_for_variable(var)
23
+ DEFAULT_NAMESPACES[ var[/^\w+->(\w+)$/, 1] ] || super
24
+ end
25
+
26
+ def handle_class(var_name, class_name, parent, stmt, in_module = nil)
27
+ object = super(var_name, class_name, parent, in_module)
28
+
29
+ if stmt.comments
30
+ register_docstring(object, stmt.comments.source, stmt)
31
+ end
32
+
33
+ object
34
+ end
35
+
36
+ def handle_module(var_name, module_name, stmt, in_module = nil)
37
+ object = super(var_name, module_name, in_module)
38
+
39
+ if stmt.comments
40
+ register_docstring(object, stmt.comments.source, stmt)
41
+ end
42
+
43
+ object
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ module YARD::Handlers::C
2
+ class MRubyClassHandler < MRubyBase
3
+
4
+ TOP_LEVEL_CLASS = /([\w]+)\s*=\s*mrb_define_class\s*
5
+ \(
6
+ \s*\w+\s*,
7
+ \s*"(\w+)"\s*,
8
+ \s*([\w\->]+)\s*
9
+ \)
10
+ /mx
11
+
12
+ NAMESPACED_CLASS = /([\w]+)\s*=\s*mrb_define_class_under\s*
13
+ \(
14
+ \s*\w+\s*,
15
+ \s*(\w+)\s*,
16
+ \s*"(\w+)"\s*,
17
+ \s*([\w\->]+)\s*
18
+ \)
19
+ /mx
20
+
21
+ handles TOP_LEVEL_CLASS
22
+ handles NAMESPACED_CLASS
23
+
24
+ statement_class BodyStatement
25
+
26
+ process do
27
+ statement.source.scan(TOP_LEVEL_CLASS) do |var_name, class_name, parent|
28
+ handle_class(var_name, class_name, parent, statement)
29
+ end
30
+ statement.source.scan(NAMESPACED_CLASS) do |var_name, in_module, class_name, parent|
31
+ handle_class(var_name, class_name, parent, statement, in_module)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ module YARD::Handlers::C
2
+ class MRubyMethodHandler < MRubyBase
3
+ MATCH1 = /mrb_define_(
4
+ method |
5
+ singleton_method |
6
+ module_function
7
+ )
8
+ \s*\(
9
+ \s*\w+\s*,
10
+ \s*(\w+)\s*,
11
+ \s*"(\w+)"\s*,
12
+ \s*(\w+)\s*,
13
+ /mx
14
+
15
+ handles MATCH1
16
+ statement_class BodyStatement
17
+
18
+ process do
19
+ statement.source.scan(MATCH1) do |type,var_name, name, func_name|
20
+ handle_method(type, var_name, name, func_name)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ module YARD::Handlers::C
2
+ class MRubyModuleHandler < MRubyBase
3
+
4
+ TOP_LEVEL_MODULE = /([\w]+)\s*=\s*mrb_define_module\s*
5
+ \(
6
+ \s*\w+\s*,
7
+ \s*"(\w+)"\s*
8
+ \)
9
+ /mx
10
+
11
+ NAMESPACED_MODULE = /([\w]+)\s*=\s*mrb_define_module_under\s*
12
+ \(
13
+ \s*\w+\s*,
14
+ \s*(\w+)\s*,
15
+ \s*"(\w+)"\s*
16
+ \)
17
+ /mx
18
+
19
+ handles TOP_LEVEL_MODULE
20
+ handles NAMESPACED_MODULE
21
+
22
+ statement_class BodyStatement
23
+
24
+ process do
25
+ statement.source.scan(TOP_LEVEL_MODULE) do |var_name, module_name|
26
+ handle_module(var_name, module_name, statement)
27
+ end
28
+ statement.source.scan(NAMESPACED_MODULE) do |var_name, in_module, module_name|
29
+ handle_module(var_name, module_name, statement, in_module)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,15 @@
1
+ module YARD::Handlers::C
2
+ # Keeps track of function bodies for symbol lookup during MRuby method declarations
3
+ class MRubySymbolHandler < MRubyBase
4
+ MATCH = /
5
+ mrb_value\s*(\w+)\s*\(\s*mrb_state\s*\*\s*\w+,\s*mrb_value\s*\w+\s*\)
6
+ /mx
7
+
8
+ handles MATCH
9
+ statement_class ToplevelStatement
10
+
11
+ process do
12
+ symbols[statement.source[MATCH, 1]] = statement
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ require_relative 'header/base'
@@ -0,0 +1,11 @@
1
+ module YARD
2
+ module MRuby
3
+ module Handlers
4
+ module Header
5
+ class Base < YARD::Handlers::Base
6
+ include YARD::Parser::C
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
File without changes
File without changes
File without changes
data/lib/yard/mruby.rb ADDED
@@ -0,0 +1,3 @@
1
+ require_relative "mruby/version"
2
+ require_relative "mruby/code_objects"
3
+ require_relative "handlers"
@@ -0,0 +1,3 @@
1
+ require_relative 'code_objects/header_object'
2
+ require_relative 'code_objects/function_object'
3
+ require_relative 'code_objects/define_object'
@@ -0,0 +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 < YARD::CodeObjects::Base
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,7 @@
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 < YARD::CodeObjects::Base
5
+ end
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+ module YARD::MRuby::CodeObjects
2
+
3
+ # A HeaderObject represents a MRuby header inside an include directory
4
+ # It groups C Functions and define macros.
5
+ class HeaderObject < YARD::CodeObjects::NamespaceObject
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module YARD
2
+ module MRuby
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
data/sample/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ build
2
+ .bundle
3
+ Gemfile.lock
4
+ doc
5
+ .yardoc
data/sample/.inch.yml ADDED
@@ -0,0 +1,3 @@
1
+ files:
2
+ included:
3
+ - mrblib/**/*.rb
@@ -0,0 +1,2 @@
1
+ install: bundle install
2
+ script: bundle exec mrb test
data/sample/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ --plugin mruby
2
+ mrblib/**/*.rb
3
+ src/**/*.c
@@ -0,0 +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/)
data/sample/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'mruby-cli'
4
+ gem 'mruby-source', github: 'sagmor/mruby'
5
+ gem 'yard-mruby', path: '..'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 [PUT YOUR NAME HERE]
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/sample/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Sample MRuby GEM
2
+
3
+ TODO: Write your README
4
+
5
+ ## Contributing
6
+
7
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sample. 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.
8
+
9
+
10
+ ## License
11
+
12
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,9 @@
1
+ MRuby::Build.new do |conf|
2
+ toolchain :gcc
3
+ enable_debug
4
+
5
+ conf.gem '.'
6
+
7
+ conf.enable_test
8
+ end
9
+
@@ -0,0 +1,37 @@
1
+ #include "mruby.h"
2
+
3
+ #ifndef SAMPLE_H
4
+ #define SAMPLE_H
5
+
6
+ /**
7
+ * Sample C API module definition
8
+ */
9
+ MRB_BEGIN_DECL
10
+
11
+ /**
12
+ * A Sample C API method definition
13
+ *
14
+ * @param mrb The MRuby state.
15
+ * @return some ruby value
16
+ */
17
+ MRB_API mrb_value sample_api_method(mrb_state *mrb);
18
+
19
+ /**
20
+ * Another API method, now inlined.
21
+ *
22
+ * @param value some ruby value
23
+ * @return the same value
24
+ */
25
+ MRB_INLINE mrb_value sample_inline_method(mrb_value value)
26
+ {
27
+ return value;
28
+ }
29
+
30
+ /**
31
+ * A sample deprecated method
32
+ */
33
+ MRB_API mrb_deprecated void sample_deprecated_method( void );
34
+
35
+ MRB_END_DECL
36
+
37
+ #endif /* SAMPLE_H */
@@ -0,0 +1,15 @@
1
+ MRuby::Gem::Specification.new('sample') do |spec|
2
+ spec.license = 'MIT'
3
+ spec.author = 'TODO: Put your name here'
4
+ spec.summary = %q{TODO: Write a short summary of your gem.}
5
+ spec.version = '0.1.0'
6
+
7
+ # Add your runtime dependencies here
8
+ # spec.add_dependency('mruby-math', :core => 'mruby-math')
9
+
10
+
11
+ # Add your test dependencies here
12
+ if build.test_enabled?
13
+ spec.add_dependency('mruby-spec', :github => 'sagmor/mruby-spec')
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Sample
2
+
3
+ # A Sample test class
4
+ class Test
5
+
6
+ # Foo returns bar
7
+ #
8
+ # @return [String] bar!
9
+ def foo
10
+ return "bar"
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,34 @@
1
+ #include "sample.h"
2
+
3
+ mrb_value sample_api_method(mrb_state *mrb)
4
+ {
5
+ return mrb_nil_value();
6
+ }
7
+
8
+ void sample_deprecated_method( void )
9
+ {
10
+ }
11
+
12
+ /**
13
+ * A sample Ruby method defined from C
14
+ *
15
+ * @return [String] Hello World!
16
+ */
17
+ mrb_value mrb_Sample_Hello__world(mrb_state *mrb, mrb_value self)
18
+ {
19
+ return sample_inline_method( mrb_str_new_cstr(mrb, "Hello World!" ) );
20
+ }
21
+
22
+ void
23
+ mrb_sample_gem_init(mrb_state *mrb)
24
+ {
25
+ struct RClass *ns = mrb_define_module(mrb, "Sample");
26
+ struct RClass *cl = mrb_define_class_under(mrb, ns, "Hello", mrb->object_class);
27
+ mrb_define_method(mrb,cl, "world", mrb_Sample_Hello__world, MRB_ARGS_NONE() );
28
+ }
29
+
30
+ void
31
+ mrb_sample_gem_final(mrb_state *mrb)
32
+ {
33
+ // Your C finalization code goes here
34
+ }
@@ -0,0 +1,11 @@
1
+ describe Sample::Test do
2
+ it "foos" do
3
+ expect(subject.foo).to eq "bar"
4
+ end
5
+ end
6
+
7
+ describe Sample::Hello do
8
+ it "salutes" do
9
+ expect(subject.world).to eq "Hello World!"
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yard/mruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yard-mruby"
8
+ spec.version = YARD::MRuby::VERSION
9
+ spec.authors = ["Seba Gamboa"]
10
+ spec.email = ["me@sagmor.com"]
11
+
12
+ spec.summary = %q{Generate Yard documentation for MRuby projects.}
13
+ spec.description = %q{Generate Yard documentation for MRuby projects.}
14
+ spec.homepage = "https://github.com/sagmor/yard-mruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "yard"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec"
27
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-mruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seba Gamboa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Generate Yard documentation for MRuby projects.
70
+ email:
71
+ - me@sagmor.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/yard-mruby.rb
87
+ - lib/yard/handlers.rb
88
+ - lib/yard/handlers/c.rb
89
+ - lib/yard/handlers/c/mruby_base.rb
90
+ - lib/yard/handlers/c/mruby_class_handler.rb
91
+ - lib/yard/handlers/c/mruby_method_handler.rb
92
+ - lib/yard/handlers/c/mruby_module_handler.rb
93
+ - lib/yard/handlers/c/mruby_symbol_handler.rb
94
+ - lib/yard/handlers/header.rb
95
+ - lib/yard/handlers/header/base.rb
96
+ - lib/yard/handlers/header/define_handler.rb
97
+ - lib/yard/handlers/header/function_handler.rb
98
+ - lib/yard/handlers/header/header_handler.rb
99
+ - lib/yard/mruby.rb
100
+ - lib/yard/mruby/code_objects.rb
101
+ - lib/yard/mruby/code_objects/define_object.rb
102
+ - lib/yard/mruby/code_objects/function_object.rb
103
+ - lib/yard/mruby/code_objects/header_object.rb
104
+ - lib/yard/mruby/version.rb
105
+ - sample/.gitignore
106
+ - sample/.inch.yml
107
+ - sample/.travis.yml
108
+ - sample/.yardopts
109
+ - sample/CODE_OF_CONDUCT.md
110
+ - sample/Gemfile
111
+ - sample/LICENSE.txt
112
+ - sample/README.md
113
+ - sample/build_config.rb
114
+ - sample/include/sample.h
115
+ - sample/mrbgem.rake
116
+ - sample/mrblib/sample.rb
117
+ - sample/src/sample.c
118
+ - sample/test/sample_spec.rb
119
+ - yard-mruby.gemspec
120
+ homepage: https://github.com/sagmor/yard-mruby
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.4.5
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Generate Yard documentation for MRuby projects.
144
+ test_files: []
145
+ has_rdoc: