sfcgeorge / yard-contracts

YARD Plugin for Automatic Param Docs from Contracts.
MIT License
26 stars 3 forks source link

yard-contracts stopped working all of a sudden #11

Closed NobbZ closed 9 years ago

NobbZ commented 9 years ago

All of a sudden yard-contracts stopped working with the following stacktrace, even without loading it explicitely:

$ yard config
[error]: Invalid configuration file, using default options.
[error]: TypeError: InspectWrapper is not a class
[error]: Stack trace:
    /home/nobbz/.rvm/gems/ruby-2.2.0/gems/yard-contracts-0.1.4/lib/yard-contracts/formatters.rb:40:in `<module:Formatters>'
    /home/nobbz/.rvm/gems/ruby-2.2.0/gems/yard-contracts-0.1.4/lib/yard-contracts/formatters.rb:5:in `<module:Contracts>'
    /home/nobbz/.rvm/gems/ruby-2.2.0/gems/yard-contracts-0.1.4/lib/yard-contracts/formatters.rb:3:in `<top (required)>'
    /home/nobbz/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    /home/nobbz/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    /home/nobbz/.rvm/gems/ruby-2.2.0/gems/yard-contracts-0.1.4/lib/yard-contracts/contract_handler.rb:9:in `<top (required)>'

:load_plugins: false
:ignored_plugins: []
:autoload_plugins: []
:safe_mode: false

The actuall content of ~/.yard/config is:

--- !ruby/hash:SymbolHash
:load_plugins: true
:ignored_plugins: []
:autoload_plugins: []
:safe_mode: false

If I change :load_plugins to false I don't get an error anymore, but of course yard-contracts doesn't work then ;)

The way I use yard and yard-contracts in my project is:

# Rakefile
Rake::Task["doc:app"].clear

namespace :doc do
  desc "Generate documentation for the app"
  YARD::Rake::YardocTask.new(:app) do |t|
    t.files += ['app/**/*.rb',
                'lib/**/*.rb']
    t.files += ['-', 'README.md',
                     'LICENSE.md']
    t.options += ['--type-name-tag', 'formparam:Formular Parameters',
                  '--markup-provider=redcarpet',
                  '--markup', 'markdown',
                  '--plugin', 'contracts']
  end
end

And then simply run rake doc:app, but this problem does occur even outside of the project. The yard config that produced the output above was run from $HOME.

If I uninstall yard-contracts yard config shows the actual content of ~/.yard/config, also this problem does occur independently of which version of yard-contracts is installed, I tried "0.1.2" and "0.1.4" which both worked yesterday.

All what changed was, that I tried to use yard-doctest, but I removed it completely because it wasn't able to test my project because of the use of selfdefined tags and the presence of Contracts ;)

NobbZ commented 9 years ago

I went through my commit log and found that contracts-gem went from 0.7 to 0.8 in some of my expermints last night. After downgrading it worked again.

So the issue is: yard-contracts does not work with current version of contracts-gem

sfcgeorge commented 9 years ago

Yep, this was silly on my part. I made some improvements to Contracts for yard-contracts to make use of. While waiting for them to be merged I duplicated them in yard-contracts. But then they diverged and became incompatible so when a new Contracts was released with my changes it broke yard-contracts. I've just removed the duplicated stuff from yard-contracts so it's all working again and I've pushed a new version to Rubygems.

Contracts 0.8 and yard-contracts 0.1.5 should now work together so I'm closing the issue. Let me know if you have any other problems.

NobbZ commented 9 years ago

Using 0.1.5 does work with contracts 0.8, thank you for the quick response!