rdoc 3.12.2 → 4.0.0.preview2
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 +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +3 -2
- data/DEVELOPERS.rdoc +53 -0
- data/History.rdoc +159 -25
- data/LEGAL.rdoc +12 -0
- data/Manifest.txt +56 -3
- data/README.rdoc +87 -19
- data/Rakefile +11 -2
- data/TODO.rdoc +20 -13
- data/bin/rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +1 -1
- data/lib/rdoc.rb +32 -71
- data/lib/rdoc/any_method.rb +75 -21
- data/lib/rdoc/attr.rb +49 -10
- data/lib/rdoc/class_module.rb +182 -32
- data/lib/rdoc/code_object.rb +54 -12
- data/lib/rdoc/comment.rb +8 -1
- data/lib/rdoc/constant.rb +100 -6
- data/lib/rdoc/context.rb +93 -41
- data/lib/rdoc/context/section.rb +143 -28
- data/lib/rdoc/cross_reference.rb +58 -50
- data/lib/rdoc/encoding.rb +34 -29
- data/lib/rdoc/erb_partial.rb +18 -0
- data/lib/rdoc/extend.rb +117 -0
- data/lib/rdoc/generator.rb +11 -6
- data/lib/rdoc/generator/darkfish.rb +250 -62
- data/lib/rdoc/generator/json_index.rb +20 -12
- data/lib/rdoc/generator/markup.rb +10 -12
- data/lib/rdoc/generator/ri.rb +7 -60
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/include.rb +12 -3
- data/lib/rdoc/markdown.kpeg +1186 -0
- data/lib/rdoc/markdown.rb +16336 -0
- data/lib/rdoc/markdown/entities.rb +2128 -0
- data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
- data/lib/rdoc/markdown/literals_1_8.rb +454 -0
- data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
- data/lib/rdoc/markdown/literals_1_9.rb +417 -0
- data/lib/rdoc/markup.rb +69 -10
- data/lib/rdoc/markup/attr_changer.rb +2 -5
- data/lib/rdoc/markup/attribute_manager.rb +23 -14
- data/lib/rdoc/markup/attributes.rb +70 -0
- data/lib/rdoc/markup/block_quote.rb +14 -0
- data/lib/rdoc/markup/document.rb +20 -4
- data/lib/rdoc/markup/formatter.rb +17 -6
- data/lib/rdoc/markup/formatter_test_case.rb +93 -24
- data/lib/rdoc/markup/hard_break.rb +31 -0
- data/lib/rdoc/markup/heading.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +14 -0
- data/lib/rdoc/markup/list.rb +23 -4
- data/lib/rdoc/markup/list_item.rb +17 -4
- data/lib/rdoc/markup/paragraph.rb +14 -0
- data/lib/rdoc/markup/parser.rb +107 -60
- data/lib/rdoc/markup/raw.rb +4 -4
- data/lib/rdoc/markup/special.rb +3 -3
- data/lib/rdoc/markup/to_ansi.rb +7 -1
- data/lib/rdoc/markup/to_html.rb +42 -14
- data/lib/rdoc/markup/to_html_crossref.rb +10 -9
- data/lib/rdoc/markup/to_html_snippet.rb +20 -4
- data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
- data/lib/rdoc/markup/to_label.rb +20 -1
- data/lib/rdoc/markup/to_markdown.rb +134 -0
- data/lib/rdoc/markup/to_rdoc.rb +36 -5
- data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
- data/lib/rdoc/markup/to_tt_only.rb +11 -2
- data/lib/rdoc/markup/verbatim.rb +19 -0
- data/lib/rdoc/method_attr.rb +33 -19
- data/lib/rdoc/normal_class.rb +26 -7
- data/lib/rdoc/normal_module.rb +10 -5
- data/lib/rdoc/options.rb +95 -21
- data/lib/rdoc/parser.rb +6 -2
- data/lib/rdoc/parser/c.rb +212 -97
- data/lib/rdoc/parser/markdown.rb +23 -0
- data/lib/rdoc/parser/ruby.rb +115 -35
- data/lib/rdoc/parser/ruby_tools.rb +8 -3
- data/lib/rdoc/rd.rb +8 -4
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/block_parser.ry +1 -1
- data/lib/rdoc/rdoc.rb +45 -21
- data/lib/rdoc/ri/driver.rb +322 -76
- data/lib/rdoc/ri/paths.rb +90 -31
- data/lib/rdoc/ri/store.rb +2 -353
- data/lib/rdoc/ruby_lex.rb +5 -21
- data/lib/rdoc/ruby_token.rb +2 -3
- data/lib/rdoc/rubygems_hook.rb +21 -9
- data/lib/rdoc/servlet.rb +302 -0
- data/lib/rdoc/stats.rb +28 -20
- data/lib/rdoc/store.rb +881 -0
- data/lib/rdoc/task.rb +2 -1
- data/lib/rdoc/test_case.rb +103 -1
- data/lib/rdoc/text.rb +5 -4
- data/lib/rdoc/tom_doc.rb +17 -16
- data/lib/rdoc/top_level.rb +43 -285
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
- data/test/test_attribute_manager.rb +7 -4
- data/test/test_rdoc_any_method.rb +84 -13
- data/test/test_rdoc_attr.rb +59 -9
- data/test/test_rdoc_class_module.rb +670 -73
- data/test/test_rdoc_code_object.rb +21 -1
- data/test/test_rdoc_comment.rb +1 -1
- data/test/test_rdoc_constant.rb +132 -0
- data/test/test_rdoc_context.rb +84 -18
- data/test/test_rdoc_context_section.rb +99 -15
- data/test/test_rdoc_cross_reference.rb +1 -1
- data/test/test_rdoc_encoding.rb +17 -1
- data/test/test_rdoc_extend.rb +94 -0
- data/test/test_rdoc_generator_darkfish.rb +45 -19
- data/test/test_rdoc_generator_json_index.rb +27 -7
- data/test/test_rdoc_generator_markup.rb +3 -3
- data/test/test_rdoc_generator_ri.rb +11 -9
- data/test/test_rdoc_include.rb +12 -0
- data/test/test_rdoc_markdown.rb +977 -0
- data/test/test_rdoc_markdown_test.rb +1891 -0
- data/test/test_rdoc_markup.rb +1 -1
- data/test/test_rdoc_markup_attribute_manager.rb +2 -2
- data/test/test_rdoc_markup_attributes.rb +39 -0
- data/test/test_rdoc_markup_document.rb +16 -1
- data/test/test_rdoc_markup_formatter.rb +7 -4
- data/test/test_rdoc_markup_hard_break.rb +31 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
- data/test/test_rdoc_markup_paragraph.rb +15 -1
- data/test/test_rdoc_markup_parser.rb +152 -89
- data/test/test_rdoc_markup_to_ansi.rb +23 -2
- data/test/test_rdoc_markup_to_bs.rb +24 -0
- data/test/test_rdoc_markup_to_html.rb +50 -19
- data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
- data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
- data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
- data/test/test_rdoc_markup_to_label.rb +63 -1
- data/test/test_rdoc_markup_to_markdown.rb +352 -0
- data/test/test_rdoc_markup_to_rdoc.rb +22 -2
- data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
- data/test/test_rdoc_markup_to_tt_only.rb +20 -0
- data/test/test_rdoc_markup_verbatim.rb +13 -0
- data/test/test_rdoc_method_attr.rb +5 -0
- data/test/test_rdoc_normal_class.rb +24 -5
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_options.rb +21 -6
- data/test/test_rdoc_parser.rb +24 -0
- data/test/test_rdoc_parser_c.rb +151 -26
- data/test/test_rdoc_parser_markdown.rb +55 -0
- data/test/test_rdoc_parser_rd.rb +2 -2
- data/test/test_rdoc_parser_ruby.rb +468 -109
- data/test/test_rdoc_parser_simple.rb +2 -2
- data/test/test_rdoc_rd_block_parser.rb +0 -4
- data/test/test_rdoc_rdoc.rb +110 -22
- data/test/test_rdoc_ri_driver.rb +415 -80
- data/test/test_rdoc_ri_paths.rb +122 -13
- data/test/test_rdoc_ruby_lex.rb +5 -61
- data/test/test_rdoc_ruby_token.rb +19 -0
- data/test/test_rdoc_rubygems_hook.rb +64 -43
- data/test/test_rdoc_servlet.rb +429 -0
- data/test/test_rdoc_stats.rb +83 -24
- data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
- data/test/test_rdoc_task.rb +2 -2
- data/test/test_rdoc_text.rb +37 -11
- data/test/test_rdoc_tom_doc.rb +59 -62
- data/test/test_rdoc_top_level.rb +71 -113
- data/test/xref_test_case.rb +7 -9
- metadata +122 -39
- metadata.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/lib/rdoc/markup/attribute.rb +0 -51
@@ -0,0 +1,22 @@
|
|
1
|
+
%% name = RDoc::Markdown::Literals
|
2
|
+
|
3
|
+
%% header {
|
4
|
+
# coding: UTF-8
|
5
|
+
# :markup: markdown
|
6
|
+
|
7
|
+
##
|
8
|
+
#--
|
9
|
+
# This set of literals is for ruby 1.9 regular expressions and gives full
|
10
|
+
# unicode support.
|
11
|
+
#
|
12
|
+
# Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric
|
13
|
+
# characters, newlines and spaces.
|
14
|
+
}
|
15
|
+
|
16
|
+
Alphanumeric = /\p{Word}/
|
17
|
+
AlphanumericAscii = /[A-Za-z0-9]/
|
18
|
+
BOM = "\uFEFF"
|
19
|
+
Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
|
20
|
+
NonAlphanumeric = /\p{^Word}/
|
21
|
+
Spacechar = /\t|\p{Zs}/
|
22
|
+
|
@@ -0,0 +1,417 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
# :markup: markdown
|
3
|
+
|
4
|
+
##
|
5
|
+
#--
|
6
|
+
# This set of literals is for ruby 1.9 regular expressions and gives full
|
7
|
+
# unicode support.
|
8
|
+
#
|
9
|
+
# Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric
|
10
|
+
# characters, newlines and spaces.
|
11
|
+
class RDoc::Markdown::Literals
|
12
|
+
# :stopdoc:
|
13
|
+
|
14
|
+
# This is distinct from setup_parser so that a standalone parser
|
15
|
+
# can redefine #initialize and still have access to the proper
|
16
|
+
# parser setup code.
|
17
|
+
def initialize(str, debug=false)
|
18
|
+
setup_parser(str, debug)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
# Prepares for parsing +str+. If you define a custom initialize you must
|
24
|
+
# call this method before #parse
|
25
|
+
def setup_parser(str, debug=false)
|
26
|
+
@string = str
|
27
|
+
@pos = 0
|
28
|
+
@memoizations = Hash.new { |h,k| h[k] = {} }
|
29
|
+
@result = nil
|
30
|
+
@failed_rule = nil
|
31
|
+
@failing_rule_offset = -1
|
32
|
+
|
33
|
+
setup_foreign_grammar
|
34
|
+
end
|
35
|
+
|
36
|
+
attr_reader :string
|
37
|
+
attr_reader :failing_rule_offset
|
38
|
+
attr_accessor :result, :pos
|
39
|
+
|
40
|
+
|
41
|
+
def current_column(target=pos)
|
42
|
+
if c = string.rindex("\n", target-1)
|
43
|
+
return target - c - 1
|
44
|
+
end
|
45
|
+
|
46
|
+
target + 1
|
47
|
+
end
|
48
|
+
|
49
|
+
def current_line(target=pos)
|
50
|
+
cur_offset = 0
|
51
|
+
cur_line = 0
|
52
|
+
|
53
|
+
string.each_line do |line|
|
54
|
+
cur_line += 1
|
55
|
+
cur_offset += line.size
|
56
|
+
return cur_line if cur_offset >= target
|
57
|
+
end
|
58
|
+
|
59
|
+
-1
|
60
|
+
end
|
61
|
+
|
62
|
+
def lines
|
63
|
+
lines = []
|
64
|
+
string.each_line { |l| lines << l }
|
65
|
+
lines
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
def get_text(start)
|
71
|
+
@string[start..@pos-1]
|
72
|
+
end
|
73
|
+
|
74
|
+
def show_pos
|
75
|
+
width = 10
|
76
|
+
if @pos < width
|
77
|
+
"#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
|
78
|
+
else
|
79
|
+
"#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def failure_info
|
84
|
+
l = current_line @failing_rule_offset
|
85
|
+
c = current_column @failing_rule_offset
|
86
|
+
|
87
|
+
if @failed_rule.kind_of? Symbol
|
88
|
+
info = self.class::Rules[@failed_rule]
|
89
|
+
"line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
|
90
|
+
else
|
91
|
+
"line #{l}, column #{c}: failed rule '#{@failed_rule}'"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def failure_caret
|
96
|
+
l = current_line @failing_rule_offset
|
97
|
+
c = current_column @failing_rule_offset
|
98
|
+
|
99
|
+
line = lines[l-1]
|
100
|
+
"#{line}\n#{' ' * (c - 1)}^"
|
101
|
+
end
|
102
|
+
|
103
|
+
def failure_character
|
104
|
+
l = current_line @failing_rule_offset
|
105
|
+
c = current_column @failing_rule_offset
|
106
|
+
lines[l-1][c-1, 1]
|
107
|
+
end
|
108
|
+
|
109
|
+
def failure_oneline
|
110
|
+
l = current_line @failing_rule_offset
|
111
|
+
c = current_column @failing_rule_offset
|
112
|
+
|
113
|
+
char = lines[l-1][c-1, 1]
|
114
|
+
|
115
|
+
if @failed_rule.kind_of? Symbol
|
116
|
+
info = self.class::Rules[@failed_rule]
|
117
|
+
"@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
|
118
|
+
else
|
119
|
+
"@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class ParseError < RuntimeError
|
124
|
+
end
|
125
|
+
|
126
|
+
def raise_error
|
127
|
+
raise ParseError, failure_oneline
|
128
|
+
end
|
129
|
+
|
130
|
+
def show_error(io=STDOUT)
|
131
|
+
error_pos = @failing_rule_offset
|
132
|
+
line_no = current_line(error_pos)
|
133
|
+
col_no = current_column(error_pos)
|
134
|
+
|
135
|
+
io.puts "On line #{line_no}, column #{col_no}:"
|
136
|
+
|
137
|
+
if @failed_rule.kind_of? Symbol
|
138
|
+
info = self.class::Rules[@failed_rule]
|
139
|
+
io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
|
140
|
+
else
|
141
|
+
io.puts "Failed to match rule '#{@failed_rule}'"
|
142
|
+
end
|
143
|
+
|
144
|
+
io.puts "Got: #{string[error_pos,1].inspect}"
|
145
|
+
line = lines[line_no-1]
|
146
|
+
io.puts "=> #{line}"
|
147
|
+
io.print(" " * (col_no + 3))
|
148
|
+
io.puts "^"
|
149
|
+
end
|
150
|
+
|
151
|
+
def set_failed_rule(name)
|
152
|
+
if @pos > @failing_rule_offset
|
153
|
+
@failed_rule = name
|
154
|
+
@failing_rule_offset = @pos
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
attr_reader :failed_rule
|
159
|
+
|
160
|
+
def match_string(str)
|
161
|
+
len = str.size
|
162
|
+
if @string[pos,len] == str
|
163
|
+
@pos += len
|
164
|
+
return str
|
165
|
+
end
|
166
|
+
|
167
|
+
return nil
|
168
|
+
end
|
169
|
+
|
170
|
+
def scan(reg)
|
171
|
+
if m = reg.match(@string[@pos..-1])
|
172
|
+
width = m.end(0)
|
173
|
+
@pos += width
|
174
|
+
return true
|
175
|
+
end
|
176
|
+
|
177
|
+
return nil
|
178
|
+
end
|
179
|
+
|
180
|
+
if "".respond_to? :getbyte
|
181
|
+
def get_byte
|
182
|
+
if @pos >= @string.size
|
183
|
+
return nil
|
184
|
+
end
|
185
|
+
|
186
|
+
s = @string.getbyte @pos
|
187
|
+
@pos += 1
|
188
|
+
s
|
189
|
+
end
|
190
|
+
else
|
191
|
+
def get_byte
|
192
|
+
if @pos >= @string.size
|
193
|
+
return nil
|
194
|
+
end
|
195
|
+
|
196
|
+
s = @string[@pos]
|
197
|
+
@pos += 1
|
198
|
+
s
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def parse(rule=nil)
|
203
|
+
# We invoke the rules indirectly via apply
|
204
|
+
# instead of by just calling them as methods because
|
205
|
+
# if the rules use left recursion, apply needs to
|
206
|
+
# manage that.
|
207
|
+
|
208
|
+
if !rule
|
209
|
+
apply(:_root)
|
210
|
+
else
|
211
|
+
method = rule.gsub("-","_hyphen_")
|
212
|
+
apply :"_#{method}"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
class MemoEntry
|
217
|
+
def initialize(ans, pos)
|
218
|
+
@ans = ans
|
219
|
+
@pos = pos
|
220
|
+
@result = nil
|
221
|
+
@set = false
|
222
|
+
@left_rec = false
|
223
|
+
end
|
224
|
+
|
225
|
+
attr_reader :ans, :pos, :result, :set
|
226
|
+
attr_accessor :left_rec
|
227
|
+
|
228
|
+
def move!(ans, pos, result)
|
229
|
+
@ans = ans
|
230
|
+
@pos = pos
|
231
|
+
@result = result
|
232
|
+
@set = true
|
233
|
+
@left_rec = false
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def external_invoke(other, rule, *args)
|
238
|
+
old_pos = @pos
|
239
|
+
old_string = @string
|
240
|
+
|
241
|
+
@pos = other.pos
|
242
|
+
@string = other.string
|
243
|
+
|
244
|
+
begin
|
245
|
+
if val = __send__(rule, *args)
|
246
|
+
other.pos = @pos
|
247
|
+
other.result = @result
|
248
|
+
else
|
249
|
+
other.set_failed_rule "#{self.class}##{rule}"
|
250
|
+
end
|
251
|
+
val
|
252
|
+
ensure
|
253
|
+
@pos = old_pos
|
254
|
+
@string = old_string
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def apply_with_args(rule, *args)
|
259
|
+
memo_key = [rule, args]
|
260
|
+
if m = @memoizations[memo_key][@pos]
|
261
|
+
@pos = m.pos
|
262
|
+
if !m.set
|
263
|
+
m.left_rec = true
|
264
|
+
return nil
|
265
|
+
end
|
266
|
+
|
267
|
+
@result = m.result
|
268
|
+
|
269
|
+
return m.ans
|
270
|
+
else
|
271
|
+
m = MemoEntry.new(nil, @pos)
|
272
|
+
@memoizations[memo_key][@pos] = m
|
273
|
+
start_pos = @pos
|
274
|
+
|
275
|
+
ans = __send__ rule, *args
|
276
|
+
|
277
|
+
lr = m.left_rec
|
278
|
+
|
279
|
+
m.move! ans, @pos, @result
|
280
|
+
|
281
|
+
# Don't bother trying to grow the left recursion
|
282
|
+
# if it's failing straight away (thus there is no seed)
|
283
|
+
if ans and lr
|
284
|
+
return grow_lr(rule, args, start_pos, m)
|
285
|
+
else
|
286
|
+
return ans
|
287
|
+
end
|
288
|
+
|
289
|
+
return ans
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def apply(rule)
|
294
|
+
if m = @memoizations[rule][@pos]
|
295
|
+
@pos = m.pos
|
296
|
+
if !m.set
|
297
|
+
m.left_rec = true
|
298
|
+
return nil
|
299
|
+
end
|
300
|
+
|
301
|
+
@result = m.result
|
302
|
+
|
303
|
+
return m.ans
|
304
|
+
else
|
305
|
+
m = MemoEntry.new(nil, @pos)
|
306
|
+
@memoizations[rule][@pos] = m
|
307
|
+
start_pos = @pos
|
308
|
+
|
309
|
+
ans = __send__ rule
|
310
|
+
|
311
|
+
lr = m.left_rec
|
312
|
+
|
313
|
+
m.move! ans, @pos, @result
|
314
|
+
|
315
|
+
# Don't bother trying to grow the left recursion
|
316
|
+
# if it's failing straight away (thus there is no seed)
|
317
|
+
if ans and lr
|
318
|
+
return grow_lr(rule, nil, start_pos, m)
|
319
|
+
else
|
320
|
+
return ans
|
321
|
+
end
|
322
|
+
|
323
|
+
return ans
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
def grow_lr(rule, args, start_pos, m)
|
328
|
+
while true
|
329
|
+
@pos = start_pos
|
330
|
+
@result = m.result
|
331
|
+
|
332
|
+
if args
|
333
|
+
ans = __send__ rule, *args
|
334
|
+
else
|
335
|
+
ans = __send__ rule
|
336
|
+
end
|
337
|
+
return nil unless ans
|
338
|
+
|
339
|
+
break if @pos <= m.pos
|
340
|
+
|
341
|
+
m.move! ans, @pos, @result
|
342
|
+
end
|
343
|
+
|
344
|
+
@result = m.result
|
345
|
+
@pos = m.pos
|
346
|
+
return m.ans
|
347
|
+
end
|
348
|
+
|
349
|
+
class RuleInfo
|
350
|
+
def initialize(name, rendered)
|
351
|
+
@name = name
|
352
|
+
@rendered = rendered
|
353
|
+
end
|
354
|
+
|
355
|
+
attr_reader :name, :rendered
|
356
|
+
end
|
357
|
+
|
358
|
+
def self.rule_info(name, rendered)
|
359
|
+
RuleInfo.new(name, rendered)
|
360
|
+
end
|
361
|
+
|
362
|
+
|
363
|
+
# :startdoc:
|
364
|
+
# :stopdoc:
|
365
|
+
def setup_foreign_grammar; end
|
366
|
+
|
367
|
+
# Alphanumeric = /\p{Word}/
|
368
|
+
def _Alphanumeric
|
369
|
+
_tmp = scan(/\A(?-mix:\p{Word})/)
|
370
|
+
set_failed_rule :_Alphanumeric unless _tmp
|
371
|
+
return _tmp
|
372
|
+
end
|
373
|
+
|
374
|
+
# AlphanumericAscii = /[A-Za-z0-9]/
|
375
|
+
def _AlphanumericAscii
|
376
|
+
_tmp = scan(/\A(?-mix:[A-Za-z0-9])/)
|
377
|
+
set_failed_rule :_AlphanumericAscii unless _tmp
|
378
|
+
return _tmp
|
379
|
+
end
|
380
|
+
|
381
|
+
# BOM = "uFEFF"
|
382
|
+
def _BOM
|
383
|
+
_tmp = match_string("uFEFF")
|
384
|
+
set_failed_rule :_BOM unless _tmp
|
385
|
+
return _tmp
|
386
|
+
end
|
387
|
+
|
388
|
+
# Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
|
389
|
+
def _Newline
|
390
|
+
_tmp = scan(/\A(?-mix:\n|\r\n?|\p{Zl}|\p{Zp})/)
|
391
|
+
set_failed_rule :_Newline unless _tmp
|
392
|
+
return _tmp
|
393
|
+
end
|
394
|
+
|
395
|
+
# NonAlphanumeric = /\p{^Word}/
|
396
|
+
def _NonAlphanumeric
|
397
|
+
_tmp = scan(/\A(?-mix:\p{^Word})/)
|
398
|
+
set_failed_rule :_NonAlphanumeric unless _tmp
|
399
|
+
return _tmp
|
400
|
+
end
|
401
|
+
|
402
|
+
# Spacechar = /\t|\p{Zs}/
|
403
|
+
def _Spacechar
|
404
|
+
_tmp = scan(/\A(?-mix:\t|\p{Zs})/)
|
405
|
+
set_failed_rule :_Spacechar unless _tmp
|
406
|
+
return _tmp
|
407
|
+
end
|
408
|
+
|
409
|
+
Rules = {}
|
410
|
+
Rules[:_Alphanumeric] = rule_info("Alphanumeric", "/\\p{Word}/")
|
411
|
+
Rules[:_AlphanumericAscii] = rule_info("AlphanumericAscii", "/[A-Za-z0-9]/")
|
412
|
+
Rules[:_BOM] = rule_info("BOM", "\"uFEFF\"")
|
413
|
+
Rules[:_Newline] = rule_info("Newline", "/\\n|\\r\\n?|\\p{Zl}|\\p{Zp}/")
|
414
|
+
Rules[:_NonAlphanumeric] = rule_info("NonAlphanumeric", "/\\p{^Word}/")
|
415
|
+
Rules[:_Spacechar] = rule_info("Spacechar", "/\\t|\\p{Zs}/")
|
416
|
+
# :startdoc:
|
417
|
+
end
|
data/lib/rdoc/markup.rb
CHANGED
@@ -6,11 +6,44 @@
|
|
6
6
|
# is similar in spirit to that used on WikiWiki webs, where folks create web
|
7
7
|
# pages using a simple set of formatting rules.
|
8
8
|
#
|
9
|
-
# RDoc::Markup
|
10
|
-
#
|
9
|
+
# RDoc::Markup and other markup formats do no output formatting, this is
|
10
|
+
# handled by the RDoc::Markup::Formatter subclasses.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# = Supported Formats
|
13
|
+
#
|
14
|
+
# Besides the RDoc::Markup format, the following formats are built in to RDoc:
|
15
|
+
#
|
16
|
+
# markdown::
|
17
|
+
# The markdown format as described by
|
18
|
+
# http://daringfireball.net/projects/markdown/. See RDoc::Markdown for
|
19
|
+
# details on the parser and supported extensions.
|
20
|
+
# rd::
|
21
|
+
# The rdtool format. See RDoc::RD for details on the parser and format.
|
22
|
+
# tomdoc::
|
23
|
+
# The TomDoc format as described by http://tomdoc.org/. See RDoc::TomDoc
|
24
|
+
# for details on the parser and supported extensions.
|
25
|
+
#
|
26
|
+
# You can choose a markup format using the following methods:
|
27
|
+
#
|
28
|
+
# per project::
|
29
|
+
# If you build your documentation with rake use RDoc::Task#markup.
|
30
|
+
#
|
31
|
+
# If you build your documentation by hand run:
|
32
|
+
#
|
33
|
+
# rdoc --markup your_favorite_format --write-options
|
34
|
+
#
|
35
|
+
# and commit <tt>.rdoc_options</tt> and ship it with your packaged gem.
|
36
|
+
# per file::
|
37
|
+
# At the top of the file use the <tt>:markup:</tt> directive to set the
|
38
|
+
# default format for the rest of the file.
|
39
|
+
# per comment::
|
40
|
+
# Use the <tt>:markup:</tt> directive at the top of a comment you want
|
41
|
+
# to write in a different format.
|
42
|
+
#
|
43
|
+
# = RDoc::Markup
|
44
|
+
#
|
45
|
+
# RDoc::Markup is extensible at runtime: you can add \new markup elements to
|
46
|
+
# be recognized in the documents that RDoc::Markup parses.
|
14
47
|
#
|
15
48
|
# RDoc::Markup is intended to be the basis for a family of tools which share
|
16
49
|
# the common requirement that simple, plain-text should be rendered in a
|
@@ -30,7 +63,7 @@
|
|
30
63
|
#
|
31
64
|
# puts h.convert(input_string)
|
32
65
|
#
|
33
|
-
# You can extend the RDoc::Markup parser to
|
66
|
+
# You can extend the RDoc::Markup parser to recognize new markup
|
34
67
|
# sequences, and to add special processing for text that matches a
|
35
68
|
# regular expression. Here we make WikiWords significant to the parser,
|
36
69
|
# and also make the sequences {word} and \<no>text...</no> signify
|
@@ -653,11 +686,34 @@
|
|
653
686
|
# markup type. For ruby files, if the first comment contains this directive
|
654
687
|
# it is applied automatically to all comments in the file.
|
655
688
|
#
|
656
|
-
#
|
657
|
-
#
|
658
|
-
#
|
689
|
+
# Unless you are converting between markup formats you should use a
|
690
|
+
# <code>.rdoc_options</code> file to specify the default documentation
|
691
|
+
# format for your entire project. See RDoc::Options@Saved+Options for
|
692
|
+
# instructions.
|
693
|
+
#
|
694
|
+
# At the top of a file the +:markup:+ directive applies to the entire file:
|
695
|
+
#
|
696
|
+
# # coding: UTF-8
|
697
|
+
# # :markup: TomDoc
|
698
|
+
#
|
699
|
+
# # TomDoc comment here ...
|
700
|
+
#
|
701
|
+
# class MyClass
|
702
|
+
# # ...
|
703
|
+
#
|
704
|
+
# For just one comment:
|
705
|
+
#
|
706
|
+
# # ...
|
707
|
+
# end
|
708
|
+
#
|
709
|
+
# # :markup: RDoc
|
710
|
+
# #
|
711
|
+
# # This is a comment in RDoc markup format ...
|
712
|
+
#
|
713
|
+
# def some_method
|
714
|
+
# # ...
|
659
715
|
#
|
660
|
-
#
|
716
|
+
# See Markup@DEVELOPERS for instructions on adding a new markup format.
|
661
717
|
#
|
662
718
|
# [+:include:+ _filename_]
|
663
719
|
# Include the contents of the named file at this point. This directive
|
@@ -776,13 +832,15 @@ https://github.com/rdoc/rdoc/issues
|
|
776
832
|
# Inline markup classes
|
777
833
|
autoload :AttrChanger, 'rdoc/markup/attr_changer'
|
778
834
|
autoload :AttrSpan, 'rdoc/markup/attr_span'
|
779
|
-
autoload :
|
835
|
+
autoload :Attributes, 'rdoc/markup/attributes'
|
780
836
|
autoload :AttributeManager, 'rdoc/markup/attribute_manager'
|
781
837
|
autoload :Special, 'rdoc/markup/special'
|
782
838
|
|
783
839
|
# RDoc::Markup AST
|
784
840
|
autoload :BlankLine, 'rdoc/markup/blank_line'
|
841
|
+
autoload :BlockQuote, 'rdoc/markup/block_quote'
|
785
842
|
autoload :Document, 'rdoc/markup/document'
|
843
|
+
autoload :HardBreak, 'rdoc/markup/hard_break'
|
786
844
|
autoload :Heading, 'rdoc/markup/heading'
|
787
845
|
autoload :Include, 'rdoc/markup/include'
|
788
846
|
autoload :IndentedParagraph, 'rdoc/markup/indented_paragraph'
|
@@ -804,6 +862,7 @@ https://github.com/rdoc/rdoc/issues
|
|
804
862
|
autoload :ToHtmlCrossref, 'rdoc/markup/to_html_crossref'
|
805
863
|
autoload :ToHtmlSnippet, 'rdoc/markup/to_html_snippet'
|
806
864
|
autoload :ToLabel, 'rdoc/markup/to_label'
|
865
|
+
autoload :ToMarkdown, 'rdoc/markup/to_markdown'
|
807
866
|
autoload :ToRdoc, 'rdoc/markup/to_rdoc'
|
808
867
|
autoload :ToTableOfContents, 'rdoc/markup/to_table_of_contents'
|
809
868
|
autoload :ToTest, 'rdoc/markup/to_test'
|