Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions lib/rdoc/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RDoc::RDoc
##
# The current documentation store

attr_reader :store
attr_accessor :store

##
# Add +klass+ that can generate output after parsing
Expand Down Expand Up @@ -208,15 +208,6 @@ def setup_output_dir(dir, force)
last
end

##
# Sets the current documentation tree to +store+ and sets the store's rdoc
# driver to this instance.

def store= store
@store = store
@store.rdoc = self
end

##
# Update the flag file in an output directory.

Expand Down Expand Up @@ -450,8 +441,6 @@ def remove_unparseable files
# current directory, so make sure you're somewhere writable before invoking.

def document options
self.store = RDoc::Store.new

if RDoc::Options === options then
@options = options
else
Expand All @@ -460,6 +449,8 @@ def document options
end
@options.finish

@store = RDoc::Store.new(@options)

if @options.pipe then
handle_pipe
exit
Expand All @@ -469,12 +460,6 @@ def document options
@last_modified = setup_output_dir @options.op_dir, @options.force_update
end

@store.encoding = @options.encoding
@store.dry_run = @options.dry_run
@store.main = @options.main_page
@store.title = @options.title
@store.path = @options.op_dir

@start_time = Time.now

@store.load_cache
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/ri/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def initialize initial_options = {}
*options[:extra_doc_dirs]) do |path, type|
@doc_dirs << path

store = RDoc::RI::Store.new path, type
store = RDoc::RI::Store.new(RDoc::Options.new, path: path, type: type)
store.load_cache
@stores << store
end
Expand Down
8 changes: 1 addition & 7 deletions lib/rdoc/rubygems_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ def generate
@rdoc = new_rdoc
@rdoc.options = options

store = RDoc::Store.new
store.encoding = options.encoding
store.dry_run = options.dry_run
store.main = options.main_page
store.title = options.title

@rdoc.store = store
@rdoc.store = RDoc::Store.new(options)

say "Parsing documentation for #{@spec.full_name}"

Expand Down
14 changes: 7 additions & 7 deletions lib/rdoc/servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def do_GET req, res
show_documentation req, res
end
rescue WEBrick::HTTPStatus::NotFound => e
generator = generator_for RDoc::Store.new
generator = generator_for RDoc::Store.new(@options)

not_found generator, req, res, e.message
rescue WEBrick::HTTPStatus::Status
Expand Down Expand Up @@ -291,7 +291,7 @@ def if_modified_since req, res, path = nil
def installed_docs
extra_counter = 0
ri_paths.map do |path, type|
store = RDoc::Store.new path, type
store = RDoc::Store.new(@options, path: path, type: type)
exists = File.exist? store.cache_path

case type
Expand Down Expand Up @@ -420,15 +420,15 @@ def show_documentation req, res
def store_for source_name
case source_name
when 'home' then
RDoc::Store.new RDoc::RI::Paths.home_dir, :home
RDoc::Store.new(@options, path: RDoc::RI::Paths.home_dir, type: :home)
when 'ruby' then
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
RDoc::Store.new(@options, path: RDoc::RI::Paths.system_dir, type: :system)
when 'site' then
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
RDoc::Store.new(@options, path: RDoc::RI::Paths.site_dir, type: :site)
when /\Aextra-(\d+)\z/ then
index = $1.to_i - 1
ri_dir = installed_docs[index][4]
RDoc::Store.new ri_dir, :extra
RDoc::Store.new(@options, path: ri_dir, type: :extra)
else
ri_dir, type = ri_paths.find do |dir, dir_type|
next unless dir_type == :gem
Expand All @@ -439,7 +439,7 @@ def store_for source_name
raise WEBrick::HTTPStatus::NotFound,
"Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir

store = RDoc::Store.new ri_dir, type
store = RDoc::Store.new(@options, path: ri_dir, type: type)

return store if File.exist? store.cache_path

Expand Down
20 changes: 8 additions & 12 deletions lib/rdoc/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def message # :nodoc:

