mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
[ruby/rdoc] Move RDoc::RDoc#load_options to RDoc::RDoc.load_options
ac85e01756
This commit is contained in:
parent
10ebf87428
commit
cf2faf2e33
4 changed files with 89 additions and 89 deletions
|
@ -1282,4 +1282,33 @@ Usage: #{opt.program_name} [options] [names...]
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Loads options from .rdoc_options if the file exists, otherwise creates a
|
||||
# new RDoc::Options instance.
|
||||
|
||||
def self.load_options
|
||||
options_file = File.expand_path '.rdoc_options'
|
||||
return RDoc::Options.new unless File.exist? options_file
|
||||
|
||||
RDoc.load_yaml
|
||||
|
||||
begin
|
||||
options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
|
||||
rescue Psych::SyntaxError
|
||||
raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
|
||||
end
|
||||
|
||||
return RDoc::Options.new unless options # Allow empty file.
|
||||
|
||||
raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
|
||||
RDoc::Options === options or Hash === options
|
||||
|
||||
if Hash === options
|
||||
# Override the default values with the contents of YAML file.
|
||||
options = RDoc::Options.new options
|
||||
end
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ require 'time'
|
|||
# is:
|
||||
#
|
||||
# rdoc = RDoc::RDoc.new
|
||||
# options = rdoc.load_options # returns an RDoc::Options instance
|
||||
# options = RDoc::Options.load_options # returns an RDoc::Options instance
|
||||
# # set extra options
|
||||
# rdoc.document options
|
||||
#
|
||||
|
@ -151,35 +151,6 @@ class RDoc::RDoc
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Loads options from .rdoc_options if the file exists, otherwise creates a
|
||||
# new RDoc::Options instance.
|
||||
|
||||
def load_options
|
||||
options_file = File.expand_path '.rdoc_options'
|
||||
return RDoc::Options.new unless File.exist? options_file
|
||||
|
||||
RDoc.load_yaml
|
||||
|
||||
begin
|
||||
options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
|
||||
rescue Psych::SyntaxError
|
||||
raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
|
||||
end
|
||||
|
||||
return RDoc::Options.new unless options # Allow empty file.
|
||||
|
||||
raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
|
||||
RDoc::Options === options or Hash === options
|
||||
|
||||
if Hash === options
|
||||
# Override the default values with the contents of YAML file.
|
||||
options = RDoc::Options.new options
|
||||
end
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
##
|
||||
# Create an output dir if it doesn't exist. If it does exist, but doesn't
|
||||
# contain the flag file <tt>created.rid</tt> then we refuse to use it, as
|
||||
|
@ -471,7 +442,7 @@ The internal error was:
|
|||
@options = options
|
||||
@options.finish
|
||||
else
|
||||
@options = load_options
|
||||
@options = RDoc::Options.load_options
|
||||
@options.parse options
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue