Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module method with options before declaring module_function Errors out #567

Closed
gkellogg opened this issue Jul 5, 2012 · 1 comment
Closed

Comments

@gkellogg
Copy link

gkellogg commented Jul 5, 2012

Try creating a directory 'lib', and then add the following as the contents in a file called 'test.rb' within lib:

module Test
  # @param [#to_s] arg
  # @param [Hash{Symbol => Object}] options
  # @option options [#to_sym] :format
  def test(arg, options = {})
  end
  module_function :test

end

This errors out with the following:

[yardtest] yardoc
[error]: Unhandled exception in YARD::Handlers::Ruby::ModuleFunctionHandler:
[error]:   in `lib/test.rb`:7:

    7: module_function :test

[error]: NoMethodError: undefined method `length' for nil:NilClass
[error]: Stack trace:
    /Users/gregg/.rvm/gems/ruby-1.9.3-p194/gems/yard-0.8.2.1/lib/yard/tags/default_factory.rb:139:in `extract_types_and_name_from_text_unstripped'
    /Users/gregg/.rvm/gems/ruby-1.9.3-p194/gems/yard-0.8.2.1/lib/yard/tags/default_factory.rb:126:in `extract_types_and_name_from_text'
    /Users/gregg/.rvm/gems/ruby-1.9.3-p194/gems/yard-0.8.2.1/lib/yard/tags/default_factory.rb:76:in `parse_tag_with_types_name_and_default'
    /Users/gregg/.rvm/gems/ruby-1.9.3-p194/gems/yard-0.8.2.1/lib/yard/tags/default_factory.rb:88:in `parse_tag_with_options'
    /Users/gregg/.rvm/gems/ruby-1.9.3-p194/gems/yard-0.8.2.1/lib/yard/tags/library.rb:237:in `send_to_factory'
    /Users/gregg/.rvm/gems/ruby-1.9.3-p194/gems/yard-0.8.2.1/lib/yard/tags/library.rb:172:in `option_tag'

Files:           1
Modules:         1 (    1 undocumented)
Classes:         0 (    0 undocumented)
Constants:       0 (    0 undocumented)
Methods:         0 (    0 undocumented)
 0.00% documented
[yardtest] 

If you remove the @option, the problem goes away. My investigation made it look like there is an @option with a nil text element that is being processed when the module_function is hit.

@lsegal
Copy link
Owner

lsegal commented Jul 5, 2012

Duplicate of #563

@lsegal lsegal closed this as completed Jul 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants