rdoc 6.6.0 → 6.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 947667e0cc733b38e36c829627ea1cca454420e44124b9536bf7f6ab7c687688
4
- data.tar.gz: ce0d8a98c383e7c6b03138fbb62a31626bb24a20be3967aefa3c29a302b0d9f6
3
+ metadata.gz: 060b06473aafc2a0a07ded738b5be7819ddd0520d7e2033ef72311ff8dd57248
4
+ data.tar.gz: 500fd282367d6cefeb9257518a0ed5e5371cf3c09a6addc8ac30be1dbe7ba267
5
5
  SHA512:
6
- metadata.gz: dd6e321fe810da6ed4b5257df5347474adb514b061c9c5ad981c57feef340544e6e51fe9bfe48ef31bc7eaa87fc179883635d5448f6f2ab669443adcd6e98d46
7
- data.tar.gz: 1c7d9158ca93ab8a913f282d6a641bc6d2f69eecf779b452d93fb935f6fde8e0e536d186ca8c2eba90a58a31ffd34cffd9af7a220fd5ff0ed63da6cf68ad8ed2
6
+ metadata.gz: 52461100f11f5123da6874e2786b4a83248435fd4955609647421c49a71c5d6ba98bd869fc3c510e64d148992461762b4213390b7aa33bd9dd80d7caad665638
7
+ data.tar.gz: 87b21e587bc4e2d97b35f56b4be8e28a1ac40961dc5caf2f61ab3500f5f3a9147195b917d329a1264cb6f4605daec30bb5603c2269a09c5a89da359074928805
@@ -131,6 +131,9 @@ class RDoc::CrossReference
131
131
  @seen = {}
132
132
  end
133
133
 
134
+ ##
135
+ # Returns a method reference to +name+.
136
+
134
137
  def resolve_method name
135
138
  ref = nil
136
139
 
data/lib/rdoc/encoding.rb CHANGED
@@ -86,17 +86,6 @@ module RDoc::Encoding
86
86
  nil
87
87
  end
88
88
 
