Skip to content

Context#modules and #classes error #105

Closed
trans opened this Issue Mar 7, 2012 · 4 comments

2 participants

@trans
trans commented Mar 7, 2012
>> gem 'rdoc', '>3'
>> require 'rdoc'
>> ri = ::RDoc::RI::Store.new('.rdoc')
=> #<RDoc::RI::Store:0x115f42c .rdoc []>
>> ri.load_cache
=> {:ancestors=>{"FishSampler::Fish"=>["Object"], "FishSampler::RedFish"=>["Object"], "FishSampler::BlueFish"=>["FishSampler::Fish"], "FishSampler::OldFish"=>["FishSampler::Fish"], "FishSampler::NewFish"=>["FishSampler::Fish"], "FishSampler::Shark"=>["FishSampler::Fish", "FishSampler::ManEater"], "Numeric"=>["Numeric::Multipliers", "Object"]}, :attributes=>{"FishSampler::Fish"=>["attr_accessor properties", "attr_accessor qualities"], "FishSampler::RedFish"=>["attr_accessor qualities"], "FishSampler::BlueFish"=>["attr_accessor qualities"], "FishSampler::OldFish"=>["attr_accessor qualities"], "FishSampler::NewFish"=>["attr_accessor qualities"], "FishSampler"=>["attr_reader fishy_active"]}, :class_methods=>{"FishSampler::Fish"=>["new"], "FishSampler"=>["fishy_active"]}, :encoding=>#<Encoding:UTF-8>, :instance_methods=>{"FishSampler::Fish"=>["initialize_qualities", "properties", "qualities"], "FishSampler::RedFish"=>["initialize_qualities", "qualities"], "FishSampler::BlueFish"=>["initialize_qualities", "qualities"], "FishSampler::OldFish"=>["initialize_qualities", "qualities"], "FishSampler::NewFish"=>["initialize_qualities", "qualities"], "FishSampler::Shark"=>["initialize_qualities"], "FishSampler::ManEater"=>["initialize_qualities"], "Numeric::Multipliers"=>["atto", "centi", "deci", "deka", "exa", "exbi", "femto", "gibi", "giga", "hecto", "kibi", "kilo", "mebi", "mega", "micro", "milli", "nano", "pebi", "peta", "pico", "tebi", "tera"]}, :modules=>["FishSampler", "FishSampler::BlueFish", "FishSampler::Fish", "FishSampler::ManEater", "FishSampler::NewFish", "FishSampler::OldFish", "FishSampler::RedFish", "FishSampler::Shark", "Numeric", "Numeric::Multipliers"]}
>> k = ri.load_class(ri.modules.first)
=> #<RDoc::NormalModule:0x1248a14 module FishSampler includes: [] attributes: [#<RDoc::Attr:0x144b000 FishSampler::fishy_active R (private)>] methods: [] aliases: []>
>> k.modules
NoMethodError: undefined method `values' for nil:NilClass
    from /home/trans/.rbfu/rubies/1.9.3-p0/lib/ruby/gems/gems/rdoc-3.12/lib/rdoc/context.rb:936:in `modules'
    from (irb):7
    from /home/trans/.rbfu/rubies/1.9.3-p0/bin/irb:12:in `<main>'

Since there are no modules in this case, I would expect it to return an empty array (preferably). But since there are none, the @classes attribute in RDoc::Context is nil instead of a Hash, so when #values is called against it, this error occurs.

@drbrain
RDoc member
drbrain commented Mar 7, 2012

What is the source used to generate the ri data store?

@trans
trans commented Mar 7, 2012

I've been using this sample project: https://github.com/rubyworks/shomen/tree/master/work/sandbox

I generate with:

$ rdoc --ri --op .rdoc lib README

Note, I've also noticed a few other issues, for example, #line seems to always returns nil and constants have no value and classes/modules don't have #file or #in_files. I was going to report these once I double checked them, but I'll just mention them presently. If you'd rather I file additional issues let me know.

@drbrain
RDoc member
drbrain commented Nov 21, 2012
@drbrain
RDoc member
drbrain commented Nov 21, 2012

This has been fixed in RDoc 4, but RDoc::Store#modules no longer exists. Use #module_names instead.

@drbrain drbrain closed this Nov 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.