rdoc 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +14 -0
- data/History.txt +27 -0
- data/Manifest.txt +29 -9
- data/Rakefile +2 -0
- data/bin/rdoc +13 -2
- data/lib/rdoc.rb +11 -3
- data/lib/rdoc/alias.rb +54 -0
- data/lib/rdoc/anon_class.rb +10 -0
- data/lib/rdoc/any_method.rb +190 -0
- data/lib/rdoc/attr.rb +79 -0
- data/lib/rdoc/cache.rb +11 -2
- data/lib/rdoc/class_module.rb +87 -0
- data/lib/rdoc/code_object.rb +152 -0
- data/lib/rdoc/code_objects.rb +18 -1118
- data/lib/rdoc/constant.rb +36 -0
- data/lib/rdoc/context.rb +712 -0
- data/lib/rdoc/diagram.rb +8 -8
- data/lib/rdoc/generator.rb +3 -1140
- data/lib/rdoc/generator/darkfish.rb +107 -133
- data/lib/rdoc/generator/markup.rb +194 -0
- data/lib/rdoc/generator/ri.rb +4 -2
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +92 -113
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +33 -35
- data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -15
- data/lib/rdoc/ghost_method.rb +8 -0
- data/lib/rdoc/include.rb +39 -0
- data/lib/rdoc/markup/attribute_manager.rb +46 -0
- data/lib/rdoc/markup/formatter.rb +11 -0
- data/lib/rdoc/markup/fragments.rb +42 -2
- data/lib/rdoc/markup/inline.rb +29 -4
- data/lib/rdoc/markup/lines.rb +4 -0
- data/lib/rdoc/markup/preprocess.rb +4 -0
- data/lib/rdoc/markup/to_flow.rb +27 -1
- data/lib/rdoc/markup/to_html.rb +33 -33
- data/lib/rdoc/markup/to_html_crossref.rb +4 -11
- data/lib/rdoc/markup/to_latex.rb +31 -31
- data/lib/rdoc/markup/to_test.rb +3 -0
- data/lib/rdoc/markup/to_texinfo.rb +18 -14
- data/lib/rdoc/meta_method.rb +8 -0
- data/lib/rdoc/normal_class.rb +18 -0
- data/lib/rdoc/normal_module.rb +34 -0
- data/lib/rdoc/options.rb +26 -159
- data/lib/rdoc/parser/c.rb +16 -8
- data/lib/rdoc/parser/ruby.rb +16 -10
- data/lib/rdoc/parser/simple.rb +1 -1
- data/lib/rdoc/rdoc.rb +50 -34
- data/lib/rdoc/require.rb +32 -0
- data/lib/rdoc/ri/descriptions.rb +1 -1
- data/lib/rdoc/ri/driver.rb +4 -4
- data/lib/rdoc/ri/formatter.rb +70 -32
- data/lib/rdoc/single_class.rb +8 -0
- data/lib/rdoc/top_level.rb +232 -0
- data/test/test_rdoc_any_method.rb +10 -0
- data/test/test_rdoc_code_object.rb +80 -0
- data/test/test_rdoc_constant.rb +15 -0
- data/test/test_rdoc_context.rb +250 -0
- data/test/test_rdoc_include.rb +17 -0
- data/test/test_rdoc_markup.rb +13 -2
- data/test/test_rdoc_markup_to_html.rb +22 -0
- data/test/test_rdoc_markup_to_html_crossref.rb +50 -115
- data/test/test_rdoc_normal_module.rb +26 -0
- data/test/test_rdoc_parser_c.rb +33 -0
- data/test/test_rdoc_parser_ruby.rb +54 -36
- data/test/test_rdoc_require.rb +25 -0
- data/test/test_rdoc_ri_default_display.rb +2 -1
- data/test/test_rdoc_ri_html_formatter.rb +141 -0
- data/test/test_rdoc_top_level.rb +85 -0
- data/test/xref_data.rb +46 -0
- data/test/xref_test_case.rb +48 -0
- metadata +42 -13
- metadata.gz.sig +0 -0
- data/lib/rdoc/generator/html.rb +0 -456
- data/lib/rdoc/generator/html/common.rb +0 -24
- data/lib/rdoc/generator/html/html.rb +0 -769
- data/lib/rdoc/generator/html/one_page_html.rb +0 -122
- data/lib/rdoc/generator/xml.rb +0 -124
- data/lib/rdoc/generator/xml/rdf.rb +0 -113
- data/lib/rdoc/generator/xml/xml.rb +0 -123
- data/lib/rdoc/parser/f95.rb +0 -1835
- data/lib/rdoc/template.rb +0 -68
metadata.gz.sig
CHANGED
Binary file
|
data/lib/rdoc/generator/html.rb
DELETED
@@ -1,456 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
require 'rdoc/generator'
|
4
|
-
require 'rdoc/markup/to_html'
|
5
|
-
require 'rdoc/cache'
|
6
|
-
|
7
|
-
##
|
8
|
-
# We're responsible for generating all the HTML files from the object tree
|
9
|
-
# defined in code_objects.rb. We generate:
|
10
|
-
#
|
11
|
-
# [files] an html file for each input file given. These
|
12
|
-
# input files appear as objects of class
|
13
|
-
# TopLevel
|
14
|
-
#
|
15
|
-
# [classes] an html file for each class or module encountered.
|
16
|
-
# These classes are not grouped by file: if a file
|
17
|
-
# contains four classes, we'll generate an html
|
18
|
-
# file for the file itself, and four html files
|
19
|
-
# for the individual classes.
|
20
|
-
#
|
21
|
-
# [indices] we generate three indices for files, classes,
|
22
|
-
# and methods. These are displayed in a browser
|
23
|
-
# like window with three index panes across the
|
24
|
-
# top and the selected description below
|
25
|
-
#
|
26
|
-
# Method descriptions appear in whatever entity (file, class, or module) that
|
27
|
-
# contains them.
|
28
|
-
#
|
29
|
-
# We generate files in a structure below a specified subdirectory, normally
|
30
|
-
# +doc+.
|
31
|
-
#
|
32
|
-
# opdir
|
33
|
-
# |
|
34
|
-
# |___ files
|
35
|
-
# | |__ per file summaries
|
36
|
-
# |
|
37
|
-
# |___ classes
|
38
|
-
# |__ per class/module descriptions
|
39
|
-
#
|
40
|
-
# HTML is generated using the Template class.
|
41
|
-
|
42
|
-
class RDoc::Generator::HTML
|
43
|
-
|
44
|
-
RDoc::RDoc.add_generator self
|
45
|
-
|
46
|
-
include RDoc::Generator::MarkUp
|
47
|
-
|
48
|
-
##
|
49
|
-
# Generator may need to return specific subclasses depending on the
|
50
|
-
# options they are passed. Because of this we create them using a factory
|
51
|
-
|
52
|
-
def self.for(options)
|
53
|
-
RDoc::Generator::AllReferences.reset
|
54
|
-
RDoc::Generator::Method.reset
|
55
|
-
|
56
|
-
if options.all_one_file
|
57
|
-
RDoc::Generator::HTMLInOne.new options
|
58
|
-
else
|
59
|
-
new options
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class << self
|
64
|
-
protected :new
|
65
|
-
end
|
66
|
-
|
67
|
-
##
|
68
|
-
# Set up a new HTML generator. Basically all we do here is load up the
|
69
|
-
# correct output temlate
|
70
|
-
|
71
|
-
def initialize(options) #:not-new:
|
72
|
-
@options = options
|
73
|
-
load_html_template
|
74
|
-
end
|
75
|
-
|
76
|
-
##
|
77
|
-
# Build the initial indices and output objects
|
78
|
-
# based on an array of TopLevel objects containing
|
79
|
-
# the extracted information.
|
80
|
-
|
81
|
-
def generate(toplevels)
|
82
|
-
@toplevels = toplevels
|
83
|
-
@files = []
|
84
|
-
@classes = []
|
85
|
-
@template_cache = RDoc::Cache.instance
|
86
|
-
|
87
|
-
write_style_sheet
|
88
|
-
gen_sub_directories
|
89
|
-
build_indices
|
90
|
-
generate_html
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
##
|
96
|
-
# Load up the HTML template specified in the options. If the template name
|
97
|
-
# contains a slash, use it literally.
|
98
|
-
#
|
99
|
-
# If the template is not a path, first look for it in rdoc's HTML template
|
100
|
-
# directory. Perhaps this behavior should be reversed (first try to include
|
101
|
-
# the template and, only if that fails, try to include it in the default
|
102
|
-
# template directory). One danger with reversing the behavior, however, is
|
103
|
-
# that if something like require 'html' could load up an unrelated file in
|
104
|
-
# the standard library or in a gem.
|
105
|
-
|
106
|
-
def load_html_template
|
107
|
-
template = @options.template
|
108
|
-
|
109
|
-
unless template =~ %r{/|\\} then
|
110
|
-
generator_name = @options.generator.name.sub(/^RDoc::Generator::/, '')
|
111
|
-
template = File.join('rdoc', 'generator', generator_name.downcase,
|
112
|
-
template)
|
113
|
-
end
|
114
|
-
|
115
|
-
begin
|
116
|
-
require template
|
117
|
-
|
118
|
-
@template = self.class.const_get @options.template.upcase
|
119
|
-
@options.template_class = @template
|
120
|
-
rescue LoadError => e
|
121
|
-
# The template did not exist in the default template directory, so
|
122
|
-
# see if require can find the template elsewhere (in a gem, for
|
123
|
-
# instance).
|
124
|
-
if(e.message[template] && template != @options.template)
|
125
|
-
template = @options.template
|
126
|
-
retry
|
127
|
-
end
|
128
|
-
|
129
|
-
$stderr.puts "Could not find HTML template '#{template}': #{e.message}"
|
130
|
-
exit 99
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
##
|
135
|
-
# Write out the style sheet used by the main frames
|
136
|
-
|
137
|
-
def write_style_sheet
|
138
|
-
return unless @template.constants.include? :STYLE or
|
139
|
-
@template.constants.include? 'STYLE'
|
140
|
-
|
141
|
-
template = RDoc::TemplatePage.new @template::STYLE
|
142
|
-
|
143
|
-
unless @options.css then
|
144
|
-
open RDoc::Generator::CSS_NAME, 'w' do |f|
|
145
|
-
values = {}
|
146
|
-
|
147
|
-
if @template.constants.include? :FONTS or
|
148
|
-
@template.constants.include? 'FONTS' then
|
149
|
-
values[:fonts] = @template::FONTS
|
150
|
-
end
|
151
|
-
|
152
|
-
template.write_html_on(f, values)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
##
|
158
|
-
# See the comments at the top for a description of the directory structure
|
159
|
-
|
160
|
-
def gen_sub_directories
|
161
|
-
FileUtils.mkdir_p RDoc::Generator::FILE_DIR
|
162
|
-
FileUtils.mkdir_p RDoc::Generator::CLASS_DIR
|
163
|
-
rescue
|
164
|
-
$stderr.puts $!.message
|
165
|
-
exit 1
|
166
|
-
end
|
167
|
-
|
168
|
-
def build_indices
|
169
|
-
@files, @classes = RDoc::Generator::Context.build_indices(@toplevels,
|
170
|
-
@options,
|
171
|
-
@template_cache)
|
172
|
-
end
|
173
|
-
|
174
|
-
##
|
175
|
-
# Generate all the HTML
|
176
|
-
|
177
|
-
def generate_html
|
178
|
-
@main_url = main_url
|
179
|
-
@sorted_files = @files.sort
|
180
|
-
@sorted_classes = @classes.sort
|
181
|
-
@sorted_methods = RDoc::Generator::Method.all_methods.sort
|
182
|
-
|
183
|
-
# the individual descriptions for files and classes
|
184
|
-
gen_into(@files)
|
185
|
-
gen_into(@classes)
|
186
|
-
|
187
|
-
# and the index files
|
188
|
-
gen_file_index
|
189
|
-
gen_class_index
|
190
|
-
gen_method_index
|
191
|
-
gen_main_index
|
192
|
-
|
193
|
-
# this method is defined in the template file
|
194
|
-
values = {
|
195
|
-
:title_suffix => CGI.escapeHTML("[#{@options.title}]"),
|
196
|
-
:charset => @options.charset,
|
197
|
-
:style_url => style_url('', @options.css),
|
198
|
-
}
|
199
|
-
|
200
|
-
@template.write_extra_pages(values) if
|
201
|
-
@template.respond_to?(:write_extra_pages)
|
202
|
-
end
|
203
|
-
|
204
|
-
def gen_into(list)
|
205
|
-
#
|
206
|
-
# The file, class, and method lists technically should be regenerated
|
207
|
-
# for every output file, in order that the relative links be correct
|
208
|
-
# (we are worried here about frameless templates, which need this
|
209
|
-
# information for every generated page). Doing this is a bit slow,
|
210
|
-
# however. For a medium-sized gem, this increased rdoc's runtime by
|
211
|
-
# about 5% (using the 'time' command-line utility). While this is not
|
212
|
-
# necessarily a problem, I do not want to pessimize rdoc for large
|
213
|
-
# projects, however, and so we only regenerate the lists when the
|
214
|
-
# directory of the output file changes, which seems like a reasonable
|
215
|
-
# optimization.
|
216
|
-
#
|
217
|
-
file_list = {}
|
218
|
-
class_list = {}
|
219
|
-
method_list = {}
|
220
|
-
prev_op_dir = nil
|
221
|
-
|
222
|
-
# Extra optimization: sort the list based on item directories, to minimize
|
223
|
-
# the number of times the directory changes. This reduces runtime by about
|
224
|
-
# 8% on RDoc's own sources.
|
225
|
-
sorted_list = list.sort do |a, b|
|
226
|
-
File.dirname(a.path) <=> File.dirname(b.path)
|
227
|
-
end
|
228
|
-
|
229
|
-
sorted_list.each do |item|
|
230
|
-
next unless item.document_self
|
231
|
-
|
232
|
-
op_file = item.path
|
233
|
-
op_dir = File.dirname(op_file)
|
234
|
-
|
235
|
-
if(op_dir != prev_op_dir)
|
236
|
-
file_list = index_to_links op_file, @sorted_files
|
237
|
-
class_list = index_to_links op_file, @sorted_classes
|
238
|
-
method_list = index_to_links op_file, @sorted_methods
|
239
|
-
end
|
240
|
-
prev_op_dir = op_dir
|
241
|
-
|
242
|
-
FileUtils.mkdir_p op_dir
|
243
|
-
|
244
|
-
open op_file, 'w' do |io|
|
245
|
-
item.write_on io, file_list, class_list, method_list
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
def gen_file_index
|
251
|
-
gen_an_index @files, 'Files', @template::FILE_INDEX, "fr_file_index.html"
|
252
|
-
end
|
253
|
-
|
254
|
-
def gen_class_index
|
255
|
-
gen_an_index(@classes, 'Classes', @template::CLASS_INDEX,
|
256
|
-
"fr_class_index.html")
|
257
|
-
end
|
258
|
-
|
259
|
-
def gen_method_index
|
260
|
-
gen_an_index(RDoc::Generator::Method.all_methods, 'Methods',
|
261
|
-
@template::METHOD_INDEX, "fr_method_index.html")
|
262
|
-
end
|
263
|
-
|
264
|
-
def gen_an_index(collection, title, template, filename)
|
265
|
-
template = RDoc::TemplatePage.new @template::FR_INDEX_BODY, template
|
266
|
-
res = []
|
267
|
-
collection.sort.each do |f|
|
268
|
-
if f.document_self
|
269
|
-
res << { :href => f.path, :name => f.index_name }
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
values = {
|
274
|
-
:entries => res,
|
275
|
-
:title => CGI.escapeHTML("#{title} [#{@options.title}]"),
|
276
|
-
:list_title => CGI.escapeHTML(title),
|
277
|
-
:index_url => @main_url,
|
278
|
-
:charset => @options.charset,
|
279
|
-
:style_url => style_url('', @options.css),
|
280
|
-
}
|
281
|
-
|
282
|
-
open filename, 'w' do |f|
|
283
|
-
template.write_html_on(f, values)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
##
|
288
|
-
# The main index page is mostly a template frameset, but includes the
|
289
|
-
# initial page. If the <tt>--main</tt> option was given, we use this as
|
290
|
-
# our main page, otherwise we use the first file specified on the command
|
291
|
-
# line.
|
292
|
-
|
293
|
-
def gen_main_index
|
294
|
-
if @template.const_defined? :FRAMELESS then
|
295
|
-
#
|
296
|
-
# If we're using a template without frames, then just redirect
|
297
|
-
# to it from index.html.
|
298
|
-
#
|
299
|
-
# One alternative to this, expanding the main page's template into
|
300
|
-
# index.html, is tricky because the relative URLs will be different
|
301
|
-
# (since index.html is located in at the site's root,
|
302
|
-
# rather than within a files or a classes subdirectory).
|
303
|
-
#
|
304
|
-
open 'index.html', 'w' do |f|
|
305
|
-
f.puts(%{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
306
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">})
|
307
|
-
f.puts(%{<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
|
308
|
-
lang="en">})
|
309
|
-
f.puts(%{<head>})
|
310
|
-
f.puts(%{<title>#{CGI.escapeHTML(@options.title)}</title>})
|
311
|
-
f.puts(%{<meta http-equiv="refresh" content="0; url=#{@main_url}" />})
|
312
|
-
f.puts(%{</head>})
|
313
|
-
f.puts(%{<body></body>})
|
314
|
-
f.puts(%{</html>})
|
315
|
-
end
|
316
|
-
else
|
317
|
-
main = RDoc::TemplatePage.new @template::INDEX
|
318
|
-
|
319
|
-
open 'index.html', 'w' do |f|
|
320
|
-
style_url = style_url '', @options.css
|
321
|
-
|
322
|
-
classes = @classes.sort.map { |klass| klass.value_hash }
|
323
|
-
|
324
|
-
values = {
|
325
|
-
:initial_page => @main_url,
|
326
|
-
:style_url => style_url('', @options.css),
|
327
|
-
:title => CGI.escapeHTML(@options.title),
|
328
|
-
:charset => @options.charset,
|
329
|
-
:classes => classes,
|
330
|
-
}
|
331
|
-
|
332
|
-
values[:inline_source] = @options.inline_source
|
333
|
-
|
334
|
-
main.write_html_on f, values
|
335
|
-
end
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
def index_to_links(output_path, sorted_collection)
|
340
|
-
result = sorted_collection.map do |f|
|
341
|
-
next unless f.document_self
|
342
|
-
{ :href => RDoc::Markup::ToHtml.gen_relative_url(output_path, f.path),
|
343
|
-
:name => f.index_name }
|
344
|
-
end
|
345
|
-
result.compact!
|
346
|
-
result
|
347
|
-
end
|
348
|
-
|
349
|
-
##
|
350
|
-
# Returns the url of the main page
|
351
|
-
|
352
|
-
def main_url
|
353
|
-
main_page = @options.main_page
|
354
|
-
|
355
|
-
#
|
356
|
-
# If a main page has been specified (--main), then search for it
|
357
|
-
# in the AllReferences array. This allows either files or classes
|
358
|
-
# to be used for the main page.
|
359
|
-
#
|
360
|
-
if main_page then
|
361
|
-
main_page_ref = RDoc::Generator::AllReferences[main_page]
|
362
|
-
|
363
|
-
if main_page_ref then
|
364
|
-
return main_page_ref.path
|
365
|
-
else
|
366
|
-
$stderr.puts "Could not find main page #{main_page}"
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
#
|
371
|
-
# No main page has been specified, so just use the README.
|
372
|
-
#
|
373
|
-
@files.each do |file|
|
374
|
-
return file.path if file.name =~ /^README/
|
375
|
-
end
|
376
|
-
|
377
|
-
#
|
378
|
-
# There's no README (shame! shame!). Just use the first file
|
379
|
-
# that will be documented.
|
380
|
-
#
|
381
|
-
@files.each do |file|
|
382
|
-
return file.path if file.document_self
|
383
|
-
end
|
384
|
-
|
385
|
-
#
|
386
|
-
# There are no files to be documented... Something seems very wrong.
|
387
|
-
#
|
388
|
-
raise RDoc::Error, "Couldn't find anything to document (perhaps :stopdoc: has been used in all classes)!"
|
389
|
-
end
|
390
|
-
private :main_url
|
391
|
-
|
392
|
-
end
|
393
|
-
|
394
|
-
class RDoc::Generator::HTMLInOne < RDoc::Generator::HTML
|
395
|
-
|
396
|
-
def initialize(*args)
|
397
|
-
super
|
398
|
-
end
|
399
|
-
|
400
|
-
##
|
401
|
-
# Build the initial indices and output objects
|
402
|
-
# based on an array of TopLevel objects containing
|
403
|
-
# the extracted information.
|
404
|
-
|
405
|
-
def generate(info)
|
406
|
-
@toplevels = info
|
407
|
-
@hyperlinks = {}
|
408
|
-
|
409
|
-
build_indices
|
410
|
-
generate_xml
|
411
|
-
end
|
412
|
-
|
413
|
-
##
|
414
|
-
# Generate:
|
415
|
-
#
|
416
|
-
# * a list of RDoc::Generator::File objects for each TopLevel object.
|
417
|
-
# * a list of RDoc::Generator::Class objects for each first level
|
418
|
-
# class or module in the TopLevel objects
|
419
|
-
# * a complete list of all hyperlinkable terms (file,
|
420
|
-
# class, module, and method names)
|
421
|
-
|
422
|
-
def build_indices
|
423
|
-
@files, @classes = RDoc::Generator::Context.build_indices(@toplevels,
|
424
|
-
@options)
|
425
|
-
end
|
426
|
-
|
427
|
-
##
|
428
|
-
# Generate all the HTML. For the one-file case, we generate
|
429
|
-
# all the information in to one big hash
|
430
|
-
|
431
|
-
def generate_xml
|
432
|
-
values = {
|
433
|
-
:charset => @options.charset,
|
434
|
-
:files => gen_into(@files),
|
435
|
-
:classes => gen_into(@classes),
|
436
|
-
:title => CGI.escapeHTML(@options.title),
|
437
|
-
}
|
438
|
-
|
439
|
-
template = RDoc::TemplatePage.new @template::ONE_PAGE
|
440
|
-
|
441
|
-
opfile = if @options.op_name then
|
442
|
-
open @options.op_name, 'w'
|
443
|
-
else
|
444
|
-
$stdout
|
445
|
-
end
|
446
|
-
template.write_html_on(opfile, values)
|
447
|
-
end
|
448
|
-
|
449
|
-
def gen_into(list)
|
450
|
-
res = []
|
451
|
-
list.each do |item|
|
452
|
-
res << item.value_hash
|
453
|
-
end
|
454
|
-
res
|
455
|
-
end
|
456
|
-
end
|