attr_accessor :path

attr_writer :rdoc
attr_reader :options

##
# Type of ri datastore this was loaded from. See RDoc::RI::Driver,
Expand All @@ -120,11 +120,11 @@ def message # :nodoc:
##
# Creates a new Store of +type+ that will load or save to +path+

def initialize path = nil, type = nil
@dry_run = false
@encoding = nil
@path = path
@rdoc = nil
def initialize(options, path: nil, type: nil)
@options = options
@dry_run = options.dry_run
@encoding = options.encoding
@path = path || options.op_dir
@type = type

@cache = {
Expand All @@ -135,10 +135,10 @@ def initialize path = nil, type = nil
:c_singleton_class_variables => {},
:encoding => @encoding,
:instance_methods => {},
:main => nil,
:main => options.main_page,
:modules => [],
:pages => [],
:title => nil,
:title => options.title,
}

@classes_hash = {}
Expand Down Expand Up @@ -977,10 +977,6 @@ def unique_modules
@unique_modules
end

def options
@rdoc&.options
end

private
def marshal_load(file)
File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
Expand Down
5 changes: 3 additions & 2 deletions test/rdoc/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ def setup

@pwd = Dir.pwd

@store = RDoc::Store.new
@options = RDoc::Options.new
@store = RDoc::Store.new(@options)

@rdoc = RDoc::RDoc.new
@rdoc.store = @store
@rdoc.options = RDoc::Options.new
@rdoc.options = @options

@rdoc.generator = Object.new

Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_markup_code_with_line_numbers
<span class="ruby-constant">B</span>
EXPECTED

@options.line_numbers = true
@c2_a.options.line_numbers = true
assert_equal <<-EXPECTED.chomp, @c2_a.markup_code
<span class="ruby-comment"># File xref_data.rb</span>
<span class="line-num">1</span> <span class="ruby-constant">A</span>
Expand Down
16 changes: 8 additions & 8 deletions test/rdoc/test_rdoc_class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def test_merge_constants
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1

store = RDoc::Store.new
store = RDoc::Store.new(RDoc::Options.new)
tl = store.add_file 'one.rb'
cm2 = tl.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
Expand Down Expand Up @@ -826,7 +826,7 @@ def test_merge_constants_version_0
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1

store = RDoc::Store.new
store = RDoc::Store.new(RDoc::Options.new)
tl = store.add_file 'one.rb'
cm2 = tl.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
Expand Down Expand Up @@ -859,7 +859,7 @@ def test_merge_extends
ext.record_location tl1

tl2 = @store.add_file 'two.rb'
tl2.store = RDoc::Store.new
tl2.store = RDoc::Store.new(RDoc::Options.new)

cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
Expand Down Expand Up @@ -895,7 +895,7 @@ def test_merge_includes
incl.record_location tl1

tl2 = @store.add_file 'two.rb'
tl2.store = RDoc::Store.new
tl2.store = RDoc::Store.new(RDoc::Options.new)

cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
Expand Down Expand Up @@ -931,7 +931,7 @@ def test_merge_includes_version_0
incl.record_location tl1

tl2 = @store.add_file 'one.rb'
tl2.store = RDoc::Store.new
tl2.store = RDoc::Store.new(RDoc::Options.new)

cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
Expand Down Expand Up @@ -1034,7 +1034,7 @@ def test_merge_sections
cm1.add_section 'section 2', comment('comment 2 a', tl1_1)
cm1.add_section 'section 4', comment('comment 4 a', tl1_1)

store2 = RDoc::Store.new
store2 = RDoc::Store.new(RDoc::Options.new)
tl2_1 = store2.add_file 'one.rb'
tl2_2 = store2.add_file 'two.rb'

Expand Down Expand Up @@ -1086,7 +1086,7 @@ def test_merge_sections_overlap
cm1.add_section 'section', comment('comment 1 a', tl1_1)
cm1.add_section 'section', comment('comment 3', tl1_3)

