Sha256: a8ccfb5a753e95894525f78293d60160bb153b93547e1b9441c7e44030308898
Contents?: true
Size: 1.78 KB
Versions: 4
Compression:
Stored size: 1.78 KB
Contents
require 'puppet-strings' # Implements the strings:generate task. namespace :strings do desc 'Generate Puppet documentation with YARD.' task :generate, [:patterns, :debug, :backtrace, :markup, :json, :markdown, :yard_args] do |t, args| patterns = args[:patterns] patterns = patterns.split if patterns patterns ||= PuppetStrings::DEFAULT_SEARCH_PATTERNS options = { debug: args[:debug] == 'true', backtrace: args[:backtrace] == 'true', markup: args[:markup] || 'markdown', } raise("Error: Both JSON and Markdown output have been selected. Please select one.") if args[:json] == 'true' && args[:markdown] == 'true' # rubocop:disable Style/PreferredHashMethods # Because of Ruby, true and false from the args are both strings and both true. Here, # when the arg is set to false (or empty), set it to real false, else real true. Then, # if the arg is set simply to 'true', assume default behavior is expected and set the path # to nil to elicit that, else set to the path given. # @param [Hash] args from the Rake task cli # @param [Hash] options to send to the generate function # @param [Symbol] possible format option # @return nil def parse_format_option(args, options, format) if args.has_key? format options[format] = args[format] == 'false' || args[format].empty? ? false : true if options[format] options[:path] = args[format] == 'true' ? nil : args[format] end end end [:json,:markdown].each { |format| parse_format_option(args, options, format) } warn('yard_args behavior is a little dodgy, use at your own risk') if args[:yard_args] options[:yard_args] = args[:yard_args].split if args.has_key? :yard_args PuppetStrings.generate(patterns, options) end end
Version data entries
4 entries across 4 versions & 1 rubygems