Class: RDoc::RDoc
- Inherits:
-
Object
- Object
- RDoc::RDoc
- Defined in:
- lib/rdoc/rdoc.rb
Overview
Encapsulate the production of rdoc documentation. Basically you can use this as you would invoke rdoc from the command line:
rdoc = RDoc::RDoc.new
rdoc.document(args)
where args is an array of strings, each corresponding to an argument you'd give rdoc on the command line. See rdoc/rdoc.rb for details.
Defined Under Namespace
Classes: Generator
Constant Summary collapse
- GENERATORS =
{}
Class Method Summary collapse
-
.usage(*args) ⇒ Object
Display usage information from the comment at the top of the file.
-
.usage_no_exit(*args) ⇒ Object
Display usage.
Instance Method Summary collapse
-
#document(argv) ⇒ Object
#################################################################.
Class Method Details
.usage(*args) ⇒ Object
Display usage information from the comment at the top of the file. String arguments identify specific sections of the comment to display. An optional integer first argument specifies the exit status (defaults to 0)
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rdoc/usage.rb', line 81 def RDoc.usage(*args) exit_code = 0 if args.size > 0 status = args[0] if status.respond_to?(:to_int) exit_code = status.to_int args.shift end end # display the usage and exit with the given code usage_no_exit(*args) exit(exit_code) end |
.usage_no_exit(*args) ⇒ Object
Display usage
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/rdoc/usage.rb', line 98 def RDoc.usage_no_exit(*args) main_program_file = caller[-1].sub(/:\d+$/, '') comment = File.open(main_program_file) do |file| find_comment(file) end comment = comment.gsub(/^\s*#/, '') markup = SM::SimpleMarkup.new flow_convertor = SM::ToFlow.new flow = markup.convert(comment, flow_convertor) format = "plain" unless args.empty? flow = extract_sections(flow, args) end = RI::Options.instance if args = ENV["RI"] .parse(args.split) end formatter = .formatter.new(, "") formatter.display_flow(flow) end |
Instance Method Details
#document(argv) ⇒ Object
#################################################################
Format up one or more files according to the given arguments. For simplicity, argv is an array of strings, equivalent to the strings that would be passed on the command line. (This isn't a coincidence, as we do pass in ARGV when running interactively). For a list of options, see rdoc/rdoc.rb. By default, output will be stored in a directory called doc
below the current directory, so make sure you're somewhere writable before invoking.
Throws: RDocError on error
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/rdoc/rdoc.rb', line 249 def document(argv) TopLevel::reset @stats = Stats.new = Options.instance .parse(argv, GENERATORS) @last_created = nil unless .all_one_file @last_created = setup_output_dir(.op_dir, .force_update) end start_time = Time.now file_info = parse_files() if file_info.empty? $stderr.puts "\nNo newer files." unless .quiet else gen = .generator $stderr.puts "\nGenerating #{gen.key.upcase}..." unless .quiet require gen.file_name gen_class = Generators.const_get(gen.class_name) gen = gen_class.for() pwd = Dir.pwd Dir.chdir(.op_dir) unless .all_one_file begin Diagram.new(file_info, ).draw if .diagram gen.generate(file_info) update_output_dir(".", start_time) ensure Dir.chdir(pwd) end end unless .quiet puts @stats.print end end |