rdoc 4.0.1 → 4.1.0.preview.3
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +1 -3
- data/{DEVELOPERS.rdoc → CONTRIBUTING.rdoc} +28 -3
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/History.rdoc +81 -0
- data/Manifest.txt +11 -2
- data/README.rdoc +5 -5
- data/Rakefile +34 -4
- data/lib/rdoc.rb +4 -3
- data/lib/rdoc/any_method.rb +48 -4
- data/lib/rdoc/class_module.rb +16 -2
- data/lib/rdoc/code_object.rb +85 -24
- data/lib/rdoc/comment.rb +0 -3
- data/lib/rdoc/constant.rb +9 -1
- data/lib/rdoc/context.rb +20 -2
- data/lib/rdoc/cross_reference.rb +1 -1
- data/lib/rdoc/extend.rb +4 -112
- data/lib/rdoc/generator/darkfish.rb +46 -7
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -8
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +4 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +3 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +4 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +3 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +9 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +12 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +5 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +6 -7
- data/lib/rdoc/generator/template/darkfish/class.rhtml +36 -41
- data/lib/rdoc/generator/template/darkfish/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -7
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -15
- data/lib/rdoc/generator/template/darkfish/js/search.js +12 -4
- data/lib/rdoc/generator/template/darkfish/page.rhtml +9 -9
- data/lib/rdoc/generator/template/darkfish/rdoc.css +226 -241
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +13 -6
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +17 -14
- data/lib/rdoc/include.rb +4 -114
- data/lib/rdoc/known_classes.rb +1 -0
- data/lib/rdoc/markdown.kpeg +126 -117
- data/lib/rdoc/markdown.rb +404 -389
- data/lib/rdoc/markdown/literals_1_8.kpeg +1 -1
- data/lib/rdoc/markdown/literals_1_8.rb +15 -12
- data/lib/rdoc/markdown/literals_1_9.kpeg +1 -1
- data/lib/rdoc/markdown/literals_1_9.rb +15 -12
- data/lib/rdoc/markup.rb +10 -13
- data/lib/rdoc/markup/attribute_manager.rb +3 -2
- data/lib/rdoc/markup/formatter.rb +3 -3
- data/lib/rdoc/markup/heading.rb +13 -0
- data/lib/rdoc/markup/parser.rb +10 -3
- data/lib/rdoc/markup/pre_process.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +46 -31
- data/lib/rdoc/markup/to_html_crossref.rb +3 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
- data/lib/rdoc/markup/to_markdown.rb +7 -5
- data/lib/rdoc/markup/verbatim.rb +1 -1
- data/lib/rdoc/method_attr.rb +13 -1
- data/lib/rdoc/mixin.rb +120 -0
- data/lib/rdoc/normal_class.rb +4 -0
- data/lib/rdoc/normal_module.rb +4 -0
- data/lib/rdoc/options.rb +42 -8
- data/lib/rdoc/parser.rb +4 -2
- data/lib/rdoc/parser/c.rb +13 -7
- data/lib/rdoc/parser/ruby.rb +683 -480
- data/lib/rdoc/rdoc.rb +4 -3
- data/lib/rdoc/ri/driver.rb +174 -103
- data/lib/rdoc/ri/paths.rb +6 -6
- data/lib/rdoc/ruby_lex.rb +125 -102
- data/lib/rdoc/ruby_token.rb +41 -40
- data/lib/rdoc/servlet.rb +16 -6
- data/lib/rdoc/stats.rb +61 -48
- data/lib/rdoc/store.rb +5 -3
- data/lib/rdoc/test_case.rb +39 -0
- data/lib/rdoc/tom_doc.rb +28 -4
- data/lib/rdoc/top_level.rb +2 -2
- data/test/test_rdoc_any_method.rb +104 -1
- data/test/test_rdoc_class_module.rb +9 -15
- data/test/test_rdoc_code_object.rb +133 -8
- data/test/test_rdoc_context.rb +17 -0
- data/test/test_rdoc_context_section.rb +0 -7
- data/test/test_rdoc_cross_reference.rb +4 -3
- data/test/test_rdoc_generator_darkfish.rb +61 -19
- data/test/test_rdoc_generator_json_index.rb +0 -11
- data/test/test_rdoc_generator_ri.rb +0 -8
- data/test/test_rdoc_markdown.rb +15 -12
- data/test/test_rdoc_markdown_test.rb +0 -7
- data/test/test_rdoc_markup_attribute_manager.rb +121 -0
- data/test/test_rdoc_markup_document.rb +0 -7
- data/test/test_rdoc_markup_formatter.rb +29 -3
- data/test/test_rdoc_markup_heading.rb +9 -0
- data/test/test_rdoc_markup_parser.rb +0 -7
- data/test/test_rdoc_markup_pre_process.rb +15 -3
- data/test/test_rdoc_markup_raw.rb +0 -7
- data/test/test_rdoc_markup_to_html.rb +50 -8
- data/test/test_rdoc_markup_to_html_crossref.rb +7 -0
- data/test/test_rdoc_markup_to_html_snippet.rb +4 -4
- data/test/test_rdoc_markup_to_markdown.rb +6 -0
- data/test/test_rdoc_method_attr.rb +8 -0
- data/test/test_rdoc_normal_class.rb +5 -0
- data/test/test_rdoc_normal_module.rb +5 -0
- data/test/test_rdoc_options.rb +61 -22
- data/test/test_rdoc_parser.rb +10 -0
- data/test/test_rdoc_parser_c.rb +17 -5
- data/test/test_rdoc_parser_changelog.rb +0 -7
- data/test/test_rdoc_parser_rd.rb +0 -7
- data/test/test_rdoc_parser_ruby.rb +305 -28
- data/test/test_rdoc_rd_block_parser.rb +0 -8
- data/test/test_rdoc_rd_inline_parser.rb +0 -1
- data/test/test_rdoc_rdoc.rb +27 -1
- data/test/test_rdoc_ri_driver.rb +19 -7
- data/test/test_rdoc_ruby_lex.rb +116 -9
- data/test/test_rdoc_rubygems_hook.rb +1 -1
- data/test/test_rdoc_servlet.rb +44 -6
- data/test/test_rdoc_stats.rb +161 -141
- data/test/test_rdoc_store.rb +11 -19
- data/test/test_rdoc_text.rb +0 -7
- data/test/test_rdoc_tom_doc.rb +44 -16
- data/test/xref_test_case.rb +2 -0
- metadata +28 -27
- metadata.gz.sig +0 -0
- data/test/test_attribute_manager.rb +0 -120
@@ -3,7 +3,7 @@
|
|
3
3
|
##
|
4
4
|
# Provides Literals appropriate for your ruby version.
|
5
5
|
#--
|
6
|
-
# This set of literals is for
|
6
|
+
# This set of literals is for Ruby 1.8 regular expressions.
|
7
7
|
class RDoc::Markdown::Literals
|
8
8
|
# :stopdoc:
|
9
9
|
|
@@ -19,8 +19,7 @@ class RDoc::Markdown::Literals
|
|
19
19
|
# Prepares for parsing +str+. If you define a custom initialize you must
|
20
20
|
# call this method before #parse
|
21
21
|
def setup_parser(str, debug=false)
|
22
|
-
|
23
|
-
@pos = 0
|
22
|
+
set_string str, 0
|
24
23
|
@memoizations = Hash.new { |h,k| h[k] = {} }
|
25
24
|
@result = nil
|
26
25
|
@failed_rule = nil
|
@@ -33,7 +32,6 @@ class RDoc::Markdown::Literals
|
|
33
32
|
attr_reader :failing_rule_offset
|
34
33
|
attr_accessor :result, :pos
|
35
34
|
|
36
|
-
|
37
35
|
def current_column(target=pos)
|
38
36
|
if c = string.rindex("\n", target-1)
|
39
37
|
return target - c - 1
|
@@ -67,6 +65,13 @@ class RDoc::Markdown::Literals
|
|
67
65
|
@string[start..@pos-1]
|
68
66
|
end
|
69
67
|
|
68
|
+
# Sets the string and current parsing position for the parser.
|
69
|
+
def set_string string, pos
|
70
|
+
@string = string
|
71
|
+
@string_size = string ? string.size : 0
|
72
|
+
@pos = pos
|
73
|
+
end
|
74
|
+
|
70
75
|
def show_pos
|
71
76
|
width = 10
|
72
77
|
if @pos < width
|
@@ -173,19 +178,19 @@ class RDoc::Markdown::Literals
|
|
173
178
|
return nil
|
174
179
|
end
|
175
180
|
|
176
|
-
if "".respond_to? :
|
181
|
+
if "".respond_to? :ord
|
177
182
|
def get_byte
|
178
|
-
if @pos >= @
|
183
|
+
if @pos >= @string_size
|
179
184
|
return nil
|
180
185
|
end
|
181
186
|
|
182
|
-
s = @string
|
187
|
+
s = @string[@pos].ord
|
183
188
|
@pos += 1
|
184
189
|
s
|
185
190
|
end
|
186
191
|
else
|
187
192
|
def get_byte
|
188
|
-
if @pos >= @
|
193
|
+
if @pos >= @string_size
|
189
194
|
return nil
|
190
195
|
end
|
191
196
|
|
@@ -234,8 +239,7 @@ class RDoc::Markdown::Literals
|
|
234
239
|
old_pos = @pos
|
235
240
|
old_string = @string
|
236
241
|
|
237
|
-
|
238
|
-
@string = other.string
|
242
|
+
set_string other.string, other.pos
|
239
243
|
|
240
244
|
begin
|
241
245
|
if val = __send__(rule, *args)
|
@@ -246,8 +250,7 @@ class RDoc::Markdown::Literals
|
|
246
250
|
end
|
247
251
|
val
|
248
252
|
ensure
|
249
|
-
|
250
|
-
@string = old_string
|
253
|
+
set_string old_string, old_pos
|
251
254
|
end
|
252
255
|
end
|
253
256
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
##
|
8
8
|
#--
|
9
|
-
# This set of literals is for
|
9
|
+
# This set of literals is for Ruby 1.9 regular expressions and gives full
|
10
10
|
# unicode support.
|
11
11
|
#
|
12
12
|
# Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
##
|
5
5
|
#--
|
6
|
-
# This set of literals is for
|
6
|
+
# This set of literals is for Ruby 1.9 regular expressions and gives full
|
7
7
|
# unicode support.
|
8
8
|
#
|
9
9
|
# Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric
|
@@ -23,8 +23,7 @@ class RDoc::Markdown::Literals
|
|
23
23
|
# Prepares for parsing +str+. If you define a custom initialize you must
|
24
24
|
# call this method before #parse
|
25
25
|
def setup_parser(str, debug=false)
|
26
|
-
|
27
|
-
@pos = 0
|
26
|
+
set_string str, 0
|
28
27
|
@memoizations = Hash.new { |h,k| h[k] = {} }
|
29
28
|
@result = nil
|
30
29
|
@failed_rule = nil
|
@@ -37,7 +36,6 @@ class RDoc::Markdown::Literals
|
|
37
36
|
attr_reader :failing_rule_offset
|
38
37
|
attr_accessor :result, :pos
|
39
38
|
|
40
|
-
|
41
39
|
def current_column(target=pos)
|
42
40
|
if c = string.rindex("\n", target-1)
|
43
41
|
return target - c - 1
|
@@ -71,6 +69,13 @@ class RDoc::Markdown::Literals
|
|
71
69
|
@string[start..@pos-1]
|
72
70
|
end
|
73
71
|
|
72
|
+
# Sets the string and current parsing position for the parser.
|
73
|
+
def set_string string, pos
|
74
|
+
@string = string
|
75
|
+
@string_size = string ? string.size : 0
|
76
|
+
@pos = pos
|
77
|
+
end
|
78
|
+
|
74
79
|
def show_pos
|
75
80
|
width = 10
|
76
81
|
if @pos < width
|
@@ -177,19 +182,19 @@ class RDoc::Markdown::Literals
|
|
177
182
|
return nil
|
178
183
|
end
|
179
184
|
|
180
|
-
if "".respond_to? :
|
185
|
+
if "".respond_to? :ord
|
181
186
|
def get_byte
|
182
|
-
if @pos >= @
|
187
|
+
if @pos >= @string_size
|
183
188
|
return nil
|
184
189
|
end
|
185
190
|
|
186
|
-
s = @string
|
191
|
+
s = @string[@pos].ord
|
187
192
|
@pos += 1
|
188
193
|
s
|
189
194
|
end
|
190
195
|
else
|
191
196
|
def get_byte
|
192
|
-
if @pos >= @
|
197
|
+
if @pos >= @string_size
|
193
198
|
return nil
|
194
199
|
end
|
195
200
|
|
@@ -238,8 +243,7 @@ class RDoc::Markdown::Literals
|
|
238
243
|
old_pos = @pos
|
239
244
|
old_string = @string
|
240
245
|
|
241
|
-
|
242
|
-
@string = other.string
|
246
|
+
set_string other.string, other.pos
|
243
247
|
|
244
248
|
begin
|
245
249
|
if val = __send__(rule, *args)
|
@@ -250,8 +254,7 @@ class RDoc::Markdown::Literals
|
|
250
254
|
end
|
251
255
|
val
|
252
256
|
ensure
|
253
|
-
|
254
|
-
@string = old_string
|
257
|
+
set_string old_string, old_pos
|
255
258
|
end
|
256
259
|
end
|
257
260
|
|
data/lib/rdoc/markup.rb
CHANGED
@@ -127,7 +127,7 @@
|
|
127
127
|
# left, so the amount of indentation of verbatim text is unimportant.
|
128
128
|
#
|
129
129
|
# For HTML output RDoc makes a small effort to determine if a verbatim section
|
130
|
-
# contains
|
130
|
+
# contains Ruby source code. If so, the verbatim block will be marked up as
|
131
131
|
# HTML. Triggers include "def", "class", "module", "require", the "hash
|
132
132
|
# rocket"# (=>) or a block call with a parameter.
|
133
133
|
#
|
@@ -171,22 +171,13 @@
|
|
171
171
|
# === Rules
|
172
172
|
#
|
173
173
|
# A line starting with three or more hyphens (at the current indent)
|
174
|
-
# generates a horizontal rule.
|
175
|
-
# (within reason, and if supported by the output device).
|
176
|
-
#
|
177
|
-
# In the case of HTML output, three dashes generate a 1-pixel high rule,
|
178
|
-
# four dashes result in 2 pixels, and so on. The actual height is limited
|
179
|
-
# to 10 pixels:
|
174
|
+
# generates a horizontal rule.
|
180
175
|
#
|
181
176
|
# ---
|
182
|
-
# -----
|
183
|
-
# -----------------------------------------------------
|
184
177
|
#
|
185
178
|
# produces:
|
186
179
|
#
|
187
180
|
# ---
|
188
|
-
# -----
|
189
|
-
# -----------------------------------------------------
|
190
181
|
#
|
191
182
|
# === Simple Lists
|
192
183
|
#
|
@@ -356,12 +347,18 @@
|
|
356
347
|
# with <tt>+</tt> like <tt>RDoc::Markup@Escaping+Text+Markup</tt>.
|
357
348
|
# Punctuation and other special characters must be escaped like CGI.escape.
|
358
349
|
#
|
350
|
+
# The <tt>@</tt> can also be used to link to sections. If a section and a
|
351
|
+
# heading share the same name the section is preferred for the link.
|
352
|
+
#
|
359
353
|
# Links can also be of the form <tt>label[url]</tt>, in which case +label+ is
|
360
354
|
# used in the displayed text, and +url+ is used as the target. If +label+
|
361
355
|
# contains multiple words, put it in braces: <tt>{multi word label}[url]</tt>.
|
362
356
|
# The +url+ may be an +http:+-type link or a cross-reference to a class,
|
363
357
|
# module or method with a label.
|
364
358
|
#
|
359
|
+
# Links with the <code>rdoc-image:</code> scheme will create an image tag for
|
360
|
+
# HTML output. Only fully-qualified URLs are supported.
|
361
|
+
#
|
365
362
|
# Links with the <tt>rdoc-ref:</tt> scheme will link to the referenced class,
|
366
363
|
# module, method, file, etc. If the referenced item is does not exist
|
367
364
|
# no link will be generated and <tt>rdoc-ref:</tt> will be removed from the
|
@@ -683,7 +680,7 @@
|
|
683
680
|
#
|
684
681
|
# [+:markup:+ _type_]
|
685
682
|
# Overrides the default markup type for this comment with the specified
|
686
|
-
# markup type. For
|
683
|
+
# markup type. For Ruby files, if the first comment contains this directive
|
687
684
|
# it is applied automatically to all comments in the file.
|
688
685
|
#
|
689
686
|
# Unless you are converting between markup formats you should use a
|
@@ -713,7 +710,7 @@
|
|
713
710
|
# def some_method
|
714
711
|
# # ...
|
715
712
|
#
|
716
|
-
# See Markup@
|
713
|
+
# See Markup@CONTRIBUTING for instructions on adding a new markup format.
|
717
714
|
#
|
718
715
|
# [+:include:+ _filename_]
|
719
716
|
# Include the contents of the named file at this point. This directive
|
@@ -186,8 +186,9 @@ class RDoc::Markup::AttributeManager
|
|
186
186
|
# protect __send__, __FILE__, etc.
|
187
187
|
@str.gsub!(/__([a-z]+)__/i,
|
188
188
|
"_#{PROTECT_ATTR}_#{PROTECT_ATTR}\\1_#{PROTECT_ATTR}_#{PROTECT_ATTR}")
|
189
|
-
@str.gsub!(
|
190
|
-
"\\1#{PROTECT_ATTR}")
|
189
|
+
@str.gsub!(/(\A|[^\\])\\([#{Regexp.escape @protectable.join}])/m,
|
190
|
+
"\\1\\2#{PROTECT_ATTR}")
|
191
|
+
@str.gsub!(/\\(\\[#{Regexp.escape @protectable.join}])/m, "\\1")
|
191
192
|
end
|
192
193
|
|
193
194
|
##
|
@@ -80,7 +80,7 @@ class RDoc::Markup::Formatter
|
|
80
80
|
# Adds a special for links of the form rdoc-...:
|
81
81
|
|
82
82
|
def add_special_RDOCLINK
|
83
|
-
@markup.add_special(/rdoc-[a-z]
|
83
|
+
@markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
|
84
84
|
end
|
85
85
|
|
86
86
|
##
|
@@ -88,7 +88,7 @@ class RDoc::Markup::Formatter
|
|
88
88
|
|
89
89
|
def add_special_TIDYLINK
|
90
90
|
@markup.add_special(/(?:
|
91
|
-
\{.*?\} |
|
91
|
+
\{.*?\} | # multi-word label
|
92
92
|
\b[^\s{}]+? # single-word label
|
93
93
|
)
|
94
94
|
|
@@ -239,7 +239,7 @@ class RDoc::Markup::Formatter
|
|
239
239
|
else
|
240
240
|
scheme = 'http'
|
241
241
|
path = url
|
242
|
-
url =
|
242
|
+
url = url
|
243
243
|
end
|
244
244
|
|
245
245
|
if scheme == 'link' then
|
data/lib/rdoc/markup/heading.rb
CHANGED
@@ -47,6 +47,19 @@ RDoc::Markup::Heading =
|
|
47
47
|
"label-#{self.class.to_label.convert text.dup}"
|
48
48
|
end
|
49
49
|
|
50
|
+
##
|
51
|
+
# Creates a fully-qualified label which will include the label from
|
52
|
+
# +context+. This helps keep ids unique in HTML.
|
53
|
+
|
54
|
+
def label context = nil
|
55
|
+
label = aref
|
56
|
+
|
57
|
+
label = [context.aref, label].compact.join '-' if
|
58
|
+
context and context.respond_to? :aref
|
59
|
+
|
60
|
+
label
|
61
|
+
end
|
62
|
+
|
50
63
|
##
|
51
64
|
# HTML markup of the text of this label without the surrounding header
|
52
65
|
# element.
|
data/lib/rdoc/markup/parser.rb
CHANGED
@@ -389,7 +389,7 @@ class RDoc::Markup::Parser
|
|
389
389
|
skip :NEWLINE
|
390
390
|
when :TEXT then
|
391
391
|
unget
|
392
|
-
parent
|
392
|
+
parse_text parent, indent
|
393
393
|
when *LIST_TOKENS then
|
394
394
|
unget
|
395
395
|
parent << build_list(indent)
|
@@ -405,6 +405,13 @@ class RDoc::Markup::Parser
|
|
405
405
|
|
406
406
|
end
|
407
407
|
|
408
|
+
##
|
409
|
+
# Small hook that is overridden by RDoc::TomDoc
|
410
|
+
|
411
|
+
def parse_text parent, indent # :nodoc:
|
412
|
+
parent << build_paragraph(indent)
|
413
|
+
end
|
414
|
+
|
408
415
|
##
|
409
416
|
# Returns the next token on the stream without modifying the stream
|
410
417
|
|
@@ -528,8 +535,8 @@ class RDoc::Markup::Parser
|
|
528
535
|
end
|
529
536
|
|
530
537
|
##
|
531
|
-
# Calculates the column (by character) and line of the current token
|
532
|
-
#
|
538
|
+
# Calculates the column (by character) and line of the current token based
|
539
|
+
# on +byte_offset+.
|
533
540
|
|
534
541
|
def token_pos byte_offset
|
535
542
|
offset = char_pos byte_offset
|
data/lib/rdoc/markup/to_html.rb
CHANGED
@@ -65,6 +65,30 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
65
65
|
#
|
66
66
|
# These methods handle special markup added by RDoc::Markup#add_special.
|
67
67
|
|
68
|
+
def handle_RDOCLINK url # :nodoc:
|
69
|
+
case url
|
70
|
+
when /^rdoc-ref:/
|
71
|
+
$'
|
72
|
+
when /^rdoc-label:/
|
73
|
+
text = $'
|
74
|
+
|
75
|
+
text = case text
|
76
|
+
when /\Alabel-/ then $'
|
77
|
+
when /\Afootmark-/ then $'
|
78
|
+
when /\Afoottext-/ then $'
|
79
|
+
else text
|
80
|
+
end
|
81
|
+
|
82
|
+
gen_url url, text
|
83
|
+
when /^rdoc-image:/
|
84
|
+
"<img src=\"#{$'}\">"
|
85
|
+
else
|
86
|
+
url =~ /\Ardoc-[a-z]+:/
|
87
|
+
|
88
|
+
$'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
68
92
|
##
|
69
93
|
# +special+ is a <code><br></code>
|
70
94
|
|
@@ -100,27 +124,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
100
124
|
# when creating a link. All other contents will be linked verbatim.
|
101
125
|
|
102
126
|
def handle_special_RDOCLINK special
|
103
|
-
|
104
|
-
|
105
|
-
case url
|
106
|
-
when /\Ardoc-ref:/
|
107
|
-
$'
|
108
|
-
when /\Ardoc-label:/
|
109
|
-
text = $'
|
110
|
-
|
111
|
-
text = case text
|
112
|
-
when /\Alabel-/ then $'
|
113
|
-
when /\Afootmark-/ then "^#{$'}"
|
114
|
-
when /\Afoottext-/ then "*#{$'}"
|
115
|
-
else text
|
116
|
-
end
|
117
|
-
|
118
|
-
gen_url url, text
|
119
|
-
else
|
120
|
-
url =~ /\Ardoc-[a-z]+:/
|
121
|
-
|
122
|
-
$'
|
123
|
-
end
|
127
|
+
handle_RDOCLINK special.text
|
124
128
|
end
|
125
129
|
|
126
130
|
##
|
@@ -130,10 +134,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
130
134
|
def handle_special_TIDYLINK(special)
|
131
135
|
text = special.text
|
132
136
|
|
133
|
-
return text unless
|
137
|
+
return text unless
|
138
|
+
text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/
|
134
139
|
|
135
140
|
label = $1
|
136
141
|
url = $2
|
142
|
+
|
143
|
+
label = handle_RDOCLINK label if /^rdoc-image:/ =~ label
|
144
|
+
|
137
145
|
gen_url url, label
|
138
146
|
end
|
139
147
|
|
@@ -212,10 +220,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
212
220
|
##
|
213
221
|
# Adds +rule+ to the output
|
214
222
|
|
215
|
-
def accept_rule
|
216
|
-
|
217
|
-
size = 10 if size > 10
|
218
|
-
@res << "<hr style=\"height: #{size}px\">\n"
|
223
|
+
def accept_rule rule
|
224
|
+
@res << "<hr>\n"
|
219
225
|
end
|
220
226
|
|
221
227
|
##
|
@@ -270,11 +276,13 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
270
276
|
def accept_heading heading
|
271
277
|
level = [6, heading.level].min
|
272
278
|
|
273
|
-
label = heading.
|
274
|
-
label = [@code_object.aref, label].compact.join '-' if
|
275
|
-
@code_object and @code_object.respond_to? :aref
|
279
|
+
label = heading.label @code_object
|
276
280
|
|
277
|
-
@res <<
|
281
|
+
@res << if @options.output_decoration
|
282
|
+
"\n<h#{level} id=\"#{label}\">"
|
283
|
+
else
|
284
|
+
"\n<h#{level}>"
|
285
|
+
end
|
278
286
|
@res << to_html(heading.text)
|
279
287
|
unless @options.pipe then
|
280
288
|
@res << "<span><a href=\"##{label}\">¶</a>"
|
@@ -310,7 +318,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
310
318
|
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
|
311
319
|
"<img src=\"#{url}\" />"
|
312
320
|
else
|
313
|
-
|
321
|
+
text = text.sub %r%^#{scheme}:/*%i, ''
|
322
|
+
text = text.sub %r%^[*\^](\d+)$%, '\1'
|
323
|
+
|
324
|
+
link = "<a#{id} href=\"#{url}\">#{text}</a>"
|
325
|
+
|
326
|
+
link = "<sup>#{link}</sup>" if /"foot/ =~ id
|
327
|
+
|
328
|
+
link
|
314
329
|
end
|
315
330
|
end
|
316
331
|
|