rdoc 6.6.3.1 → 6.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.rdoc +1 -1
- data/ExampleMarkdown.md +2 -0
- data/ExampleRDoc.rdoc +2 -0
- data/History.rdoc +64 -62
- data/LICENSE.rdoc +2 -0
- data/README.rdoc +13 -0
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +1 -1
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +54 -0
- data/lib/rdoc/{context.rb → code_object/context.rb} +1 -1
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +3 -3
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +4 -4
- data/lib/rdoc/code_object.rb +6 -0
- data/lib/rdoc/generator/darkfish.rb +45 -3
- data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +1 -1
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +23 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +3 -8
- data/lib/rdoc/generator/template/darkfish/class.rhtml +69 -43
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +367 -392
- data/lib/rdoc/generator/template/darkfish/index.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +18 -1
- data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +5 -2
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +11 -0
- data/lib/rdoc/markdown.kpeg +3 -3
- data/lib/rdoc/markdown.rb +25 -15
- data/lib/rdoc/markup/attribute_manager.rb +2 -2
- data/lib/rdoc/markup/pre_process.rb +9 -6
- data/lib/rdoc/markup/to_bs.rb +26 -1
- data/lib/rdoc/markup/to_html_crossref.rb +12 -13
- data/lib/rdoc/markup/to_markdown.rb +4 -4
- data/lib/rdoc/markup/to_rdoc.rb +15 -7
- data/lib/rdoc/markup.rb +18 -13
- data/lib/rdoc/options.rb +23 -5
- data/lib/rdoc/parser/c.rb +19 -9
- data/lib/rdoc/parser/changelog.rb +2 -2
- data/lib/rdoc/parser/ripper_state_lex.rb +7 -305
- data/lib/rdoc/parser/ruby.rb +26 -8
- data/lib/rdoc/parser.rb +6 -3
- data/lib/rdoc/rd/block_parser.rb +3 -7
- data/lib/rdoc/rd/inline_parser.rb +3 -7
- data/lib/rdoc/rdoc.rb +3 -2
- data/lib/rdoc/ri/driver.rb +11 -7
- data/lib/rdoc/task.rb +2 -3
- data/lib/rdoc/tom_doc.rb +1 -7
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +23 -23
- metadata +27 -24
- data/RI.rdoc +0 -57
- /data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +0 -0
- /data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +0 -0
- /data/lib/rdoc/{attr.rb → code_object/attr.rb} +0 -0
- /data/lib/rdoc/{constant.rb → code_object/constant.rb} +0 -0
- /data/lib/rdoc/{context → code_object/context}/section.rb +0 -0
- /data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -0
- /data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +0 -0
- /data/lib/rdoc/{include.rb → code_object/include.rb} +0 -0
- /data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +0 -0
- /data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +0 -0
- /data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +0 -0
- /data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +0 -0
- /data/lib/rdoc/{require.rb → code_object/require.rb} +0 -0
- /data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +0 -0
data/lib/rdoc/options.rb
CHANGED
@@ -105,6 +105,7 @@ class RDoc::Options
|
|
105
105
|
generator_name
|
106
106
|
generator_options
|
107
107
|
generators
|
108
|
+
locale
|
108
109
|
op_dir
|
109
110
|
page_dir
|
110
111
|
option_parser
|
@@ -232,9 +233,9 @@ class RDoc::Options
|
|
232
233
|
attr_accessor :main_page
|
233
234
|
|
234
235
|
##
|
235
|
-
# The
|
236
|
-
#
|
237
|
-
|
236
|
+
# The markup format.
|
237
|
+
# One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
|
238
|
+
# See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
|
238
239
|
attr_accessor :markup
|
239
240
|
|
240
241
|
##
|
@@ -343,6 +344,11 @@ class RDoc::Options
|
|
343
344
|
# Indicates if files of test suites should be skipped
|
344
345
|
attr_accessor :skip_tests
|
345
346
|
|
347
|
+
##
|
348
|
+
# Embed mixin methods, attributes, and constants into class documentation. Set via
|
349
|
+
# +--[no-]embed-mixins+ (Default is +false+.)
|
350
|
+
attr_accessor :embed_mixins
|
351
|
+
|
346
352
|
def initialize loaded_options = nil # :nodoc:
|
347
353
|
init_ivars
|
348
354
|
override loaded_options if loaded_options
|
@@ -350,6 +356,7 @@ class RDoc::Options
|
|
350
356
|
|
351
357
|
def init_ivars # :nodoc:
|
352
358
|
@dry_run = false
|
359
|
+
@embed_mixins = false
|
353
360
|
@exclude = %w[
|
354
361
|
~\z \.orig\z \.rej\z \.bak\z
|
355
362
|
\.gemspec\z
|
@@ -400,6 +407,7 @@ class RDoc::Options
|
|
400
407
|
@encoding = encoding ? Encoding.find(encoding) : encoding
|
401
408
|
|
402
409
|
@charset = map['charset']
|
410
|
+
@embed_mixins = map['embed_mixins']
|
403
411
|
@exclude = map['exclude']
|
404
412
|
@generator_name = map['generator_name']
|
405
413
|
@hyperlink_all = map['hyperlink_all']
|
@@ -431,6 +439,7 @@ class RDoc::Options
|
|
431
439
|
end
|
432
440
|
|
433
441
|
@charset = map['charset'] if map.has_key?('charset')
|
442
|
+
@embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
|
434
443
|
@exclude = map['exclude'] if map.has_key?('exclude')
|
435
444
|
@generator_name = map['generator_name'] if map.has_key?('generator_name')
|
436
445
|
@hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
|
@@ -459,11 +468,12 @@ class RDoc::Options
|
|
459
468
|
def == other # :nodoc:
|
460
469
|
self.class === other and
|
461
470
|
@encoding == other.encoding and
|
471
|
+
@embed_mixins == other.embed_mixins and
|
462
472
|
@generator_name == other.generator_name and
|
463
473
|
@hyperlink_all == other.hyperlink_all and
|
464
474
|
@line_numbers == other.line_numbers and
|
465
475
|
@locale == other.locale and
|
466
|
-
@locale_dir == other.locale_dir
|
476
|
+
@locale_dir == other.locale_dir and
|
467
477
|
@main_page == other.main_page and
|
468
478
|
@markup == other.markup and
|
469
479
|
@op_dir == other.op_dir and
|
@@ -682,7 +692,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
682
692
|
|
683
693
|
EOF
|
684
694
|
|
685
|
-
parsers = Hash.new { |h,parser| h[parser] = [] }
|
695
|
+
parsers = Hash.new { |h, parser| h[parser] = [] }
|
686
696
|
|
687
697
|
RDoc::Parser.parsers.each do |regexp, parser|
|
688
698
|
parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
|
@@ -841,6 +851,14 @@ Usage: #{opt.program_name} [options] [names...]
|
|
841
851
|
|
842
852
|
opt.separator nil
|
843
853
|
|
854
|
+
opt.on("--[no-]embed-mixins",
|
855
|
+
"Embed mixin methods, attributes, and constants",
|
856
|
+
"into class documentation. (default false)") do |value|
|
857
|
+
@embed_mixins = value
|
858
|
+
end
|
859
|
+
|
860
|
+
opt.separator nil
|
861
|
+
|
844
862
|
markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
|
845
863
|
|
846
864
|
opt.on("--markup=MARKUP", markup_formats,
|
data/lib/rdoc/parser/c.rb
CHANGED
@@ -440,7 +440,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
440
440
|
# Scans #content for rb_include_module
|
441
441
|
|
442
442
|
def do_includes
|
443
|
-
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
|
443
|
+
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c, m|
|
444
444
|
next unless cls = @classes[c]
|
445
445
|
m = @known_classes[m] || m
|
446
446
|
|
@@ -756,17 +756,27 @@ class RDoc::Parser::C < RDoc::Parser
|
|
756
756
|
def gen_const_table file_content
|
757
757
|
table = {}
|
758
758
|
@content.scan(%r{
|
759
|
-
((?>^\s*/\*.*?\*/\s+))
|
760
|
-
rb_define_(
|
761
|
-
"(
|
759
|
+
(?<doc>(?>^\s*/\*.*?\*/\s+))
|
760
|
+
rb_define_(?<type>\w+)\(\s*(?:\w+),\s*
|
761
|
+
"(?<name>\w+)"\s*,
|
762
762
|
.*?\)\s*;
|
763
|
+
| (?<doc>(?>^\s*/\*.*?\*/\s+))
|
764
|
+
rb_file_(?<type>const)\(\s*
|
765
|
+
"(?<name>\w+)"\s*,
|
766
|
+
.*?\)\s*;
|
767
|
+
| (?<doc>(?>^\s*/\*.*?\*/\s+))
|
768
|
+
rb_curses_define_(?<type>const)\(\s*
|
769
|
+
(?<name>\w+)
|
770
|
+
\s*\)\s*;
|
763
771
|
| Document-(?:const|global|variable):\s
|
764
|
-
((?:\w+::)*\w+)
|
765
|
-
\s*?\n((?>.*?\*/))
|
772
|
+
(?<name>(?:\w+::)*\w+)
|
773
|
+
\s*?\n(?<doc>(?>.*?\*/))
|
766
774
|
}mxi) do
|
767
|
-
|
768
|
-
|
769
|
-
|
775
|
+
name, doc, type = $~.values_at(:name, :doc, :type)
|
776
|
+
if type
|
777
|
+
table[[type, name]] = doc
|
778
|
+
else
|
779
|
+
table[name] = "/*\n" + doc
|
770
780
|
end
|
771
781
|
end
|
772
782
|
table
|
@@ -193,7 +193,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
193
193
|
|
194
194
|
entries << [entry_name, entry_body] if entry_name
|
195
195
|
|
196
|
-
entries.reject! do |(entry,_)|
|
196
|
+
entries.reject! do |(entry, _)|
|
197
197
|
entry == nil
|
198
198
|
end
|
199
199
|
|
@@ -221,7 +221,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
221
221
|
|
222
222
|
module Git
|
223
223
|
##
|
224
|
-
# Parses auxiliary info.
|
224
|
+
# Parses auxiliary info. Currently `base-url` to expand
|
225
225
|
# references is effective.
|
226
226
|
|
227
227
|
def parse_info(info)
|
@@ -7,307 +7,12 @@ require 'ripper'
|
|
7
7
|
class RDoc::Parser::RipperStateLex
|
8
8
|
# :stopdoc:
|
9
9
|
|
10
|
-
# TODO: Remove this constants after Ruby 2.4 EOL
|
11
|
-
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
|
12
|
-
|
13
10
|
Token = Struct.new(:line_no, :char_no, :kind, :text, :state)
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
EXPR_ENDFN = 8
|
20
|
-
EXPR_ARG = 16
|
21
|
-
EXPR_CMDARG = 32
|
22
|
-
EXPR_MID = 64
|
23
|
-
EXPR_FNAME = 128
|
24
|
-
EXPR_DOT = 256
|
25
|
-
EXPR_CLASS = 512
|
26
|
-
EXPR_LABEL = 1024
|
27
|
-
EXPR_LABELED = 2048
|
28
|
-
EXPR_FITEM = 4096
|
29
|
-
EXPR_VALUE = EXPR_BEG
|
30
|
-
EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS)
|
31
|
-
EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG)
|
32
|
-
EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN)
|
33
|
-
|
34
|
-
class InnerStateLex < Ripper::Filter
|
35
|
-
attr_accessor :lex_state
|
36
|
-
|
37
|
-
def initialize(code)
|
38
|
-
@lex_state = EXPR_BEG
|
39
|
-
@in_fname = false
|
40
|
-
@continue = false
|
41
|
-
reset
|
42
|
-
super(code)
|
43
|
-
end
|
44
|
-
|
45
|
-
def reset
|
46
|
-
@command_start = false
|
47
|
-
@cmd_state = @command_start
|
48
|
-
end
|
49
|
-
|
50
|
-
def on_nl(tok, data)
|
51
|
-
case @lex_state
|
52
|
-
when EXPR_FNAME, EXPR_DOT
|
53
|
-
@continue = true
|
54
|
-
else
|
55
|
-
@continue = false
|
56
|
-
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
57
|
-
end
|
58
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
59
|
-
end
|
60
|
-
|
61
|
-
def on_ignored_nl(tok, data)
|
62
|
-
case @lex_state
|
63
|
-
when EXPR_FNAME, EXPR_DOT
|
64
|
-
@continue = true
|
65
|
-
else
|
66
|
-
@continue = false
|
67
|
-
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
68
|
-
end
|
69
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
70
|
-
end
|
71
|
-
|
72
|
-
def on_op(tok, data)
|
73
|
-
case tok
|
74
|
-
when '&', '|', '!', '!=', '!~'
|
75
|
-
case @lex_state
|
76
|
-
when EXPR_FNAME, EXPR_DOT
|
77
|
-
@lex_state = EXPR_ARG
|
78
|
-
else
|
79
|
-
@lex_state = EXPR_BEG
|
80
|
-
end
|
81
|
-
when '<<'
|
82
|
-
# TODO next token?
|
83
|
-
case @lex_state
|
84
|
-
when EXPR_FNAME, EXPR_DOT
|
85
|
-
@lex_state = EXPR_ARG
|
86
|
-
else
|
87
|
-
@lex_state = EXPR_BEG
|
88
|
-
end
|
89
|
-
when '?'
|
90
|
-
@lex_state = EXPR_BEG
|
91
|
-
when '&&', '||', '+=', '-=', '*=', '**=',
|
92
|
-
'&=', '|=', '^=', '<<=', '>>=', '||=', '&&='
|
93
|
-
@lex_state = EXPR_BEG
|
94
|
-
when '::'
|
95
|
-
case @lex_state
|
96
|
-
when EXPR_ARG, EXPR_CMDARG
|
97
|
-
@lex_state = EXPR_DOT
|
98
|
-
when EXPR_FNAME, EXPR_DOT
|
99
|
-
@lex_state = EXPR_ARG
|
100
|
-
else
|
101
|
-
@lex_state = EXPR_BEG
|
102
|
-
end
|
103
|
-
else
|
104
|
-
case @lex_state
|
105
|
-
when EXPR_FNAME, EXPR_DOT
|
106
|
-
@lex_state = EXPR_ARG
|
107
|
-
else
|
108
|
-
@lex_state = EXPR_BEG
|
109
|
-
end
|
110
|
-
end
|
111
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
112
|
-
end
|
113
|
-
|
114
|
-
def on_kw(tok, data)
|
115
|
-
case tok
|
116
|
-
when 'class'
|
117
|
-
@lex_state = EXPR_CLASS
|
118
|
-
@in_fname = true
|
119
|
-
when 'def'
|
120
|
-
@lex_state = EXPR_FNAME
|
121
|
-
@continue = true
|
122
|
-
@in_fname = true
|
123
|
-
when 'if', 'unless', 'while', 'until'
|
124
|
-
if ((EXPR_MID | EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if
|
125
|
-
@lex_state = EXPR_BEG | EXPR_LABEL
|
126
|
-
else
|
127
|
-
@lex_state = EXPR_BEG
|
128
|
-
end
|
129
|
-
when 'begin', 'case', 'when'
|
130
|
-
@lex_state = EXPR_BEG
|
131
|
-
when 'return', 'break'
|
132
|
-
@lex_state = EXPR_MID
|
133
|
-
else
|
134
|
-
if @lex_state == EXPR_FNAME
|
135
|
-
@lex_state = EXPR_END
|
136
|
-
else
|
137
|
-
@lex_state = EXPR_END
|
138
|
-
end
|
139
|
-
end
|
140
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
141
|
-
end
|
142
|
-
|
143
|
-
def on_tstring_beg(tok, data)
|
144
|
-
@lex_state = EXPR_BEG
|
145
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
146
|
-
end
|
147
|
-
|
148
|
-
def on_tstring_end(tok, data)
|
149
|
-
@lex_state = EXPR_END | EXPR_ENDARG
|
150
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
151
|
-
end
|
152
|
-
|
153
|
-
def on_CHAR(tok, data)
|
154
|
-
@lex_state = EXPR_END
|
155
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
156
|
-
end
|
157
|
-
|
158
|
-
def on_period(tok, data)
|
159
|
-
@lex_state = EXPR_DOT
|
160
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
161
|
-
end
|
162
|
-
|
163
|
-
def on_int(tok, data)
|
164
|
-
@lex_state = EXPR_END | EXPR_ENDARG
|
165
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
166
|
-
end
|
167
|
-
|
168
|
-
def on_float(tok, data)
|
169
|
-
@lex_state = EXPR_END | EXPR_ENDARG
|
170
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
171
|
-
end
|
172
|
-
|
173
|
-
def on_rational(tok, data)
|
174
|
-
@lex_state = EXPR_END | EXPR_ENDARG
|
175
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
176
|
-
end
|
177
|
-
|
178
|
-
def on_imaginary(tok, data)
|
179
|
-
@lex_state = EXPR_END | EXPR_ENDARG
|
180
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
181
|
-
end
|
182
|
-
|
183
|
-
def on_symbeg(tok, data)
|
184
|
-
@lex_state = EXPR_FNAME
|
185
|
-
@continue = true
|
186
|
-
@in_fname = true
|
187
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
188
|
-
end
|
189
|
-
|
190
|
-
private def on_variables(event, tok, data)
|
191
|
-
if @in_fname
|
192
|
-
@lex_state = EXPR_ENDFN
|
193
|
-
@in_fname = false
|
194
|
-
@continue = false
|
195
|
-
elsif @continue
|
196
|
-
case @lex_state
|
197
|
-
when EXPR_DOT
|
198
|
-
@lex_state = EXPR_ARG
|
199
|
-
else
|
200
|
-
@lex_state = EXPR_ENDFN
|
201
|
-
@continue = false
|
202
|
-
end
|
203
|
-
else
|
204
|
-
@lex_state = EXPR_CMDARG
|
205
|
-
end
|
206
|
-
data << Token.new(lineno, column, event, tok, @lex_state)
|
207
|
-
end
|
208
|
-
|
209
|
-
def on_ident(tok, data)
|
210
|
-
on_variables(__method__, tok, data)
|
211
|
-
end
|
212
|
-
|
213
|
-
def on_ivar(tok, data)
|
214
|
-
@lex_state = EXPR_END
|
215
|
-
on_variables(__method__, tok, data)
|
216
|
-
end
|
217
|
-
|
218
|
-
def on_cvar(tok, data)
|
219
|
-
@lex_state = EXPR_END
|
220
|
-
on_variables(__method__, tok, data)
|
221
|
-
end
|
222
|
-
|
223
|
-
def on_gvar(tok, data)
|
224
|
-
@lex_state = EXPR_END
|
225
|
-
on_variables(__method__, tok, data)
|
226
|
-
end
|
227
|
-
|
228
|
-
def on_backref(tok, data)
|
229
|
-
@lex_state = EXPR_END
|
230
|
-
on_variables(__method__, tok, data)
|
231
|
-
end
|
232
|
-
|
233
|
-
def on_lparen(tok, data)
|
234
|
-
@lex_state = EXPR_LABEL | EXPR_BEG
|
235
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
236
|
-
end
|
237
|
-
|
238
|
-
def on_rparen(tok, data)
|
239
|
-
@lex_state = EXPR_ENDFN
|
240
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
241
|
-
end
|
242
|
-
|
243
|
-
def on_lbrace(tok, data)
|
244
|
-
@lex_state = EXPR_LABEL | EXPR_BEG
|
245
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
246
|
-
end
|
247
|
-
|
248
|
-
def on_rbrace(tok, data)
|
249
|
-
@lex_state = EXPR_ENDARG
|
250
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
251
|
-
end
|
252
|
-
|
253
|
-
def on_lbracket(tok, data)
|
254
|
-
@lex_state = EXPR_LABEL | EXPR_BEG
|
255
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
256
|
-
end
|
257
|
-
|
258
|
-
def on_rbracket(tok, data)
|
259
|
-
@lex_state = EXPR_ENDARG
|
260
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
261
|
-
end
|
262
|
-
|
263
|
-
def on_const(tok, data)
|
264
|
-
case @lex_state
|
265
|
-
when EXPR_FNAME
|
266
|
-
@lex_state = EXPR_ENDFN
|
267
|
-
when EXPR_CLASS, EXPR_CMDARG, EXPR_MID
|
268
|
-
@lex_state = EXPR_ARG
|
269
|
-
else
|
270
|
-
@lex_state = EXPR_CMDARG
|
271
|
-
end
|
272
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
273
|
-
end
|
274
|
-
|
275
|
-
def on_sp(tok, data)
|
276
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
277
|
-
end
|
278
|
-
|
279
|
-
def on_comma(tok, data)
|
280
|
-
@lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0
|
281
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
282
|
-
end
|
283
|
-
|
284
|
-
def on_comment(tok, data)
|
285
|
-
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
286
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
287
|
-
end
|
288
|
-
|
289
|
-
def on_ignored_sp(tok, data)
|
290
|
-
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
|
291
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
292
|
-
end
|
293
|
-
|
294
|
-
def on_heredoc_beg(tok, data)
|
295
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
296
|
-
@lex_state = EXPR_END
|
297
|
-
data
|
298
|
-
end
|
299
|
-
|
300
|
-
def on_heredoc_end(tok, data)
|
301
|
-
data << Token.new(lineno, column, __method__, tok, @lex_state)
|
302
|
-
@lex_state = EXPR_BEG
|
303
|
-
data
|
304
|
-
end
|
305
|
-
|
306
|
-
def on_default(event, tok, data)
|
307
|
-
reset
|
308
|
-
data << Token.new(lineno, column, event, tok, @lex_state)
|
309
|
-
end
|
310
|
-
end unless RIPPER_HAS_LEX_STATE
|
12
|
+
EXPR_END = Ripper::EXPR_END
|
13
|
+
EXPR_ENDFN = Ripper::EXPR_ENDFN
|
14
|
+
EXPR_ARG = Ripper::EXPR_ARG
|
15
|
+
EXPR_FNAME = Ripper::EXPR_FNAME
|
311
16
|
|
312
17
|
class InnerStateLex < Ripper::Filter
|
313
18
|
def initialize(code)
|
@@ -317,7 +22,7 @@ class RDoc::Parser::RipperStateLex
|
|
317
22
|
def on_default(event, tok, data)
|
318
23
|
data << Token.new(lineno, column, event, tok, state)
|
319
24
|
end
|
320
|
-
end
|
25
|
+
end
|
321
26
|
|
322
27
|
def get_squashed_tk
|
323
28
|
if @buf.empty?
|
@@ -333,9 +38,8 @@ class RDoc::Parser::RipperStateLex
|
|
333
38
|
tk = get_string_tk(tk)
|
334
39
|
when :on_backtick then
|
335
40
|
if (tk[:state] & (EXPR_FNAME | EXPR_ENDFN)) != 0
|
336
|
-
@inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
|
337
41
|
tk[:kind] = :on_ident
|
338
|
-
tk[:state] = Ripper::Lexer
|
42
|
+
tk[:state] = Ripper::Lexer::State.new(EXPR_ARG)
|
339
43
|
else
|
340
44
|
tk = get_string_tk(tk)
|
341
45
|
end
|
@@ -345,7 +49,6 @@ class RDoc::Parser::RipperStateLex
|
|
345
49
|
tk = get_embdoc_tk(tk)
|
346
50
|
when :on_heredoc_beg then
|
347
51
|
@heredoc_queue << retrieve_heredoc_info(tk)
|
348
|
-
@inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE
|
349
52
|
when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then
|
350
53
|
if !@heredoc_queue.empty?
|
351
54
|
get_heredoc_tk(*@heredoc_queue.shift)
|
@@ -549,8 +252,7 @@ class RDoc::Parser::RipperStateLex
|
|
549
252
|
private def get_op_tk(tk)
|
550
253
|
redefinable_operators = %w[! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] []= ^ ` | ~]
|
551
254
|
if redefinable_operators.include?(tk[:text]) and tk[:state] == EXPR_ARG then
|
552
|
-
|
553
|
-
tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG
|
255
|
+
tk[:state] = Ripper::Lexer::State.new(EXPR_ARG)
|
554
256
|
tk[:kind] = :on_ident
|
555
257
|
elsif tk[:text] =~ /^[-+]$/ then
|
556
258
|
tk_ahead = get_squashed_tk
|
data/lib/rdoc/parser/ruby.rb
CHANGED
@@ -8,6 +8,15 @@
|
|
8
8
|
# by Keiju ISHITSUKA (Nippon Rational Inc.)
|
9
9
|
#
|
10
10
|
|
11
|
+
if ENV['RDOC_USE_PRISM_PARSER']
|
12
|
+
require 'rdoc/parser/prism_ruby'
|
13
|
+
RDoc::Parser.const_set(:Ruby, RDoc::Parser::PrismRuby)
|
14
|
+
puts "========================================================================="
|
15
|
+
puts "RDoc is using the experimental Prism parser to generate the documentation"
|
16
|
+
puts "========================================================================="
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
11
20
|
require 'ripper'
|
12
21
|
require_relative 'ripper_state_lex'
|
13
22
|
|
@@ -513,7 +522,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
513
522
|
when :on_comment, :on_embdoc then
|
514
523
|
@read.pop
|
515
524
|
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
|
516
|
-
(!continue or (tk[:state] &
|
525
|
+
(!continue or (tk[:state] & Ripper::EXPR_LABEL) != 0) then
|
517
526
|
break if !continue and nest <= 0
|
518
527
|
end
|
519
528
|
when :on_comma then
|
@@ -526,7 +535,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
526
535
|
nest += 1
|
527
536
|
when 'if', 'unless', 'while', 'until', 'rescue'
|
528
537
|
# postfix if/unless/while/until/rescue must be EXPR_LABEL
|
529
|
-
nest += 1 unless (tk[:state] &
|
538
|
+
nest += 1 unless (tk[:state] & Ripper::EXPR_LABEL) != 0
|
530
539
|
when 'end'
|
531
540
|
nest -= 1
|
532
541
|
break if nest == 0
|
@@ -789,8 +798,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
789
798
|
al.line = line_no
|
790
799
|
|
791
800
|
read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
|
792
|
-
|
793
|
-
|
801
|
+
if al.document_self or not @track_visibility
|
802
|
+
context.add_alias al
|
803
|
+
@stats.add_alias al
|
804
|
+
end
|
794
805
|
|
795
806
|
al
|
796
807
|
end
|
@@ -1039,7 +1050,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1039
1050
|
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
|
1040
1051
|
nest += 1
|
1041
1052
|
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
|
1042
|
-
if (tk[:state] &
|
1053
|
+
if (tk[:state] & Ripper::EXPR_LABEL) == 0
|
1043
1054
|
nest += 1
|
1044
1055
|
end
|
1045
1056
|
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
|
@@ -1453,6 +1464,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1453
1464
|
meth = RDoc::AnyMethod.new get_tkread, name
|
1454
1465
|
look_for_directives_in meth, comment
|
1455
1466
|
meth.singleton = single == SINGLE ? true : singleton
|
1467
|
+
if singleton
|
1468
|
+
# `current_line_visibility' is useless because it works against
|
1469
|
+
# the normal method named as same as the singleton method, after
|
1470
|
+
# the latter was defined. Of course these are different things.
|
1471
|
+
container.current_line_visibility = :public
|
1472
|
+
end
|
1456
1473
|
|
1457
1474
|
record_location meth
|
1458
1475
|
meth.line = line_no
|
@@ -1654,7 +1671,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1654
1671
|
when :on_comment, :on_embdoc then
|
1655
1672
|
@read.pop
|
1656
1673
|
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
|
1657
|
-
(!continue or (tk[:state] &
|
1674
|
+
(!continue or (tk[:state] & Ripper::EXPR_LABEL) != 0) then
|
1658
1675
|
if method && method.block_params.nil? then
|
1659
1676
|
unget_tk tk
|
1660
1677
|
read_documentation_modifiers method, modifiers
|
@@ -1776,6 +1793,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1776
1793
|
|
1777
1794
|
nest = 1
|
1778
1795
|
save_visibility = container.visibility
|
1796
|
+
container.visibility = :public unless current_method
|
1779
1797
|
|
1780
1798
|
non_comment_seen = true
|
1781
1799
|
|
@@ -1873,7 +1891,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1873
1891
|
end
|
1874
1892
|
|
1875
1893
|
when 'until', 'while' then
|
1876
|
-
if (tk[:state] &
|
1894
|
+
if (tk[:state] & Ripper::EXPR_LABEL) == 0
|
1877
1895
|
nest += 1
|
1878
1896
|
skip_optional_do_after_expression
|
1879
1897
|
end
|
@@ -1889,7 +1907,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1889
1907
|
skip_optional_do_after_expression
|
1890
1908
|
|
1891
1909
|
when 'case', 'do', 'if', 'unless', 'begin' then
|
1892
|
-
if (tk[:state] &
|
1910
|
+
if (tk[:state] & Ripper::EXPR_LABEL) == 0
|
1893
1911
|
nest += 1
|
1894
1912
|
end
|
1895
1913
|
|
data/lib/rdoc/parser.rb
CHANGED
@@ -125,9 +125,11 @@ class RDoc::Parser
|
|
125
125
|
return parser if ext_name.empty?
|
126
126
|
|
127
127
|
if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ then
|
128
|
-
case check_modeline
|
128
|
+
case mode = check_modeline(file_name)
|
129
129
|
when nil, 'rdoc' then # continue
|
130
|
-
else
|
130
|
+
else
|
131
|
+
RDoc::Parser.parsers.find { |_, p| return p if mode.casecmp?(p.name[/\w+\z/]) }
|
132
|
+
return nil
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
@@ -164,7 +166,8 @@ class RDoc::Parser
|
|
164
166
|
# Finds and instantiates the correct parser for the given +file_name+ and
|
165
167
|
# +content+.
|
166
168
|
|
167
|
-
def self.for top_level,
|
169
|
+
def self.for top_level, content, options, stats
|
170
|
+
file_name = top_level.absolute_name
|
168
171
|
return if binary? file_name
|
169
172
|
|
170
173
|
parser = use_markup content
|
data/lib/rdoc/rd/block_parser.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
5
|
# from Racc grammar file "block_parser.ry".
|
6
6
|
#
|
7
7
|
|
@@ -23,7 +23,7 @@ unless $".find {|p| p.end_with?('/racc/info.rb')}
|
|
23
23
|
$".push "#{__dir__}/racc/info.rb"
|
24
24
|
|
25
25
|
module Racc
|
26
|
-
VERSION = '1.
|
26
|
+
VERSION = '1.8.1'
|
27
27
|
Version = VERSION
|
28
28
|
Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
|
29
29
|
end
|
@@ -31,10 +31,6 @@ end
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
-
unless defined?(NotImplementedError)
|
35
|
-
NotImplementedError = NotImplementError # :nodoc:
|
36
|
-
end
|
37
|
-
|
38
34
|
module Racc
|
39
35
|
class ParseError < StandardError; end
|
40
36
|
end
|
@@ -42,7 +38,7 @@ unless defined?(::ParseError)
|
|
42
38
|
ParseError = Racc::ParseError # :nodoc:
|
43
39
|
end
|
44
40
|
|
45
|
-
# Racc is
|
41
|
+
# Racc is an LALR(1) parser generator.
|
46
42
|
# It is written in Ruby itself, and generates Ruby programs.
|
47
43
|
#
|
48
44
|
# == Command-line Reference
|