lib/yard/cli/yardoc.rb in yard-0.2.3 vs lib/yard/cli/yardoc.rb in yard-0.2.3.2

- old
+ new

@@ -14,18 +14,19 @@ def initialize @options = SymbolHash[ :format => :html, :template => :default, :serializer => YARD::Serializers::FileSystemSerializer.new, + :files => [], :verifier => lambda do |gen, obj| return false if gen.respond_to?(:visibility) && !visibilities.include?(gen.visibility) end ] + @files = [] @visibilities = [:public] @reload = true @generate = true - @files = ['lib/**/*.rb'] @options_file = DEFAULT_YARDOPTS_FILE end def run(*args) args += support_rdoc_document_file! @@ -54,18 +55,49 @@ IO.read(".document").split(/\s+/) rescue Errno::ENOENT [] end + def add_extra_files(*files) + files.map! {|f| f.include?("*") ? Dir.glob(f) : f }.flatten! + files.each do |file| + raise Errno::ENOENT, "Could not find extra file: #{file}" unless File.file?(file) + options[:files] << file + end + end + + def parse_files(*files) + self.files = [] + seen_extra_files_marker = false + + files.each do |file| + if file == "-" + seen_extra_files_marker = true + next + end + + if seen_extra_files_marker + add_extra_files(file) + else + self.files << file + end + end + end + def optparse(*args) serialopts = SymbolHash.new opts = OptionParser.new - opts.banner = "Usage: yardoc [options] [source files]" + opts.banner = "Usage: yardoc [options] [source_files [- extra_files]]" opts.separator "(if a list of source files is omitted, lib/**/*.rb is used.)" opts.separator "" + opts.separator "Example: yardoc -o documentation/ - FAQ LICENSE" + opts.separator " The above example outputs documentation for files in" + opts.separator " lib/**/*.rb to documentation/ including the extra files" + opts.separator " FAQ and LICENSE." + opts.separator "" opts.separator "A base set of options can be specified by adding a .yardopts" opts.separator "file to your base path containing all extra options separated" opts.separator "by whitespace." opts.separator "" opts.separator "General Options:" @@ -111,22 +143,22 @@ end opts.on('--no-highlight', "Don't highlight code in docs as Ruby.") do options[:no_highlight] = true end + + opts.on('--title TITLE', 'Add a specific title to HTML documents') do |title| + options[:title] = title + end opts.on('-r', '--readme FILE', 'The readme file used as the title page of documentation.') do |readme| raise Errno::ENOENT, readme unless File.file?(readme) options[:readme] = readme end opts.on('--files FILE1,FILE2,...', 'Any extra comma separated static files to be included (eg. FAQ)') do |files| - options[:files] = [] - files.split(",").each do |file| - raise Errno::ENOENT, file unless File.file?(file) - options[:files] << file - end + add_extra_files *files.split(",") end opts.on('-m', '--markup MARKUP', 'Markup style used in documentation, like textile, markdown or rdoc. (defaults to rdoc)') do |markup| options[:markup] = markup.to_sym @@ -172,11 +204,11 @@ STDERR << "\n" << opts exit end # Last minute modifications - self.files = args unless args.empty? - self.reload = false if self.files.empty? + parse_files(*args) unless args.empty? + self.files = ['lib/**/*.rb'] if self.files.empty? self.visibilities.uniq! options[:serializer] ||= Serializers::FileSystemSerializer.new(serialopts) end end end