rdoc 3.5.1 → 3.5.2
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/History.txt +18 -1
- data/Manifest.txt +1 -0
- data/README.txt +3 -3
- data/Rakefile +10 -3
- data/lib/rdoc.rb +1 -1
- data/lib/rdoc/any_method.rb +2 -2
- data/lib/rdoc/context.rb +105 -38
- data/lib/rdoc/generator/markup.rb +12 -17
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +138 -115
- data/lib/rdoc/generator/template/darkfish/rdoc.css +40 -11
- data/lib/rdoc/markup.rb +9 -5
- data/lib/rdoc/markup/to_html.rb +62 -82
- data/lib/rdoc/options.rb +1 -1
- data/lib/rdoc/text.rb +32 -0
- data/test/test_rdoc_any_method.rb +7 -1
- data/test/test_rdoc_context.rb +65 -0
- data/test/test_rdoc_context_section.rb +54 -0
- data/test/test_rdoc_options.rb +18 -8
- data/test/xref_data.rb +5 -0
- metadata +23 -14
- metadata.gz.sig +0 -0
@@ -278,46 +278,46 @@ ul.link-list .type {
|
|
278
278
|
|
279
279
|
|
280
280
|
/* @group Documentation Section */
|
281
|
-
|
281
|
+
.description {
|
282
282
|
font-size: 100%;
|
283
283
|
color: #333;
|
284
284
|
}
|
285
285
|
|
286
|
-
|
286
|
+
.description p {
|
287
287
|
margin: 1em 0.4em;
|
288
288
|
}
|
289
289
|
|
290
|
-
|
290
|
+
.description li p {
|
291
291
|
margin: 0;
|
292
292
|
}
|
293
293
|
|
294
|
-
|
294
|
+
.description ul {
|
295
295
|
margin-left: 1.5em;
|
296
296
|
}
|
297
|
-
|
297
|
+
.description ul li {
|
298
298
|
line-height: 1.4em;
|
299
299
|
}
|
300
300
|
|
301
|
-
|
301
|
+
.description dl,
|
302
302
|
#documentation dl {
|
303
303
|
margin: 8px 1.5em;
|
304
304
|
border: 1px solid #ccc;
|
305
305
|
}
|
306
|
-
|
306
|
+
.description dl {
|
307
307
|
font-size: 14px;
|
308
308
|
}
|
309
309
|
|
310
|
-
|
310
|
+
.description dt,
|
311
311
|
#documentation dt {
|
312
312
|
padding: 2px 4px;
|
313
313
|
font-weight: bold;
|
314
314
|
background: #ddd;
|
315
315
|
}
|
316
|
-
|
316
|
+
.description dd,
|
317
317
|
#documentation dd {
|
318
318
|
padding: 2px 12px;
|
319
319
|
}
|
320
|
-
|
320
|
+
.description dd + dt,
|
321
321
|
#documentation dd + dt {
|
322
322
|
margin-top: 0.7em;
|
323
323
|
}
|
@@ -325,9 +325,21 @@ ul.link-list .type {
|
|
325
325
|
#documentation .section {
|
326
326
|
font-size: 90%;
|
327
327
|
}
|
328
|
-
|
328
|
+
|
329
|
+
#documentation h2.section-header {
|
329
330
|
margin-top: 2em;
|
330
331
|
padding: 0.75em 0.5em;
|
332
|
+
background: #ccc;
|
333
|
+
color: #333;
|
334
|
+
font-size: 175%;
|
335
|
+
border: 1px solid #bbb;
|
336
|
+
-moz-border-radius: 3px;
|
337
|
+
-webkit-border-radius: 3px;
|
338
|
+
}
|
339
|
+
|
340
|
+
#documentation h3.section-header {
|
341
|
+
margin-top: 2em;
|
342
|
+
padding: 0.25em 0.5em;
|
331
343
|
background-color: #dedede;
|
332
344
|
color: #333;
|
333
345
|
font-size: 150%;
|
@@ -359,6 +371,23 @@ ul.link-list .type {
|
|
359
371
|
color: #666;
|
360
372
|
}
|
361
373
|
|
374
|
+
.documentation-section h2 {
|
375
|
+
position: relative;
|
376
|
+
}
|
377
|
+
|
378
|
+
.documentation-section h2 a {
|
379
|
+
position: absolute;
|
380
|
+
top: 8px;
|
381
|
+
right: 10px;
|
382
|
+
font-size: 12px;
|
383
|
+
color: #9b9877;
|
384
|
+
visibility: hidden;
|
385
|
+
}
|
386
|
+
|
387
|
+
.documentation-section h2:hover a {
|
388
|
+
visibility: visible;
|
389
|
+
}
|
390
|
+
|
362
391
|
/* @group Method Details */
|
363
392
|
|
364
393
|
#documentation .method-source-code {
|
data/lib/rdoc/markup.rb
CHANGED
@@ -502,10 +502,11 @@ require 'rdoc'
|
|
502
502
|
# Starts a new section in the output. The title following +:section:+ is
|
503
503
|
# used as the section heading, and the remainder of the comment containing
|
504
504
|
# the section is used as introductory text. Subsequent methods, aliases,
|
505
|
-
# attributes, and classes will be documented in this section.
|
506
|
-
#
|
507
|
-
#
|
508
|
-
#
|
505
|
+
# attributes, and classes will be documented in this section.
|
506
|
+
#
|
507
|
+
# A :section: comment block may have one or more lines before the :section:
|
508
|
+
# directive. These will be removed, and any identical lines at the end of
|
509
|
+
# the block are also removed. This allows you to add visual cues such as:
|
509
510
|
#
|
510
511
|
# # ----------------------------------------
|
511
512
|
# # :section: My Section
|
@@ -513,7 +514,10 @@ require 'rdoc'
|
|
513
514
|
# # See it glisten in the noon-day sun.
|
514
515
|
# # ----------------------------------------
|
515
516
|
#
|
516
|
-
#
|
517
|
+
# Sections may be referenced multiple times in a class or module allowing
|
518
|
+
# methods, attributes and constants to be ordered one way for implementation
|
519
|
+
# ordering but still grouped together in documentation. If a section has
|
520
|
+
# multiple comments they will be concatenated with a dividing rule.
|
517
521
|
#
|
518
522
|
# [+:call-seq:+]
|
519
523
|
# Lines up to the next blank line in the comment are treated as the method's
|
data/lib/rdoc/markup/to_html.rb
CHANGED
@@ -10,6 +10,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
10
10
|
|
11
11
|
include RDoc::Text
|
12
12
|
|
13
|
+
# :section: Utilities
|
14
|
+
|
13
15
|
##
|
14
16
|
# Maps RDoc::Markup::Parser::LIST_TOKENS types to HTML tags
|
15
17
|
|
@@ -55,6 +57,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
55
57
|
File.join(*from)
|
56
58
|
end
|
57
59
|
|
60
|
+
# :section:
|
61
|
+
|
58
62
|
##
|
59
63
|
# Creates a new formatter that will output HTML
|
60
64
|
|
@@ -75,54 +79,21 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
75
79
|
init_tags
|
76
80
|
end
|
77
81
|
|
78
|
-
|
79
|
-
#
|
80
|
-
|
81
|
-
def init_tags
|
82
|
-
add_tag :BOLD, "<b>", "</b>"
|
83
|
-
add_tag :TT, "<tt>", "</tt>"
|
84
|
-
add_tag :EM, "<em>", "</em>"
|
85
|
-
end
|
82
|
+
# :section: Special Handling
|
83
|
+
#
|
84
|
+
# These methods handle special markup added by RDoc::Markup#add_special.
|
86
85
|
|
87
86
|
##
|
88
|
-
#
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
url = "http://#{url}"
|
99
|
-
end
|
100
|
-
|
101
|
-
if type == "link" then
|
102
|
-
url = if path[0, 1] == '#' then # is this meaningful?
|
103
|
-
path
|
104
|
-
else
|
105
|
-
self.class.gen_relative_url @from_path, path
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
if (type == "http" or type == "link") and
|
110
|
-
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
|
111
|
-
"<img src=\"#{url}\" />"
|
112
|
-
else
|
113
|
-
"<a href=\"#{url}\">#{text.sub(%r{^#{type}:/*}, '')}</a>"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# :section: Special handling
|
118
|
-
|
119
|
-
##
|
120
|
-
# And we're invoked with a potential external hyperlink. <tt>mailto:</tt>
|
121
|
-
# just gets inserted. <tt>http:</tt> links are checked to see if they
|
122
|
-
# reference an image. If so, that image gets inserted using an
|
123
|
-
# <tt><img></tt> tag. Otherwise a conventional <tt><a href></tt> is used.
|
124
|
-
# We also support a special type of hyperlink, <tt>link:</tt>, which is a
|
125
|
-
# reference to a local file whose path is relative to the --op directory.
|
87
|
+
# +special+ is a potential hyperlink. The following schemes are handled:
|
88
|
+
#
|
89
|
+
# <tt>mailto:</tt>::
|
90
|
+
# Inserted as-is.
|
91
|
+
# <tt>http:</tt>::
|
92
|
+
# Links are checked to see if they reference an image. If so, that image
|
93
|
+
# gets inserted using an <tt><img></tt> tag. Otherwise a conventional
|
94
|
+
# <tt><a href></tt> is used.
|
95
|
+
# <tt>link:</tt>::
|
96
|
+
# Reference to a local file relative to the output directory.
|
126
97
|
|
127
98
|
def handle_special_HYPERLINK(special)
|
128
99
|
url = special.text
|
@@ -130,8 +101,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
130
101
|
end
|
131
102
|
|
132
103
|
##
|
133
|
-
#
|
134
|
-
#
|
104
|
+
# This +special+ is a hyperlink where the label is different from the URL
|
105
|
+
# label[url] or {long label}[url]
|
135
106
|
|
136
107
|
def handle_special_TIDYLINK(special)
|
137
108
|
text = special.text
|
@@ -143,41 +114,9 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
143
114
|
gen_url url, label
|
144
115
|
end
|
145
116
|
|
146
|
-
# :section: Utilities
|
147
|
-
|
148
|
-
##
|
149
|
-
# Wraps +txt+ to +line_len+
|
150
|
-
|
151
|
-
def wrap(txt, line_len = 76)
|
152
|
-
res = []
|
153
|
-
sp = 0
|
154
|
-
ep = txt.length
|
155
|
-
|
156
|
-
while sp < ep
|
157
|
-
# scan back for a space
|
158
|
-
p = sp + line_len - 1
|
159
|
-
if p >= ep
|
160
|
-
p = ep
|
161
|
-
else
|
162
|
-
while p > sp and txt[p] != ?\s
|
163
|
-
p -= 1
|
164
|
-
end
|
165
|
-
if p <= sp
|
166
|
-
p = sp + line_len
|
167
|
-
while p < ep and txt[p] != ?\s
|
168
|
-
p += 1
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
res << txt[sp...p] << "\n"
|
173
|
-
sp = p
|
174
|
-
sp += 1 while sp < ep and txt[sp] == ?\s
|
175
|
-
end
|
176
|
-
|
177
|
-
res.join.strip
|
178
|
-
end
|
179
|
-
|
180
117
|
# :section: Visitor
|
118
|
+
#
|
119
|
+
# These methods implement the HTML visitor.
|
181
120
|
|
182
121
|
##
|
183
122
|
# Prepares the visitor for HTML generation
|
@@ -283,6 +222,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
283
222
|
@res << raw.parts.join("\n")
|
284
223
|
end
|
285
224
|
|
225
|
+
# :section: Utilities
|
226
|
+
|
286
227
|
##
|
287
228
|
# CGI escapes +text+
|
288
229
|
|
@@ -290,6 +231,36 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
290
231
|
CGI.escapeHTML text
|
291
232
|
end
|
292
233
|
|
234
|
+
##
|
235
|
+
# Generate a hyperlink for +url+, labeled with +text+. Handles the special
|
236
|
+
# cases for img: and link: described under handle_special_HYPERLINK
|
237
|
+
|
238
|
+
def gen_url(url, text)
|
239
|
+
if url =~ /([A-Za-z]+):(.*)/ then
|
240
|
+
type = $1
|
241
|
+
path = $2
|
242
|
+
else
|
243
|
+
type = "http"
|
244
|
+
path = url
|
245
|
+
url = "http://#{url}"
|
246
|
+
end
|
247
|
+
|
248
|
+
if type == "link" then
|
249
|
+
url = if path[0, 1] == '#' then # is this meaningful?
|
250
|
+
path
|
251
|
+
else
|
252
|
+
self.class.gen_relative_url @from_path, path
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
if (type == "http" or type == "link") and
|
257
|
+
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
|
258
|
+
"<img src=\"#{url}\" />"
|
259
|
+
else
|
260
|
+
"<a href=\"#{url}\">#{text.sub(%r{^#{type}:/*}, '')}</a>"
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
293
264
|
##
|
294
265
|
# Determines the HTML list element for +list_type+ and +open_tag+
|
295
266
|
|
@@ -299,6 +270,15 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
299
270
|
tags[open_tag ? 0 : 1]
|
300
271
|
end
|
301
272
|
|
273
|
+
##
|
274
|
+
# Maps attributes to HTML tags
|
275
|
+
|
276
|
+
def init_tags
|
277
|
+
add_tag :BOLD, "<b>", "</b>"
|
278
|
+
add_tag :TT, "<tt>", "</tt>"
|
279
|
+
add_tag :EM, "<em>", "</em>"
|
280
|
+
end
|
281
|
+
|
302
282
|
##
|
303
283
|
# Returns the HTML tag for +list_type+, possible using a label from
|
304
284
|
# +list_item+
|
data/lib/rdoc/options.rb
CHANGED
data/lib/rdoc/text.rb
CHANGED
@@ -260,5 +260,37 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
|
|
260
260
|
html
|
261
261
|
end
|
262
262
|
|
263
|
+
##
|
264
|
+
# Wraps +txt+ to +line_len+
|
265
|
+
|
266
|
+
def wrap(txt, line_len = 76)
|
267
|
+
res = []
|
268
|
+
sp = 0
|
269
|
+
ep = txt.length
|
270
|
+
|
271
|
+
while sp < ep
|
272
|
+
# scan back for a space
|
273
|
+
p = sp + line_len - 1
|
274
|
+
if p >= ep
|
275
|
+
p = ep
|
276
|
+
else
|
277
|
+
while p > sp and txt[p] != ?\s
|
278
|
+
p -= 1
|
279
|
+
end
|
280
|
+
if p <= sp
|
281
|
+
p = sp + line_len
|
282
|
+
while p < ep and txt[p] != ?\s
|
283
|
+
p += 1
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
res << txt[sp...p] << "\n"
|
288
|
+
sp = p
|
289
|
+
sp += 1 while sp < ep and txt[sp] == ?\s
|
290
|
+
end
|
291
|
+
|
292
|
+
res.join.strip
|
293
|
+
end
|
294
|
+
|
263
295
|
end
|
264
296
|
|
@@ -47,7 +47,7 @@ method(a, b) { |c, d| ... }
|
|
47
47
|
def test_markup_code
|
48
48
|
tokens = [
|
49
49
|
RDoc::RubyToken::TkCONSTANT. new(0, 0, 0, 'CONSTANT'),
|
50
|
-
RDoc::RubyToken::
|
50
|
+
RDoc::RubyToken::TkDEF. new(0, 0, 0, 'KW'),
|
51
51
|
RDoc::RubyToken::TkIVAR. new(0, 0, 0, 'IVAR'),
|
52
52
|
RDoc::RubyToken::TkOp. new(0, 0, 0, 'Op'),
|
53
53
|
RDoc::RubyToken::TkId. new(0, 0, 0, 'Id'),
|
@@ -90,6 +90,12 @@ method(a, b) { |c, d| ... }
|
|
90
90
|
assert_equal 'C1', instance_method.parent_name
|
91
91
|
assert_equal '(foo)', instance_method.params
|
92
92
|
|
93
|
+
aliased_method = Marshal.load Marshal.dump(@c2.method_list.last)
|
94
|
+
|
95
|
+
assert_equal 'C2#a', aliased_method.full_name
|
96
|
+
assert_equal 'C2', aliased_method.parent_name
|
97
|
+
assert_equal '()', aliased_method.params
|
98
|
+
|
93
99
|
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
|
94
100
|
|
95
101
|
assert_equal 'C1::m', class_method.full_name
|
data/test/test_rdoc_context.rb
CHANGED
@@ -251,6 +251,34 @@ class TestRDocContext < XrefTestCase
|
|
251
251
|
refute_equal @c2_c3, @c3
|
252
252
|
end
|
253
253
|
|
254
|
+
def test_each_section
|
255
|
+
sects = []
|
256
|
+
consts = []
|
257
|
+
attrs = []
|
258
|
+
|
259
|
+
@c1.each_section do |section, constants, attributes|
|
260
|
+
sects << section
|
261
|
+
consts << constants
|
262
|
+
attrs << attributes
|
263
|
+
end
|
264
|
+
|
265
|
+
assert_equal [nil, 'separate'], sects.map { |section| section.title }
|
266
|
+
|
267
|
+
expected_consts = [
|
268
|
+
[@c1.constants.first],
|
269
|
+
[],
|
270
|
+
]
|
271
|
+
|
272
|
+
assert_equal expected_consts, consts
|
273
|
+
|
274
|
+
expected_attrs = [
|
275
|
+
[@c1.attributes[0], @c1.attributes[3]],
|
276
|
+
[@c1.attributes[1], @c1.attributes[2]],
|
277
|
+
]
|
278
|
+
|
279
|
+
assert_equal expected_attrs, attrs
|
280
|
+
end
|
281
|
+
|
254
282
|
def test_find_attribute_named
|
255
283
|
assert_equal nil, @c1.find_attribute_named('none')
|
256
284
|
assert_equal 'R', @c1.find_attribute_named('attr').rw
|
@@ -373,5 +401,42 @@ class TestRDocContext < XrefTestCase
|
|
373
401
|
assert_equal(-1, @c2_c3.<=>(@c3))
|
374
402
|
end
|
375
403
|
|
404
|
+
def test_methods_by_type
|
405
|
+
expected = {
|
406
|
+
'instance' => {
|
407
|
+
:private => [],
|
408
|
+
:protected => [],
|
409
|
+
:public => [@c1_m],
|
410
|
+
},
|
411
|
+
'class' => {
|
412
|
+
:private => [],
|
413
|
+
:protected => [],
|
414
|
+
:public => [@c1__m],
|
415
|
+
},
|
416
|
+
}
|
417
|
+
|
418
|
+
assert_equal expected, @c1.methods_by_type
|
419
|
+
end
|
420
|
+
|
421
|
+
def test_methods_by_type_section
|
422
|
+
separate = @c1.sections_hash['separate']
|
423
|
+
@c1_m.section = separate
|
424
|
+
|
425
|
+
expected = {
|
426
|
+
'instance' => {
|
427
|
+
:private => [],
|
428
|
+
:protected => [],
|
429
|
+
:public => [@c1_m],
|
430
|
+
},
|
431
|
+
'class' => {
|
432
|
+
:private => [],
|
433
|
+
:protected => [],
|
434
|
+
:public => [],
|
435
|
+
},
|
436
|
+
}
|
437
|
+
|
438
|
+
assert_equal expected, @c1.methods_by_type(separate)
|
439
|
+
end
|
440
|
+
|
376
441
|
end
|
377
442
|
|