89
- def self.remove_frozen_string_literal string
90
- string =~ /\A(?:#!.*\n)?(.*\n)/
91
- first_line = $1
92
-
93
- if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
94
- string = string.sub first_line, ''
95
- end
96
-
97
- string
98
- end
99
-
100
89
  ##
101
90
  # Detects the encoding of +string+ based on the magic comment
102
91
 
@@ -81,6 +81,7 @@ class RDoc::Generator::POT
81
81
  end
82
82
  end
83
83
 
84
+ # :nodoc:
84
85
  def class_dir
85
86
  nil
86
87
  end
@@ -87,6 +87,17 @@ pre {
87
87
  border-radius: 0.2em;
88
88
  }
89
89
 
90
+ em {
91
+ text-decoration-color: rgba(52, 48, 64, 0.25);
92
+ text-decoration-line: underline;
93
+ text-decoration-style: dotted;
94
+ }
95
+
96
+ strong,
97
+ em {
98
+ background-color: rgba(158, 178, 255, 0.1);
99
+ }
100
+
90
101
  table {
91
102
  margin: 0;
92
103
  border-spacing: 0;
@@ -6,7 +6,6 @@
6
6
  # :markup: markdown
7
7
 
8
8
  ##
9
- #--
10
9
  # This set of literals is for Ruby 1.9 regular expressions and gives full
11
10
  # unicode support.
12
11
  #
@@ -20,4 +19,3 @@ BOM = "\uFEFF"
20
19
  Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
21
20
  NonAlphanumeric = /\p{^Word}/
22
21
  Spacechar = /\t|\p{Zs}/
23
-
@@ -3,7 +3,6 @@
3
3
  # :markup: markdown
4
4
 
5
5
  ##
6
- #--
7
6
  # This set of literals is for Ruby 1.9 regular expressions and gives full
8
7
  # unicode support.
9
8
  #
@@ -64,9 +63,6 @@ class RDoc::Markdown::Literals
64
63
  def current_line(target=pos)
65
64
  if line = position_line_offsets.bsearch_index {|x| x > target }
66
65
  return line + 1
67
- elsif target == string.size
68
- past_last = !string.empty? && string[-1]=="\n" ? 1 : 0
69
- return position_line_offsets.size + past_last
70
66
  end
71
67
  raise "Target position #{target} is outside of string"
72
68
  end
@@ -74,22 +70,17 @@ class RDoc::Markdown::Literals
74
70
  def current_line(target=pos)
75
71
  if line = position_line_offsets.index {|x| x > target }
76
72
  return line + 1
77
- elsif target == string.size
78
- past_last = !string.empty? && string[-1]=="\n" ? 1 : 0
79
- return position_line_offsets.size + past_last
80
73
  end
74
+
81
75
  raise "Target position #{target} is outside of string"
82
76
  end
83
77
  end
84
78
 
85
79
  def current_character(target=pos)
86
- if target < 0 || target > string.size
80
+ if target < 0 || target >= string.size
87
81
  raise "Target position #{target} is outside of string"
88
- elsif target == string.size
89
- ""
90
- else
91
- string[target, 1]
92
82
  end
83
+ string[target, 1]
93
84
  end
94
85
 
95
86
  KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
@@ -208,15 +199,6 @@ class RDoc::Markdown::Literals
208
199
 
209
200
  attr_reader :failed_rule
210
201
 
211
- def match_dot()
212
- if @pos >= @string_size
213
- return nil
214
- end
215
-
216
- @pos += 1
217
- true
218
- end
219
-
220
202
  def match_string(str)
221
203
  len = str.size
222
204
  if @string[pos,len] == str
@@ -237,26 +219,24 @@ class RDoc::Markdown::Literals
237
219
  end
238
220
 
239
221
  if "".respond_to? :ord
240
- def match_char_range(char_range)
222
+ def get_byte
241
223
  if @pos >= @string_size
242
224
  return nil
243
- elsif !char_range.include?(@string[@pos].ord)
244
- return nil
245
225
  end
246
226
 
227
+ s = @string[@pos].ord
247
228
  @pos += 1
248
- true
229
+ s
249
230
  end
250
231
  else
251
- def match_char_range(char_range)
232
+ def get_byte
252
233
  if @pos >= @string_size
253
234
  return nil
254
- elsif !char_range.include?(@string[@pos])
255
- return nil
256
235
  end
257
236
 
237
+ s = @string[@pos]
258
238
  @pos += 1
259
- true
239
+ s
260
240
  end
261
241
  end
262
242
 
@@ -138,6 +138,7 @@ class RDoc::Markup::AttributeManager
138
138
  res
139
139
  end
140
140
 
141
+ # :nodoc:
141
142
  def exclusive?(attr)
142
143
  (attr & @exclusive_bitmap) != 0
143
144
  end
@@ -155,6 +156,7 @@ class RDoc::Markup::AttributeManager
155
156
  convert_attrs_word_pair_map(str, attrs, exclusive)
156
157
  end
157
158
 
159
+ # :nodoc:
158
160
  def convert_attrs_matching_word_pairs(str, attrs, exclusive)
159
161
  # first do matching ones
160
162
  tags = @matching_word_pairs.select { |start, bitmap|
@@ -179,6 +181,7 @@ class RDoc::Markup::AttributeManager
179
181
  str.delete!(NON_PRINTING_START + NON_PRINTING_END)
180
182
  end
181
183
 
184
+ # :nodoc:
182
185
  def convert_attrs_word_pair_map(str, attrs, exclusive)
183
186
  # then non-matching
184
187
  unless @word_pair_map.empty? then
@@ -90,7 +90,7 @@ class RDoc::Markup::Formatter
90
90
 
91
91
  def add_regexp_handling_TIDYLINK
92
92
  @markup.add_regexp_handling(/(?:
93
- \{.*?\} | # multi-word label
93
+ \{[^{}]*\} | # multi-word label
94
94
  \b[^\s{}]+? # single-word label
95
95
  )
96
96
 
@@ -218,7 +218,7 @@ class RDoc::Markup::Parser
218
218
 
219
219
  break if peek_token.first == :BREAK
220
220
 
221
- data << ' ' if skip :NEWLINE
221
+ data << ' ' if skip :NEWLINE and /#{SPACE_SEPARATED_LETTER_CLASS}\z/o.match?(data)
222
222
  else
223
223
  unget
224
224
  break
@@ -420,6 +420,8 @@ class RDoc::Markup::Parser
420
420
  # A simple wrapper of StringScanner that is aware of the current column and lineno
421
421
 
422
422
  class MyStringScanner
423
+ # :stopdoc:
424
+
423
425
  def initialize(input)
424
426
  @line = @column = 0
425
427
  @s = StringScanner.new input
@@ -456,6 +458,8 @@ class RDoc::Markup::Parser
456
458
  def [](i)
457
459
  @s[i]
458
460
  end
461
+
462
+ #:startdoc:
459
463
  end
460
464
 
461
465
  ##
@@ -3,12 +3,21 @@
3
3
  # A section of table
4
4
 
5
5
  class RDoc::Markup::Table
6
- attr_accessor :header, :align, :body
6
+ # headers of each column
7
+ attr_accessor :header
7
8
 
9
+ # alignments of each column
10
+ attr_accessor :align
11
+
12
+ # body texts of each column
13
+ attr_accessor :body
14
+
15
+ # Creates new instance
8
16
  def initialize header, align, body
9
17
  @header, @align, @body = header, align, body
10
18
  end
11
19
 
20
+ # :stopdoc:
12
21
  def == other
13
22
  self.class == other.class and
14
23
  @header == other.header and
@@ -20,7 +29,7 @@ class RDoc::Markup::Table
20
29
  visitor.accept_table @header, @body, @align
21
30
  end
22
31
 
23
- def pretty_print q # :nodoc:
32
+ def pretty_print q
24
33
  q.group 2, '[Table: ', ']' do
25
34
  q.group 2, '[Head: ', ']' do
26
35
  q.seplist @header.zip(@align) do |text, align|
@@ -61,6 +61,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
61
61
  #
62
62
  # These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling.
63
63
 
64
+ # :nodoc:
64
65
  URL_CHARACTERS_REGEXP_STR = /[A-Za-z0-9\-._~:\/\?#\[\]@!$&'\(\)*+,;%=]/.source
65
66
 
66
67
  ##
@@ -202,7 +203,9 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
202
203
  def accept_paragraph paragraph
203
204
  @res << "\n<p>"
204
205
  text = paragraph.text @hard_break
205
- text = text.gsub(/\r?\n/, ' ')
206
+ text = text.gsub(/(#{SPACE_SEPARATED_LETTER_CLASS})?\K\r?\n(?=(?(1)(#{SPACE_SEPARATED_LETTER_CLASS})?))/o) {
207
+ defined?($2) && ' '
208
+ }
206
209
  @res << to_html(text)
207
210
  @res << "</p>\n"
208
211
  end
@@ -42,6 +42,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
42
42
  @cross_reference = RDoc::CrossReference.new @context
43
43
  end
44
44
 
45
+ # :nodoc:
45
46
  def init_link_notation_regexp_handlings
46
47
  add_regexp_handling_RDOCLINK
47
48
 
@@ -66,6 +66,9 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
66
66
 
67
67
  alias accept_rule ignore
68
68
 
69
+ ##
70
+ # Adds +paragraph+ to the output
71
+
69
72
  def accept_paragraph paragraph
70
73
  para = @in_list_entry.last || "<p>"
71
74
 
data/lib/rdoc/parser/c.rb CHANGED
@@ -575,19 +575,18 @@ class RDoc::Parser::C < RDoc::Parser
575
575
  table = {}
576
576
  file_content.scan(%r{
577
577
  ((?>/\*.*?\*/\s*)?)
578
- ((?:(?:\w+)\s+)?
579
- (?:intern\s+)?VALUE\s+(\w+)
580
- \s*(?:\([^)]*\))(?:[^\);]|$))
578
+ ((?:\w+\s+){0,2} VALUE\s+(\w+)
579
+ \s*(?:\([^\)]*\))(?:[^\);]|$))
581
580
  | ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
582
581
  | ^\s*\#\s*define\s+(\w+)\s+(\w+)
583
582
  }xm) do
584
583
  case
585
- when $1
586
- table[$3] = [:func_def, $1, $2, $~.offset(2)] if !table[$3] || table[$3][0] != :func_def
587
- when $4
588
- table[$6] = [:macro_def, $4, $5, $~.offset(5), $7] if !table[$6] || table[$6][0] == :macro_alias
589
- when $8
590
- table[$8] ||= [:macro_alias, $9]
584
+ when name = $3
585
+ table[name] = [:func_def, $1, $2, $~.offset(2)] if !(t = table[name]) || t[0] != :func_def
586
+ when name = $6
587
+ table[name] = [:macro_def, $4, $5, $~.offset(5), $7] if !(t = table[name]) || t[0] == :macro_alias
588
+ when name = $8
589
+ table[name] ||= [:macro_alias, $9]
591
590
  end
592
591
  end
593
592
  table
@@ -939,14 +938,13 @@ class RDoc::Parser::C < RDoc::Parser
939
938
  # "/* definition: comment */" form. The literal ':' and '\' characters
940
939
  # can be escaped with a backslash.
941
940
  if type.downcase == 'const' then
942
- no_match, new_definition, new_comment = comment.text.split(/(\A.*):/)
941
+ if /\A(.+?)?:(?!\S)/ =~ comment.text
942
+ new_definition, new_comment = $1, $'
943
943
 
944
- if no_match and no_match.empty? then
945
- if new_definition.empty? then # Default to literal C definition
944
+ if !new_definition # Default to literal C definition
946
945
  new_definition = definition
947
946
  else
948
- new_definition = new_definition.gsub("\:", ":")
949
- new_definition = new_definition.gsub("\\", '\\')
947
+ new_definition = new_definition.gsub(/\\([\\:])/, '\1')
950
948
  end
951
949
 
952
950
  new_definition.sub!(/\A(\s+)/, '')
@@ -1217,6 +1215,9 @@ class RDoc::Parser::C < RDoc::Parser
1217
1215
  @top_level
1218
1216
  end
1219
1217
 
1218
+ ##
1219
+ # Creates a RDoc::Comment instance.
1220
+
1220
1221
  def new_comment text = nil, location = nil, language = nil
1221
1222
  RDoc::Comment.new(text, location, language).tap do |comment|
1222
1223
  comment.format = @markup
@@ -216,12 +216,22 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
216
216
  @top_level
217
217
  end
218
218
 
219
+ ##
220
+ # The extension for Git commit log
221
+
219
222
  module Git
223
+ ##
224
+ # Parses auxiliary info. Currentry `base-url` to expand
225
+ # references is effective.
226
+
220
227
  def parse_info(info)
221
228
  /^\s*base-url\s*=\s*(.*\S)/ =~ info
222
229
  @base_url = $1
223
230
  end
224
231
 
232
+ ##
233
+ # Parses the entries in the Git commit logs
234
+
225
235
  def parse_entries
226
236
  entries = []
227
237
 
@@ -244,6 +254,11 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
244
254
  entries
245
255
  end
246
256
 
257
+ ##
258
+ # Returns a list of ChangeLog entries as
259
+ # RDoc::Parser::ChangeLog::Git::LogEntry list for the given
260
+ # +entries+.
261
+
247
262
  def create_entries entries
248
263
  # git log entries have no strictly itemized style like the old
249
264
  # style, just assume Markdown.
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  require 'ripper'
3
3
 
4
+ ##
5
+ # Wrapper for Ripper lex states
6
+
4
7
  class RDoc::Parser::RipperStateLex
8
+ # :stopdoc:
9
+
5
10
  # TODO: Remove this constants after Ruby 2.4 EOL
6
11
  RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
7
12
 
@@ -565,6 +570,9 @@ class RDoc::Parser::RipperStateLex
565
570
  tk
566
571
  end
567
572
 
573
+ # :startdoc:
574
+
575
+ # New lexer for +code+.
568
576
  def initialize(code)
569
577
  @buf = []
570
578
  @heredoc_queue = []
@@ -572,6 +580,7 @@ class RDoc::Parser::RipperStateLex
572
580
  @tokens = @inner_lex.parse([])
573
581
  end
574
582
 
583
+ # Returns tokens parsed from +code+.
575
584
  def self.parse(code)
576
585
  lex = self.new(code)
577
586
  tokens = []
@@ -584,6 +593,7 @@ class RDoc::Parser::RipperStateLex
584
593
  tokens
585
594
  end
586
595
 
596
+ # Returns +true+ if lex state will be +END+ after +token+.
587
597
  def self.end?(token)
588
598
  (token[:state] & EXPR_END)
589
599
  end
@@ -180,6 +180,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
180
180
  reset
181
181
  end
182
182
 
183
+ ##
184
+ # Return +true+ if +tk+ is a newline.
185
+
183
186
  def tk_nl?(tk)
184
187
  :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]
185
188
  end
@@ -1,11 +1,659 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.7.1
5
- # from Racc grammar file "".
4
+ # This file is automatically generated by Racc 1.7.3
5
+ # from Racc grammar file "inline_parser.ry".
6
6
  #
7
7
 
8
- require 'racc/parser.rb'
8
+ ###### racc/parser.rb begin
9
+ unless $".find {|p| p.end_with?('/racc/parser.rb')}
10
+ $".push "#{__dir__}/racc/parser.rb"
11
+ #--
12
+ # Copyright (c) 1999-2006 Minero Aoki
13
+ #
14
+ # This program is free software.
15
+ # You can distribute/modify this program under the same terms of ruby.
16
+ #
17
+ # As a special exception, when this code is copied by Racc
18
+ # into a Racc output file, you may use that output file
19
+ # without restriction.
20
+ #++
21
+
22
+ unless $".find {|p| p.end_with?('/racc/info.rb')}
23
+ $".push "#{__dir__}/racc/info.rb"
24
+
25
+ module Racc
26
+ VERSION = '1.7.3'
27
+ Version = VERSION
28
+ Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
29
+ end
30
+
31
+ end
32
+
33
+
34
+ unless defined?(NotImplementedError)
35
+ NotImplementedError = NotImplementError # :nodoc:
36
+ end
37
+
38
+ module Racc
39
+ class ParseError < StandardError; end
40
+ end
41
+ unless defined?(::ParseError)
42
+ ParseError = Racc::ParseError # :nodoc:
43
+ end
44
+
45
+ # Racc is a LALR(1) parser generator.
46
+ # It is written in Ruby itself, and generates Ruby programs.
47
+ #
48
+ # == Command-line Reference
49
+ #
50
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
51
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
52
+ # [-v] [--verbose]
53
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
54
+ # [-g] [--debug]
55
+ # [-E] [--embedded]
56
+ # [-l] [--no-line-convert]
57
+ # [-c] [--line-convert-all]
58
+ # [-a] [--no-omit-actions]
59
+ # [-C] [--check-only]
60
+ # [-S] [--output-status]
61
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
62
+ #
63
+ # [+grammarfile+]
64
+ # Racc grammar file. Any extension is permitted.
65
+ # [-o+outfile+, --output-file=+outfile+]
66
+ # A filename for output. default is <+filename+>.tab.rb
67
+ # [-O+filename+, --log-file=+filename+]
68
+ # Place logging output in file +filename+.
69
+ # Default log file name is <+filename+>.output.
70
+ # [-e+rubypath+, --executable=+rubypath+]
71
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
72
+ # [-v, --verbose]
73
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
74
+ # [-g, --debug]
75
+ # add debug code to parser class. To display debugging information,
76
+ # use this '-g' option and set @yydebug true in parser class.
77
+ # [-E, --embedded]
78
+ # Output parser which doesn't need runtime files (racc/parser.rb).
79
+ # [-F, --frozen]
80
+ # Output parser which declares frozen_string_literals: true
81
+ # [-C, --check-only]
82
+ # Check syntax of racc grammar file and quit.
83
+ # [-S, --output-status]
84
+ # Print messages time to time while compiling.
85
+ # [-l, --no-line-convert]
86
+ # turns off line number converting.
87
+ # [-c, --line-convert-all]
88
+ # Convert line number of actions, inner, header and footer.
89
+ # [-a, --no-omit-actions]
90
+ # Call all actions, even if an action is empty.
91
+ # [--version]
92
+ # print Racc version and quit.
93
+ # [--copyright]
94
+ # Print copyright and quit.
95
+ # [--help]
96
+ # Print usage and quit.
97
+ #
98
+ # == Generating Parser Using Racc
99
+ #
100
+ # To compile Racc grammar file, simply type:
101
+ #
102
+ # $ racc parse.y
103
+ #
104
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
105
+ #
106
+ # == Writing A Racc Grammar File
107
+ #
108
+ # If you want your own parser, you have to write a grammar file.
109
+ # A grammar file contains the name of your parser class, grammar for the parser,
110
+ # user code, and anything else.
111
+ # When writing a grammar file, yacc's knowledge is helpful.
112
+ # If you have not used yacc before, Racc is not too difficult.
113
+ #
114
+ # Here's an example Racc grammar file.
115
+ #
116
+ # class Calcparser
117
+ # rule
118
+ # target: exp { print val[0] }
119
+ #
120
+ # exp: exp '+' exp
121
+ # | exp '*' exp
122
+ # | '(' exp ')'
123
+ # | NUMBER
124
+ # end
125
+ #
126
+ # Racc grammar files resemble yacc files.
127
+ # But (of course), this is Ruby code.
128
+ # yacc's $$ is the 'result', $0, $1... is
129
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
130
+ #
131
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
132
+ # more information on grammar files.
133
+ #
134
+ # == Parser
135
+ #
136
+ # Then you must prepare the parse entry method. There are two types of
137
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
138
+ #
139
+ # Racc::Parser#do_parse is simple.
140
+ #
141
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
142
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
143
+ # EOF is [false, false].
144
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
145
+ # If you want to change this, see the grammar reference.
146
+ #
147
+ # Racc::Parser#yyparse is little complicated, but useful.
148
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
149
+ #
150
+ # For example, <code>yyparse(obj, :scan)</code> causes
151
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
152
+ #
153
+ # == Debugging
154
+ #
155
+ # When debugging, "-v" or/and the "-g" option is helpful.
156
+ #
157
+ # "-v" creates verbose log file (.output).
158
+ # "-g" creates a "Verbose Parser".
159
+ # Verbose Parser prints the internal status when parsing.
160
+ # But it's _not_ automatic.
161
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
162
+ # -g option only creates the verbose parser.
163
+ #
164
+ # === Racc reported syntax error.
165
+ #
166
+ # Isn't there too many "end"?
167
+ # grammar of racc file is changed in v0.10.
168
+ #
169
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
170
+ #
171
+ # === Racc reported "XXXX conflicts".
172
+ #
173
+ # Try "racc -v xxxx.y".
174
+ # It causes producing racc's internal log file, xxxx.output.
175
+ #
176
+ # === Generated parsers does not work correctly
177
+ #
178
+ # Try "racc -g xxxx.y".
179
+ # This command let racc generate "debugging parser".
180
+ # Then set @yydebug=true in your parser.
181
+ # It produces a working log of your parser.
182
+ #
183
+ # == Re-distributing Racc runtime
184
+ #
185
+ # A parser, which is created by Racc, requires the Racc runtime module;
186
+ # racc/parser.rb.
187
+ #
188
+ # Ruby 1.8.x comes with Racc runtime module,
189
+ # you need NOT distribute Racc runtime files.
190
+ #
191
+ # If you want to include the Racc runtime module with your parser.
192
+ # This can be done by using '-E' option:
193
+ #
194
+ # $ racc -E -omyparser.rb myparser.y
195
+ #
196
+ # This command creates myparser.rb which `includes' Racc runtime.
197
+ # Only you must do is to distribute your parser file (myparser.rb).
198
+ #
199
+ # Note: parser.rb is ruby license, but your parser is not.
200
+ # Your own parser is completely yours.
201
+ module Racc
202
+
203
+ unless defined?(Racc_No_Extensions)
204
+ Racc_No_Extensions = false # :nodoc:
205
+ end
206
+
207
+ class Parser
208
+
209
+ Racc_Runtime_Version = ::Racc::VERSION
210
+ Racc_Runtime_Core_Version_R = ::Racc::VERSION
211
+
212
+ begin
213
+ if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
214
+ require 'jruby'
215
+ require 'racc/cparse-jruby.jar'
216
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
217
+ else
218
+ require 'racc/cparse'
219
+ end
220
+
221
+ unless new.respond_to?(:_racc_do_parse_c, true)
222
+ raise LoadError, 'old cparse.so'
223
+ end
224
+ if Racc_No_Extensions
225
+ raise LoadError, 'selecting ruby version of racc runtime core'
226
+ end
227
+
228
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
229
+ Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
230
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
231
+ Racc_Runtime_Type = 'c' # :nodoc:
232
+ rescue LoadError
233
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
234
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
235
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
236
+ Racc_Runtime_Type = 'ruby'
237
+ end
238
+
239
+ def Parser.racc_runtime_type # :nodoc:
240
+ Racc_Runtime_Type
241
+ end
242
+
243
+ def _racc_setup
244
+ @yydebug = false unless self.class::Racc_debug_parser
245
+ @yydebug = false unless defined?(@yydebug)
246
+ if @yydebug
247
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
248
+ @racc_debug_out ||= $stderr
249
+ end
250
+ arg = self.class::Racc_arg
251
+ arg[13] = true if arg.size < 14
252
+ arg
253
+ end
254
+
255
+ def _racc_init_sysvars
256
+ @racc_state = [0]
257
+ @racc_tstack = []
258
+ @racc_vstack = []
259
+
260
+ @racc_t = nil
261
+ @racc_val = nil
262
+
263
+ @racc_read_next = true
264
+
265
+ @racc_user_yyerror = false
266
+ @racc_error_status = 0
267
+ end
268
+
269
+ # The entry point of the parser. This method is used with #next_token.
270
+ # If Racc wants to get token (and its value), calls next_token.
271
+ #
272
+ # Example:
273
+ # def parse
274
+ # @q = [[1,1],
275
+ # [2,2],
276
+ # [3,3],
277
+ # [false, '$']]
278
+ # do_parse
279
+ # end
280
+ #
281
+ # def next_token
282
+ # @q.shift
283
+ # end
284
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
285
+ def do_parse
286
+ #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
287
+ end
288
+ RUBY
289
+
290
+ # The method to fetch next token.
291
+ # If you use #do_parse method, you must implement #next_token.
292
+ #
293
+ # The format of return value is [TOKEN_SYMBOL, VALUE].
294
+ # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
295
+ # for 'IDENT'. ";" (String) for ';'.
296
+ #
297
+ # The final symbol (End of file) must be false.
298
+ def next_token
299
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
300
+ end
301
+
302
+ def _racc_do_parse_rb(arg, in_debug)
303
+ action_table, action_check, action_default, action_pointer,
304
+ _, _, _, _,
305
+ _, _, token_table, * = arg
306
+
307
+ _racc_init_sysvars
308
+ tok = act = i = nil
309
+
310
+ catch(:racc_end_parse) {
311
+ while true
312
+ if i = action_pointer[@racc_state[-1]]
313
+ if @racc_read_next
314
+ if @racc_t != 0 # not EOF
315
+ tok, @racc_val = next_token()
316
+ unless tok # EOF
317
+ @racc_t = 0
318
+ else
319
+ @racc_t = (token_table[tok] or 1) # error token
320
+ end
321
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
322
+ @racc_read_next = false
323
+ end
324
+ end
325
+ i += @racc_t
326
+ unless i >= 0 and
327
+ act = action_table[i] and
328
+ action_check[i] == @racc_state[-1]
329
+ act = action_default[@racc_state[-1]]
330
+ end
331
+ else
332
+ act = action_default[@racc_state[-1]]
333
+ end
334
+ while act = _racc_evalact(act, arg)
335
+ ;
336
+ end
337
+ end
338
+ }
339
+ end
340
+
341
+ # Another entry point for the parser.
342
+ # If you use this method, you must implement RECEIVER#METHOD_ID method.
343
+ #
344
+ # RECEIVER#METHOD_ID is a method to get next token.
345
+ # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
346
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
347
+ def yyparse(recv, mid)
348
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
349
+ end
350
+ RUBY
351
+
352
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
353
+ action_table, action_check, action_default, action_pointer,
354
+ _, _, _, _,
355
+ _, _, token_table, * = arg
356
+
357
+ _racc_init_sysvars
358
+
359
+ catch(:racc_end_parse) {
360
+ until i = action_pointer[@racc_state[-1]]
361
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
362
+ ;
363
+ end
364
+ end
365
+ recv.__send__(mid) do |tok, val|
366
+ unless tok
367
+ @racc_t = 0
368
+ else
369
+ @racc_t = (token_table[tok] or 1) # error token
370
+ end
371
+ @racc_val = val
372
+ @racc_read_next = false
373
+
374
+ i += @racc_t
375
+ unless i >= 0 and
376
+ act = action_table[i] and
377
+ action_check[i] == @racc_state[-1]
378
+ act = action_default[@racc_state[-1]]
379
+ end
380
+ while act = _racc_evalact(act, arg)
381
+ ;
382
+ end
383
+
384
+ while !(i = action_pointer[@racc_state[-1]]) ||
385
+ ! @racc_read_next ||
386
+ @racc_t == 0 # $
387
+ unless i and i += @racc_t and
388
+ i >= 0 and
389
+ act = action_table[i] and
390
+ action_check[i] == @racc_state[-1]
391
+ act = action_default[@racc_state[-1]]
392
+ end
393
+ while act = _racc_evalact(act, arg)
394
+ ;
395
+ end
396
+ end
397
+ end
398
+ }
399
+ end
400
+
401
+ ###
402
+ ### common
403
+ ###
404
+
405
+ def _racc_evalact(act, arg)
406
+ action_table, action_check, _, action_pointer,
407
+ _, _, _, _,
408
+ _, _, _, shift_n,
409
+ reduce_n, * = arg
410
+ nerr = 0 # tmp
411
+
412
+ if act > 0 and act < shift_n
413
+ #
414
+ # shift
415
+ #
416
+ if @racc_error_status > 0
417
+ @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
418
+ end
419
+ @racc_vstack.push @racc_val
420
+ @racc_state.push act
421
+ @racc_read_next = true
422
+ if @yydebug
423
+ @racc_tstack.push @racc_t
424
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
425
+ end
426
+
427
+ elsif act < 0 and act > -reduce_n
428
+ #
429
+ # reduce
430
+ #
431
+ code = catch(:racc_jump) {
432
+ @racc_state.push _racc_do_reduce(arg, act)
433
+ false
434
+ }
435
+ if code
436
+ case code
437
+ when 1 # yyerror
438
+ @racc_user_yyerror = true # user_yyerror
439
+ return -reduce_n
440
+ when 2 # yyaccept
441
+ return shift_n
442
+ else
443
+ raise '[Racc Bug] unknown jump code'
444
+ end
445
+ end
446
+
447
+ elsif act == shift_n
448
+ #
449
+ # accept
450
+ #
451
+ racc_accept if @yydebug
452
+ throw :racc_end_parse, @racc_vstack[0]
453
+
454
+ elsif act == -reduce_n
455
+ #
456
+ # error
457
+ #
458
+ case @racc_error_status
459
+ when 0
460
+ unless arg[21] # user_yyerror
461
+ nerr += 1
462
+ on_error @racc_t, @racc_val, @racc_vstack
463
+ end
464
+ when 3
465
+ if @racc_t == 0 # is $
466
+ # We're at EOF, and another error occurred immediately after
467
+ # attempting auto-recovery
468
+ throw :racc_end_parse, nil
469
+ end
470
+ @racc_read_next = true
471
+ end
472
+ @racc_user_yyerror = false
473
+ @racc_error_status = 3
474
+ while true
475
+ if i = action_pointer[@racc_state[-1]]
476
+ i += 1 # error token
477
+ if i >= 0 and
478
+ (act = action_table[i]) and
479
+ action_check[i] == @racc_state[-1]
480
+ break
481
+ end
482
+ end
483
+ throw :racc_end_parse, nil if @racc_state.size <= 1
484
+ @racc_state.pop
485
+ @racc_vstack.pop
486
+ if @yydebug
487
+ @racc_tstack.pop
488
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
489
+ end
490
+ end
491
+ return act
492
+
493
+ else
494
+ raise "[Racc Bug] unknown action #{act.inspect}"
495
+ end
496
+
497
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
498
+
499
+ nil
500
+ end
501
+
502
+ def _racc_do_reduce(arg, act)
503
+ _, _, _, _,
504
+ goto_table, goto_check, goto_default, goto_pointer,
505
+ nt_base, reduce_table, _, _,
506
+ _, use_result, * = arg
507
+
508
+ state = @racc_state
509
+ vstack = @racc_vstack
510
+ tstack = @racc_tstack
511
+
512
+ i = act * -3
513
+ len = reduce_table[i]
514
+ reduce_to = reduce_table[i+1]
515
+ method_id = reduce_table[i+2]
516
+ void_array = []
517
+
518
+ tmp_t = tstack[-len, len] if @yydebug
519
+ tmp_v = vstack[-len, len]
520
+ tstack[-len, len] = void_array if @yydebug
521
+ vstack[-len, len] = void_array
522
+ state[-len, len] = void_array
523
+
524
+ # tstack must be updated AFTER method call
525
+ if use_result
526
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
527
+ else
528
+ vstack.push __send__(method_id, tmp_v, vstack)
529
+ end
530
+ tstack.push reduce_to
531
+
532
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
533
+
534
+ k1 = reduce_to - nt_base
535
+ if i = goto_pointer[k1]
536
+ i += state[-1]
537
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
538
+ return curstate
539
+ end
540
+ end
541
+ goto_default[k1]
542
+ end
543
+
544
+ # This method is called when a parse error is found.
545
+ #
546
+ # ERROR_TOKEN_ID is an internal ID of token which caused error.
547
+ # You can get string representation of this ID by calling
548
+ # #token_to_str.
549
+ #
550
+ # ERROR_VALUE is a value of error token.
551
+ #
552
+ # value_stack is a stack of symbol values.
553
+ # DO NOT MODIFY this object.
554
+ #
555
+ # This method raises ParseError by default.
556
+ #
557
+ # If this method returns, parsers enter "error recovering mode".
558
+ def on_error(t, val, vstack)
559
+ raise ParseError, sprintf("parse error on value %s (%s)",
560
+ val.inspect, token_to_str(t) || '?')
561
+ end
562
+
563
+ # Enter error recovering mode.
564
+ # This method does not call #on_error.
565
+ def yyerror
566
+ throw :racc_jump, 1
567
+ end
568
+
569
+ # Exit parser.
570
+ # Return value is +Symbol_Value_Stack[0]+.
571
+ def yyaccept
572
+ throw :racc_jump, 2
573
+ end
574
+
575
+ # Leave error recovering mode.
576
+ def yyerrok
577
+ @racc_error_status = 0
578
+ end
579
+
580
+ # For debugging output
581
+ def racc_read_token(t, tok, val)
582
+ @racc_debug_out.print 'read '
583
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
584
+ @racc_debug_out.puts val.inspect
585
+ @racc_debug_out.puts
586
+ end
587
+
588
+ def racc_shift(tok, tstack, vstack)
589
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
590
+ racc_print_stacks tstack, vstack
591
+ @racc_debug_out.puts
592
+ end
593
+
594
+ def racc_reduce(toks, sim, tstack, vstack)
595
+ out = @racc_debug_out
596
+ out.print 'reduce '
597
+ if toks.empty?
598
+ out.print ' <none>'
599
+ else
600
+ toks.each {|t| out.print ' ', racc_token2str(t) }
601
+ end
602
+ out.puts " --> #{racc_token2str(sim)}"
603
+ racc_print_stacks tstack, vstack
604
+ @racc_debug_out.puts
605
+ end
606
+
607
+ def racc_accept
608
+ @racc_debug_out.puts 'accept'
609
+ @racc_debug_out.puts
610
+ end
611
+
612
+ def racc_e_pop(state, tstack, vstack)
613
+ @racc_debug_out.puts 'error recovering mode: pop token'
614
+ racc_print_states state
615
+ racc_print_stacks tstack, vstack
616
+ @racc_debug_out.puts
617
+ end
618
+
619
+ def racc_next_state(curstate, state)
620
+ @racc_debug_out.puts "goto #{curstate}"
621
+ racc_print_states state
622
+ @racc_debug_out.puts
623
+ end
624
+
625
+ def racc_print_stacks(t, v)
626
+ out = @racc_debug_out
627
+ out.print ' ['
628
+ t.each_index do |i|
629
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
630
+ end
631
+ out.puts ' ]'
632
+ end
633
+
634
+ def racc_print_states(s)
635
+ out = @racc_debug_out
636
+ out.print ' ['
637
+ s.each {|st| out.print ' ', st }
638
+ out.puts ' ]'
639
+ end
640
+
641
+ def racc_token2str(tok)
642
+ self.class::Racc_token_to_s_table[tok] or
643
+ raise "[Racc Bug] can't convert token #{tok} to string"
644
+ end
645
+
646
+ # Convert internal ID of token symbol to the string.
647
+ def token_to_str(t)
648
+ self.class::Racc_token_to_s_table[t]
649
+ end
650
+
651
+ end
652
+
653
+ end
654
+
655
+ end
656
+ ###### racc/parser.rb end
9
657
 
10
658
  require 'strscan'
11
659
 
data/lib/rdoc/store.rb CHANGED
@@ -197,6 +197,9 @@ class RDoc::Store
197
197
  top_level
198
198
  end
199
199
 
200
+ ##
201
+ # Sets the parser of +absolute_name+, unless it from a source code file.
202
+
200
203
  def update_parser_of_file(absolute_name, parser)
201
204
  if top_level = @files_hash[absolute_name] then
202
205
  @text_files_hash[absolute_name] = top_level if top_level.text?
data/lib/rdoc/text.rb CHANGED
@@ -10,6 +10,10 @@ require 'strscan'
10
10
 
11
11
  module RDoc::Text
12
12
 
13
+ ##
14
+ # The language for this text. This affects stripping comments
15
+ # markers.
16
+
13
17
  attr_accessor :language
14
18
 
15
19
  ##
@@ -309,4 +313,10 @@ module RDoc::Text
309
313
  res.join.strip
310
314
  end
311
315
 
316
+ ##
317
+ # Character class to be separated by a space when concatenating
318
+ # lines.
319
+
320
+ SPACE_SEPARATED_LETTER_CLASS = /[\p{Nd}\p{Lc}\p{Pc}]|[!-~&&\W]/
321
+
312
322
  end
@@ -112,7 +112,7 @@ module RDoc::TokenStream
112
112
  # Returns a string representation of the token stream
113
113
 
114
114
  def tokens_to_s
115
- token_stream.compact.map { |token| token[:text] }.join ''
115
+ (token_stream or return '').compact.map { |token| token[:text] }.join ''
116
116
  end
117
117
 
118
118
  end
@@ -52,6 +52,9 @@ class RDoc::TopLevel < RDoc::Context
52
52
  @classes_or_modules = []
53
53
  end
54
54
 
55
+ ##
56
+ # Sets the parser for this toplevel context, also the store.
57
+
55
58
  def parser=(val)
56
59
  @parser = val
57
60
  @store.update_parser_of_file(absolute_name, val) if @store
data/lib/rdoc/version.rb CHANGED
@@ -5,6 +5,6 @@ module RDoc
5
5
  ##
6
6
  # RDoc version you are using
7
7
 
8
- VERSION = '6.6.0'
8
+ VERSION = '6.6.2'
9
9
 
10
10
  end
data/lib/rdoc.rb CHANGED
@@ -120,6 +120,17 @@ module RDoc
120
120
  end
121
121
  end
122
122
 
123
+ ##
124
+ # Seaches and returns the directory for settings.
125
+ #
126
+ # 1. <tt>$HOME/.rdoc</tt> directory, if it exists.
127
+ # 2. The +rdoc+ directory under the path specified by the
128
+ # +XDG_DATA_HOME+ environment variable, if it is set.
129
+ # 3. <tt>$HOME/.local/share/rdoc</tt> directory.
130
+ #
131
+ # Other than the home directory, the containing directory will be
132
+ # created automatically.
133
+
123
134
  def self.home
124
135
  rdoc_dir = begin
125
136
  File.expand_path('~/.rdoc')
@@ -129,6 +140,7 @@ module RDoc
129
140
  if File.directory?(rdoc_dir)
130
141
  rdoc_dir
131
142
  else
143
+ require 'fileutils'
132
144
  begin
133
145
  # XDG
134
146
  xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.0
4
+ version: 6.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: exe
16
16
  cert_chain: []
17
- date: 2023-11-06 00:00:00.000000000 Z
17
+ date: 2023-12-16 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: psych