~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/rdoc/generator/xml.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'rdoc/generator/html'
2
 
 
3
 
##
4
 
# Generate XML output as one big file
5
 
 
6
 
class RDoc::Generator::XML < RDoc::Generator::HTML
7
 
 
8
 
  ##
9
 
  # Standard generator factory
10
 
 
11
 
  def self.for(options)
12
 
    new(options)
13
 
  end
14
 
 
15
 
  def initialize(*args)
16
 
    super
17
 
  end
18
 
 
19
 
  ##
20
 
  # Build the initial indices and output objects
21
 
  # based on an array of TopLevel objects containing
22
 
  # the extracted information.
23
 
 
24
 
  def generate(info)
25
 
    @info       = info
26
 
    @files      = []
27
 
    @classes    = []
28
 
    @hyperlinks = {}
29
 
 
30
 
    build_indices
31
 
    generate_xml
32
 
  end
33
 
 
34
 
  ##
35
 
  # Generate:
36
 
  #
37
 
  # * a list of File objects for each TopLevel object.
38
 
  # * a list of Class objects for each first level
39
 
  #   class or module in the TopLevel objects
40
 
  # * a complete list of all hyperlinkable terms (file,
41
 
  #   class, module, and method names)
42
 
 
43
 
  def build_indices
44
 
    @info.each do |toplevel|
45
 
      @files << RDoc::Generator::File.new(toplevel, @options, RDoc::Generator::FILE_DIR)
46
 
    end
47
 
 
48
 
    RDoc::TopLevel.all_classes_and_modules.each do |cls|
49
 
      build_class_list(cls, @files[0], RDoc::Generator::CLASS_DIR)
50
 
    end
51
 
  end
52
 
 
53
 
  def build_class_list(from, html_file, class_dir)
54
 
    @classes << RDoc::Generator::Class.new(from, html_file, class_dir, @options)
55
 
    from.each_classmodule do |mod|
56
 
      build_class_list(mod, html_file, class_dir)
57
 
    end
58
 
  end
59
 
 
60
 
  ##
61
 
  # Generate all the HTML. For the one-file case, we generate
62
 
  # all the information in to one big hash
63
 
 
64
 
  def generate_xml
65
 
    values = {
66
 
      'charset' => @options.charset,
67
 
      'files'   => gen_into(@files),
68
 
      'classes' => gen_into(@classes)
69
 
    }
70
 
 
71
 
    template = RDoc::TemplatePage.new @template::ONE_PAGE
72
 
 
73
 
    if @options.op_name
74
 
      opfile = File.open(@options.op_name, "w")
75
 
    else
76
 
      opfile = $stdout
77
 
    end
78
 
    template.write_html_on(opfile, values)
79
 
  end
80
 
 
81
 
  def gen_into(list)
82
 
    res = []
83
 
    list.each do |item|
84
 
      res << item.value_hash
85
 
    end
86
 
    res
87
 
  end
88
 
 
89
 
  def gen_file_index
90
 
    gen_an_index(@files, 'Files')
91
 
  end
92
 
 
93
 
  def gen_class_index
94
 
    gen_an_index(@classes, 'Classes')
95
 
  end
96
 
 
97
 
  def gen_method_index
98
 
    gen_an_index(RDoc::Generator::HtmlMethod.all_methods, 'Methods')
99
 
  end
100
 
 
101
 
  def gen_an_index(collection, title)
102
 
    res = []
103
 
    collection.sort.each do |f|
104
 
      if f.document_self
105
 
        res << { "href" => f.path, "name" => f.index_name }
106
 
      end
107
 
    end
108
 
 
109
 
    return {
110
 
      "entries" => res,
111
 
      'list_title' => title,
112
 
      'index_url'  => main_url,
113
 
    }
114
 
  end
115
 
 
116
 
end
117