panthomakos / guard-yard

Guard gem for YARD.
MIT License
33 stars 13 forks source link

NoMethodError: undefined method `namespace' for nil:NilClass (from YARD) #20

Closed paddor closed 8 years ago

paddor commented 8 years ago

Consider the following Guardfile:

guard 'yard' do
  watch(%r{lib/.+\.rb})
end

When I run:

rm -rf .yardoc doc
bundle exec guard

I get:

20:45:48 - INFO - [Guard::Yard] Documentation missing.
20:45:48 - INFO - [Guard::Yard] Generating all documentation.
Files:          36
Modules:         7 (    5 undocumented)
Classes:        67 (   26 undocumented)
Constants:      32 (   30 undocumented)
Methods:       791 (   46 undocumented)
 88.07% documented
20:45:56 - INFO - [Guard::Yard] Documentation has been generated.
20:45:56 - INFO - [Guard::Yard] Stopping YARD Documentation Server.
20:45:56 - INFO - [Guard::Yard] Starting YARD Documentation Server.
[2015-12-03 20:45:56] INFO  WEBrick 1.3.1
[2015-12-03 20:45:56] INFO  ruby 2.2.3 (2015-08-18) [x86_64-darwin14]
[2015-12-03 20:45:56] INFO  WEBrick::HTTPServer#start: pid=10327 port=8808
20:45:57 - INFO - [Guard::Yard] Server successfully started.
20:45:57 - INFO - Guard is now watching at '/Users/paddor/src/ruby/cztop'

So far so good. When I change a file, I get:

20:46:00 - INFO - [Guard::Yard] Detected changes in lib/cztop/frame.rb.
20:46:00 - ERROR - Guard::Yard failed to achieve its <run_on_changes>, exception was:
> [#] NoMethodError: undefined method `namespace' for nil:NilClass
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/serializers/file_system_serializer.rb:57:in `serialized_path'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/templates/helpers/html_helper.rb:359:in `url_for_file'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/templates/helpers/html_helper.rb:376:in `url_for_list'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/templates/default/fulldoc/html/setup.rb:165:in `generate_list_contents'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/templates/default/fulldoc/html/setup.rb:151:in `generate_class_list'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/templates/default/fulldoc/html/setup.rb:125:in `block in generate_assets'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/templates/default/fulldoc/html/setup.rb:122:in `each'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/templates/default/fulldoc/html/setup.rb:122:in `generate_assets'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/templates/default/fulldoc/html/setup.rb:7:in `init'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/templates/template.rb:185:in `initialize'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/templates/template.rb:130:in `new'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/templates/template.rb:135:in `run'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/yard-0.8.7.6/lib/yard/templates/engine.rb:104:in `generate'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-yard-2.1.4/lib/guard/yard.rb:65:in `document'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-yard-2.1.4/lib/guard/yard.rb:38:in `block in run_on_changes'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-yard-2.1.4/lib/guard/yard.rb:38:in `each'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-yard-2.1.4/lib/guard/yard.rb:38:in `run_on_changes'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:82:in `block in _supervise'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:79:in `catch'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:79:in `_supervise'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:61:in `block (3 levels) in run_on_changes'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:56:in `each'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:56:in `block (2 levels) in run_on_changes'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:119:in `block (2 levels) in _run_group_plugins'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:117:in `each'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:117:in `block in _run_group_plugins'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:116:in `catch'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:116:in `_run_group_plugins'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:54:in `block in run_on_changes'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:53:in `each'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/runner.rb:53:in `run_on_changes'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/internals/queue.rb:23:in `process'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/commander.rb:43:in `start'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/cli.rb:122:in `start'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:32:in `execute'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#] /Users/paddor/.gem/ruby/2.2.3/gems/guard-2.13.0/bin/_guard-core:11:in `<main>'
20:46:00 - INFO - Guard::Yard has just been fired
[1] guard(main)>

Now this doesn't happen when I just run yard.

Also, often times, this yard server keeps running even if I quit the guard shell. I don't see the point of yard server. How to disable it?

Or is the only sane way to do this like this?

guard :shell do
  watch(%r{lib/.+\.rb}) do |m|
    # regenreate documentation
    puts "Regenerating documentation ..."
    system("yard")
  end
end

Thanks for your help.

panthomakos commented 8 years ago

Can you provide some details about the lib/cztop/frame.rb file? I cannot reproduce this issue with the following file:

# lib/cztop/frame.rb

module Cztop
  class Frame
  end
end

The exception seems to be coming from w/in YARD, so my guess is that guard-yard is either passing something invalid to yard (which yard just ignores when run by itself).

paddor commented 8 years ago

Thanks for the feedback. I just re-enabled it in my Guardfile, started guard, made a change in some files (including lib/cztop/frame.rb), but can't reproduce the error...

Will keep using this solution for a while and see if the error occurs again. Well, I could check out an older version of the project to see if that'll produce the "desired" result again.

paddor commented 8 years ago

Nope, can't reproduce the error. Even with an old version from that time. I'll close this issue for now. :-)

panthomakos commented 8 years ago

@paddor Keep me up to date! Maybe some weird one-time issue w/ the yard server.