File: gauntlet_rdoc.rb

package info (click to toggle)
jruby 1.7.26-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 84,572 kB
  • sloc: ruby: 669,910; java: 253,056; xml: 35,152; ansic: 9,187; yacc: 7,267; cpp: 5,244; sh: 1,036; makefile: 345; jsp: 48; tcl: 40
file content (84 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
require 'rubygems'
Gem.load_yaml
require 'rdoc'
require 'gauntlet'
require 'fileutils'

##
# Allows for testing of RDoc against every gem

class RDoc::Gauntlet < Gauntlet

  def initialize # :nodoc:
    super

    @args = nil
    @type = nil
  end

  ##
  # Runs an RDoc generator for gem +name+

  def run name
    return if self.data.key? name

    dir = File.expand_path "~/.gauntlet/data/#{@type}/#{name}"
    FileUtils.rm_rf dir if File.exist? dir

    yaml = File.read 'gemspec'
    begin
      spec = Gem::Specification.from_yaml yaml
    rescue Psych::SyntaxError
      puts "bad spec #{name}"
      self.data[name] = false
      return
    end

    args = @args.dup
    args << '--op' << dir
    args.concat spec.rdoc_options
    args << spec.require_paths
    args << spec.extra_rdoc_files
    args = args.flatten.map { |a| a.to_s }
    args.delete '--quiet'

    puts "#{name} - rdoc #{args.join ' '}"

    self.dirty = true
    r = RDoc::RDoc.new

    begin
      r.document args
      self.data[name] = true
      puts 'passed'
      FileUtils.rm_rf dir
    rescue Interrupt, StandardError, RDoc::Error, SystemStackError => e
      puts "failed - (#{e.class}) #{e.message}"
      self.data[name] = false
    end
  rescue Gem::Exception
    puts "bad gem #{name}"
  ensure
    puts
  end

  ##
  # Runs the gauntlet with the given +type+ (rdoc or ri) and +filter+ for
  # which gems to run

  def run_the_gauntlet type = 'rdoc', filter = nil
    @type = type || 'rdoc'
    @args = type == 'rdoc' ? [] : %w[--ri]
    @data_file = "#{DATADIR}/#{@type}-data.yml"

    super filter
  end

end

type = ARGV.shift
filter = ARGV.shift
filter = /#{filter}/ if filter

RDoc::Gauntlet.new.run_the_gauntlet type, filter