lib/yard/cli/yardoc.rb in yard-0.5.2 vs lib/yard/cli/yardoc.rb in yard-0.5.3

- old
+ new

@@ -12,15 +12,22 @@ attr_reader :options # @return [Array<String>] list of Ruby source files to process attr_accessor :files + # @return [Array<String>] list of excluded paths (regexp matches) + attr_accessor :excluded + # @return [Boolean] whether to use the existing yardoc db if the # .yardoc already exists. Also makes use of file checksums to # parse only changed files. attr_accessor :use_cache + # @return [Boolean] whether to generate output incrementally ( + # implies use_cache and generate) + attr_accessor :incremental + # @return [Boolean] whether to generate output attr_accessor :generate # The options file name (defaults to {DEFAULT_YARDOPTS_FILE}) # @return [String] the filename to load extra options from @@ -30,10 +37,11 @@ # @see #run def self.run(*args) new.run(*args) end # Creates a new instance of the commandline utility def initialize + super @options = SymbolHash.new(false) @options.update( :format => :html, :template => :default, :markup => :rdoc, @@ -43,13 +51,15 @@ :no_highlight => false, :files => [], :visibilities => [:public], :verifier => nil ) + @excluded = [] @files = [] @use_cache = false @generate = true + @incremental = false @options_file = DEFAULT_YARDOPTS_FILE end # Runs the commandline utility, parsing arguments and generating # output if set. @@ -63,17 +73,18 @@ if use_cache Registry.load checksums = Registry.checksums.dup end - YARD.parse(files) + YARD.parse(files, excluded) Registry.save(use_cache) if generate - if use_cache + if incremental generate_with_cache(checksums) else + Registry.load_all if use_cache Templates::Engine.generate(all_objects, options) end end true @@ -182,10 +193,11 @@ end # Parses commandline options. # @param [Array<String>] args each tokenized argument def optparse(*args) + excluded = [] query_expressions = [] do_build_gems, do_rebuild_gems = false, false serialopts = SymbolHash.new opts = OptionParser.new @@ -221,9 +233,19 @@ opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file| if !require(file.gsub(/\.rb$/, '')) log.error "The file `#{file}' was already loaded, perhaps you need to specify the absolute path to avoid name collisions." exit end + end + + opts.on('--incremental', 'Generates output for changed files only (implies -c)') do + self.incremental = true + self.generate = true + self.use_cache = true + end + + opts.on('--exclude REGEXP', 'Ignores a file if it matches path match (regexp)') do |path| + self.excluded << path end opts.on('--legacy', 'Use old style parser and handlers. Unavailable under Ruby 1.8.x') do YARD::Parser::SourceParser.parser_type = :ruby18 end