2 require 'rdoc/generator'
3 require 'rdoc/markup/to_texinfo'
6 RDoc::GENERATORS['texinfo'] = RDoc::Generator.new("rdoc/generator/texinfo",
10 # This generates Texinfo files for viewing with GNU Info or Emacs
11 # from RDoc extracted from Ruby source files.
13 # What should the .info file be named by default?
14 DEFAULT_INFO_FILENAME = 'rdoc.info'
16 include Generator::MarkUp
19 def initialize(options)
21 @options.inline_source = true
22 @options.op_name ||= 'rdoc.texinfo'
23 @options.formatter = ::RDoc::Markup::ToTexInfo.new
26 # Generate the +texinfo+ files
27 def generate(toplevels)
28 @toplevels = toplevels
29 @files, @classes = ::RDoc::Generator::Context.build_indicies(@toplevels,
32 (@files + @classes).each { |x| x.value_hash }
34 open(@options.op_name, 'w') do |f|
35 f.puts TexinfoTemplate.new('files' => @files,
36 'classes' => @classes,
37 'filename' => @options.op_name.gsub(/texinfo/, 'info'),
38 'title' => @options.title).render
40 # TODO: create info files and install?
44 # Factory? We don't need no stinkin' factory!
45 alias_method :for, :new
49 # Basically just a wrapper around ERB.
50 # Should probably use RDoc::TemplatePage instead
52 BASE_DIR = ::File.expand_path(::File.dirname(__FILE__)) # have to calculate this when the file's loaded.
54 def initialize(values, file = 'texinfo.erb')
55 @v, @file = [values, file]
59 ::File.read(::File.join(BASE_DIR, 'texinfo', @file))
64 ERB.new(template).result binding
67 def href(location, text)
68 text # TODO: how does texinfo do hyperlinks?
71 def target(name, text)
72 text # TODO: how do hyperlink targets work?
75 # TODO: this is probably implemented elsewhere?
76 def method_prefix(section)
80 }[section['category']]