lib/yard/cli/yardoc.rb in yard-0.6.1 vs lib/yard/cli/yardoc.rb in yard-0.6.2

- old
+ new

@@ -195,10 +195,13 @@ # @param [Array<String>] args the list of arguments # @return [void] def run(*args) parse_arguments(*args) + # fail early if markup provider is not found + return if generate && !verify_markup_options + checksums = nil if use_cache Registry.load checksums = Registry.checksums.dup end @@ -292,10 +295,20 @@ end end Templates::Engine.generate(objects, options) end + # Verifies that the markup options are valid before parsing any code. + # Failing early is better than failing late. + # + # @return (see YARD::Templates::Helpers::MarkupHelper#load_markup_provider) + def verify_markup_options + obj = Struct.new(:options).new(options) + obj.extend(Templates::Helpers::MarkupHelper) + obj.load_markup_provider + end + # Copies any assets to the output directory # @return [void] # @since 0.6.0 def copy_assets return unless options[:serializer] @@ -477,11 +490,11 @@ visibilities.push(:private) end opts.on('--no-private', "Hide objects with @private tag") do options[:verifier].add_expressions '!object.tag(:private) && - (object.namespace.type == :proxy || !object.namespace.tag(:private))' + (object.namespace.is_a?(CodeObjects::Proxy) || !object.namespace.tag(:private))' end opts.on('--no-highlight', "Don't highlight code blocks in output.") do options[:no_highlight] = true end @@ -493,10 +506,11 @@ opts.on('--hide-void-return', "Hides return types specified as 'void'. Default is shown.") do options[:hide_void_return] = true end opts.on('--query QUERY', "Only show objects that match a specific query") do |query| + next if YARD::Config.options[:safe_mode] options[:verifier].add_expressions(query.taint) end opts.on('--title TITLE', 'Add a specific title to HTML documents') do |title| options[:title] = title @@ -553,9 +567,10 @@ options[:template] = template.to_sym end opts.on('-p', '--template-path PATH', 'The template path to look for templates in. (used with -t).') do |path| + next if YARD::Config.options[:safe_mode] YARD::Templates::Engine.register_template_path(path) end opts.on('-f', '--format FORMAT', 'The output format for the template. (defaults to html)') do |format|