store2 = RDoc::Store.new
store2 = RDoc::Store.new(RDoc::Options.new)
tl2_1 = store2.add_file 'one.rb'
tl2_2 = store2.add_file 'two.rb'
tl2_3 = store2.add_file 'three.rb'
Expand Down Expand Up @@ -1382,7 +1382,7 @@ def test_update_aliases_reparent
end

def test_update_aliases_reparent_root
store = RDoc::Store.new
store = RDoc::Store.new(RDoc::Options.new)

top_level = store.add_file 'file.rb'

Expand Down
8 changes: 0 additions & 8 deletions test/rdoc/test_rdoc_code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,6 @@ def test_metadata
assert_equal 'not_rdoc', @co.metadata['markup']
end

def test_options
assert_kind_of RDoc::Options, @co.options

@co.store = @store

assert_same @options, @co.options
end

def test_parent_file_name
assert_equal '(unknown)', @co.parent_file_name
assert_equal 'xref_data.rb', @c1.parent_file_name
Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_add_module_alias
end

def test_add_module_alias_top_level
store = RDoc::Store.new
store = RDoc::Store.new(RDoc::Options.new)

top_level = store.add_file 'file.rb'

Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_generator_ri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_generate
assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
assert_file File.join(@tmpdir, 'Object', 'method%21-i.ri')

store = RDoc::RI::Store.new @tmpdir
store = RDoc::RI::Store.new(@options, path: @tmpdir)
store.load_cache

encoding = Encoding::UTF_8
Expand Down
3 changes: 1 addition & 2 deletions test/rdoc/test_rdoc_method_attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ def test_equals2

def test_pretty_print
temp_dir do |tmpdir|
s = RDoc::RI::Store.new tmpdir
s.rdoc = @rdoc
s = RDoc::RI::Store.new(RDoc::Options.new, path: tmpdir)

top_level = s.add_file 'file.rb'
meth_bang = RDoc::AnyMethod.new nil, 'method!'
Expand Down
17 changes: 9 additions & 8 deletions test/rdoc/test_rdoc_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def setup
super

@rdoc = RDoc::RDoc.new
@rdoc.options = RDoc::Options.new
@options = RDoc::Options.new
@rdoc.options = @options

@stats = RDoc::Stats.new @store, 0, 0
@rdoc.instance_variable_set :@stats, @stats
Expand Down Expand Up @@ -244,7 +245,7 @@ def test_normalized_file_list_with_skipping_tests_disabled
end

def test_parse_file
@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

temp_dir do |dir|
@rdoc.options.root = Pathname(Dir.pwd)
Expand All @@ -261,7 +262,7 @@ def test_parse_file
end

def test_parse_file_binary
@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

root = File.dirname __FILE__

Expand All @@ -278,7 +279,7 @@ def test_parse_file_binary
end

def test_parse_file_include_root
@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

test_path = File.expand_path('..', __FILE__)
top_level = nil
Expand All @@ -300,7 +301,7 @@ def test_parse_file_include_root
end

def test_parse_file_page_dir
@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

temp_dir do |dir|
FileUtils.mkdir 'pages'
Expand All @@ -321,7 +322,7 @@ def test_parse_file_page_dir
def test_parse_file_relative
pwd = Dir.pwd

@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

temp_dir do |dir|
@rdoc.options.root = Pathname(dir)
Expand All @@ -343,7 +344,7 @@ def test_parse_file_relative

def test_parse_file_encoding
@rdoc.options.encoding = Encoding::ISO_8859_1
@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

tf = Tempfile.open 'test.txt' do |io|
io.write 'hi'
Expand All @@ -361,7 +362,7 @@ def test_parse_file_forbidden
omit 'chmod not supported' if Gem.win_platform?
omit "assumes that euid is not root" if Process.euid == 0

@rdoc.store = RDoc::Store.new
@rdoc.store = RDoc::Store.new(@options)

tf = Tempfile.open 'test.txt' do |io|
io.write 'hi'
Expand Down
Loading
Loading