lib/yard/cli/yardoc.rb in yard-0.7.1 vs lib/yard/cli/yardoc.rb in yard-0.7.2
- old
+ new
@@ -184,12 +184,12 @@
@statistics = true
@list = false
@save_yardoc = true
@has_markup = false
- if defined?(Encoding)
- Encoding.default_external, Encoding.default_internal = 'utf-8', 'utf-8'
+ if defined?(::Encoding) && ::Encoding.respond_to?(:default_external=)
+ ::Encoding.default_external, ::Encoding.default_internal = 'utf-8', 'utf-8'
end
end
def description
"Generates documentation"
@@ -246,19 +246,17 @@
# Last minute modifications
self.files = ['{lib,app}/**/*.rb', 'ext/**/*.c'] if self.files.empty?
self.files.delete_if {|x| x =~ /\A\s*\Z/ } # remove empty ones
readme = Dir.glob('README*').first
+ readme ||= Dir.glob(files.first).first if options[:onefile]
options[:readme] ||= CodeObjects::ExtraFileObject.new(readme) if readme
- if options[:onefile]
- options[:files] << options[:readme] if options[:readme]
- readme = Dir.glob(files.first).first
- options[:readme] = CodeObjects::ExtraFileObject.new(readme) if readme
- end
+ options[:files].unshift(options[:readme]).uniq! if options[:readme]
+
Tags::Library.visible_tags -= hidden_tags
add_visibility_verifier
-
+
if generate && !verify_markup_options
false
else
true
end
@@ -353,10 +351,11 @@
end
# Parses out the yardopts/document options
def parse_yardopts_options(*args)
opts = OptionParser.new
+ opts.base.long.clear # HACK: why are --help and --version defined?
yardopts_options(opts)
begin
opts.parse(args)
rescue OptionParser::ParseError => err
idx = args.index(err.args.first)
@@ -428,10 +427,11 @@
end
# @since 0.6.0
def add_tag(tag_data, factory_method = nil)
tag, title = *tag_data.split(':')
+ title ||= tag.capitalize
Tags::Library.define_tag(title, tag.to_sym, factory_method)
Tags::Library.visible_tags |= [tag.to_sym]
end
# Parses commandline options.
@@ -619,10 +619,12 @@
end
opts.on('--charset ENC', 'Character set to use when parsing files ',
' (default is system locale)') do |encoding|
begin
- Encoding.default_external, Encoding.default_internal = encoding, encoding
+ if defined?(Encoding) && Encoding.respond_to?(:default_external=)
+ Encoding.default_external, Encoding.default_internal = encoding, encoding
+ end
rescue ArgumentError => e
raise OptionParser::InvalidOption, e
end
end