lib/yard/cli/yardoc.rb in yard-0.9.9 vs lib/yard/cli/yardoc.rb in yard-0.9.10
- old
+ new
@@ -198,10 +198,13 @@
# @return [Boolean] whether markup option was specified
# @since 0.7.0
attr_accessor :has_markup
+ # @return [Boolean] whether yard exits with error status code if a warning occurs
+ attr_accessor :fail_on_warning
+
# Creates a new instance of the commandline utility
def initialize
super
@options = YardocOptions.new
@options.reset_defaults
@@ -216,10 +219,11 @@
@generate = true
@statistics = true
@list = false
@save_yardoc = true
@has_markup = false
+ @fail_on_warning = false
if defined?(::Encoding) && ::Encoding.respond_to?(:default_external=)
utf8 = ::Encoding.find('utf-8')
::Encoding.default_external = utf8 unless ::Encoding.default_external == utf8
@@ -271,10 +275,12 @@
log.enter_level(Logger::ERROR) do
Stats.new(false).run(*args)
end
end
+ abort if fail_on_warning && log.warned
+
true
ensure
log.show_progress = false
end
@@ -552,9 +558,13 @@
self.save_yardoc = false
end
opts.on('--exclude REGEXP', 'Ignores a file if it matches path match (regexp)') do |path|
excluded << path
+ end
+
+ opts.on('--fail-on-warning', 'Exit with error status code if a warning occurs') do
+ self.fail_on_warning = true
end
end
# Adds output options
def output_options(opts)