rdoc 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -3
  3. data/RI.md +75 -75
  4. data/exe/rdoc +2 -2
  5. data/lib/rdoc/code_object/alias.rb +71 -69
  6. data/lib/rdoc/code_object/any_method.rb +305 -303
  7. data/lib/rdoc/code_object/attr.rb +150 -148
  8. data/lib/rdoc/code_object/class_module.rb +798 -792
  9. data/lib/rdoc/code_object/constant.rb +175 -173
  10. data/lib/rdoc/code_object/context/section.rb +142 -138
  11. data/lib/rdoc/code_object/context.rb +926 -958
  12. data/lib/rdoc/code_object/extend.rb +7 -5
  13. data/lib/rdoc/code_object/include.rb +7 -5
  14. data/lib/rdoc/code_object/method_attr.rb +326 -319
  15. data/lib/rdoc/code_object/mixin.rb +97 -95
  16. data/lib/rdoc/code_object/normal_class.rb +77 -78
  17. data/lib/rdoc/code_object/normal_module.rb +61 -59
  18. data/lib/rdoc/code_object/require.rb +23 -39
  19. data/lib/rdoc/code_object/single_class.rb +21 -19
  20. data/lib/rdoc/code_object/top_level.rb +212 -219
  21. data/lib/rdoc/code_object.rb +305 -303
  22. data/lib/rdoc/comment.rb +275 -273
  23. data/lib/rdoc/cross_reference.rb +192 -190
  24. data/lib/rdoc/encoding.rb +105 -103
  25. data/lib/rdoc/erb_partial.rb +13 -11
  26. data/lib/rdoc/erbio.rb +29 -27
  27. data/lib/rdoc/generator/aliki.rb +161 -153
  28. data/lib/rdoc/generator/darkfish.rb +645 -635
  29. data/lib/rdoc/generator/json_index.rb +233 -229
  30. data/lib/rdoc/generator/markup.rb +164 -146
  31. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  32. data/lib/rdoc/generator/pot/po.rb +52 -51
  33. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  34. data/lib/rdoc/generator/pot.rb +85 -81
  35. data/lib/rdoc/generator/ri.rb +23 -19
  36. data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
  37. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
  39. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  40. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  41. data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
  42. data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  44. data/lib/rdoc/generator.rb +48 -46
  45. data/lib/rdoc/i18n/locale.rb +99 -95
  46. data/lib/rdoc/i18n/text.rb +109 -105
  47. data/lib/rdoc/i18n.rb +7 -5
  48. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  49. data/lib/rdoc/markdown.kpeg +15 -11
  50. data/lib/rdoc/markdown.rb +40 -47
  51. data/lib/rdoc/markup/block_quote.rb +12 -8
  52. data/lib/rdoc/markup/document.rb +127 -123
  53. data/lib/rdoc/markup/formatter.rb +219 -215
  54. data/lib/rdoc/markup/include.rb +33 -29
  55. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  56. data/lib/rdoc/markup/inline_parser.rb +281 -277
  57. data/lib/rdoc/markup/list.rb +80 -88
  58. data/lib/rdoc/markup/list_item.rb +73 -85
  59. data/lib/rdoc/markup/paragraph.rb +23 -19
  60. data/lib/rdoc/markup/parser.rb +501 -497
  61. data/lib/rdoc/markup/pre_process.rb +283 -279
  62. data/lib/rdoc/markup/raw.rb +2 -2
  63. data/lib/rdoc/markup/rule.rb +16 -12
  64. data/lib/rdoc/markup/to_ansi.rb +143 -139
  65. data/lib/rdoc/markup/to_bs.rb +72 -68
  66. data/lib/rdoc/markup/to_html.rb +594 -565
  67. data/lib/rdoc/markup/to_html_crossref.rb +234 -230
  68. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  69. data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
  70. data/lib/rdoc/markup/to_label.rb +63 -59
  71. data/lib/rdoc/markup/to_markdown.rb +212 -208
  72. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  73. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  74. data/lib/rdoc/markup/to_test.rb +60 -56
  75. data/lib/rdoc/markup/to_tt_only.rb +84 -80
  76. data/lib/rdoc/markup/verbatim.rb +62 -58
  77. data/lib/rdoc/markup.rb +198 -196
  78. data/lib/rdoc/options.rb +1063 -1061
  79. data/lib/rdoc/parser/c.rb +1039 -1037
  80. data/lib/rdoc/parser/changelog.rb +319 -315
  81. data/lib/rdoc/parser/markdown.rb +17 -13
  82. data/lib/rdoc/parser/rbs.rb +239 -235
  83. data/lib/rdoc/parser/rd.rb +17 -13
  84. data/lib/rdoc/parser/ruby.rb +1245 -1124
  85. data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
  86. data/lib/rdoc/parser/simple.rb +31 -27
  87. data/lib/rdoc/parser/text.rb +12 -8
  88. data/lib/rdoc/parser.rb +228 -220
  89. data/lib/rdoc/rbs_helper.rb +1 -1
  90. data/lib/rdoc/rd/inline.rb +57 -53
  91. data/lib/rdoc/rd.rb +90 -88
  92. data/lib/rdoc/rdoc.rb +500 -491
  93. data/lib/rdoc/ri/driver.rb +1140 -1135
  94. data/lib/rdoc/ri/formatter.rb +7 -3
  95. data/lib/rdoc/ri/paths.rb +140 -136
  96. data/lib/rdoc/ri/servlet.rb +354 -350
  97. data/lib/rdoc/ri/store.rb +4 -2
  98. data/lib/rdoc/ri/task.rb +55 -51
  99. data/lib/rdoc/ri.rb +14 -12
  100. data/lib/rdoc/rubygems_hook.rb +183 -181
  101. data/lib/rdoc/server.rb +349 -347
  102. data/lib/rdoc/stats/normal.rb +46 -42
  103. data/lib/rdoc/stats/quiet.rb +39 -35
  104. data/lib/rdoc/stats/verbose.rb +35 -31
  105. data/lib/rdoc/stats.rb +365 -363
  106. data/lib/rdoc/store.rb +888 -902
  107. data/lib/rdoc/task.rb +260 -256
  108. data/lib/rdoc/text.rb +135 -133
  109. data/lib/rdoc/token_stream.rb +101 -93
  110. data/lib/rdoc/tom_doc.rb +203 -201
  111. data/lib/rdoc/version.rb +1 -1
  112. metadata +4 -5
  113. data/lib/rdoc/markdown/literals.kpeg +0 -21
  114. data/lib/rdoc/markdown/literals.rb +0 -454
@@ -1,144 +1,148 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # Outputs RDoc markup with vibrant ANSI color!
2
+ module RDoc
3
+ class Markup
4
+ ##
5
+ # Outputs RDoc markup with vibrant ANSI color!
6
+
7
+ class ToAnsi < Markup::ToRdoc
8
+
9
+ ##
10
+ # Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
11
+
12
+ def initialize
13
+ super
14
+
15
+ @headings.clear
16
+ @headings[1] = ["\e[1;32m", "\e[m"] # bold
17
+ @headings[2] = ["\e[4;32m", "\e[m"] # underline
18
+ @headings[3] = ["\e[32m", "\e[m"] # just green
19
+ end
20
+
21
+ ##
22
+ # Maps attributes to ANSI sequences
23
+
24
+ ANSI_STYLE_CODES_ON = {
25
+ BOLD: 1,
26
+ TT: 7,
27
+ EM: 4,
28
+ STRIKE: 9
29
+ }
30
+
31
+ ANSI_STYLE_CODES_OFF = {
32
+ BOLD: 22,
33
+ TT: 27,
34
+ EM: 24,
35
+ STRIKE: 29
36
+ }
37
+
38
+ # Apply the given attributes by emitting ANSI sequences.
39
+ # Emitting attribute changes are deferred until new text is added and applied in batch.
40
+ # This method computes the necessary ANSI codes to transition from the
41
+ # current set of applied attributes to the new set of +attributes+.
42
+
43
+ def apply_attributes(attributes)
44
+ before = @applied_attributes
45
+ after = attributes.sort
46
+ return if before == after
47
+
48
+ if after.empty?
49
+ emit_inline("\e[m")
50
+ elsif !before.empty? && before.size > (before & after).size + 1
51
+ codes = after.map {|attr| ANSI_STYLE_CODES_ON[attr] }.compact
52
+ emit_inline("\e[#{[0, *codes].join(';')}m")
53
+ else
54
+ off_codes = (before - after).map {|attr| ANSI_STYLE_CODES_OFF[attr] }.compact
55
+ on_codes = (after - before).map {|attr| ANSI_STYLE_CODES_ON[attr] }.compact
56
+ emit_inline("\e[#{(off_codes + on_codes).join(';')}m")
57
+ end
58
+ @applied_attributes = attributes
59
+ end
60
+
61
+ def add_text(text)
62
+ attrs = @attributes.keys
63
+ if @applied_attributes != attrs
64
+ apply_attributes(attrs)
65
+ end
66
+ emit_inline(text)
67
+ end
68
+
69
+ def handle_inline(text)
70
+ @applied_attributes = []
71
+ res = super
72
+ res << "\e[m" unless @applied_attributes.empty?
73
+ @applied_attributes = []
74
+ res
75
+ end
76
+
77
+ ##
78
+ # Overrides indent width to ensure output lines up correctly.
79
+
80
+ def accept_list_item_end(list_item)
81
+ width = case @list_type.last
82
+ when :BULLET
83
+ 2
84
+ when :NOTE, :LABEL
85
+ if @prefix
86
+ @res << @prefix.strip
87
+ @prefix = nil
88
+ end
89
+
90
+ @res << "\n" unless res.length == 1
91
+ 2
92
+ else
93
+ bullet = @list_index.last.to_s
94
+ @list_index[-1] = @list_index.last.succ
95
+ bullet.length + 2
96
+ end
97
+
98
+ @indent -= width
99
+ end
100
+
101
+ ##
102
+ # Adds coloring to note and label list items
103
+
104
+ def accept_list_item_start(list_item)
105
+ bullet = case @list_type.last
106
+ when :BULLET
107
+ '*'
108
+ when :NOTE, :LABEL
109
+ labels = Array(list_item.label).map do |label|
110
+ attributes(label).strip
111
+ end.join "\n"
112
+
113
+ labels << ":\n" unless labels.empty?
114
+
115
+ labels
116
+ else
117
+ @list_index.last.to_s + '.'
118
+ end
119
+
120
+ case @list_type.last
121
+ when :NOTE, :LABEL
122
+ @indent += 2
123
+ @prefix = bullet + (' ' * @indent)
124
+ else
125
+ @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
126
+
127
+ width = bullet.gsub(/\e\[[\d;]*m/, '').length + 1
128
+
129
+ @indent += width
130
+ end
131
+ end
132
+
133
+ def calculate_text_width(text)
134
+ text.gsub(/\e\[[\d;]*m/, '').size
135
+ end
136
+
137
+ ##
138
+ # Starts accepting with a reset screen
139
+
140
+ def start_accepting
141
+ super
142
+
143
+ @res = ["\e[0m"]
144
+ end
4
145
 
5
- class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
6
-
7
- ##
8
- # Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
9
-
10
- def initialize
11
- super
12
-
13
- @headings.clear
14
- @headings[1] = ["\e[1;32m", "\e[m"] # bold
15
- @headings[2] = ["\e[4;32m", "\e[m"] # underline
16
- @headings[3] = ["\e[32m", "\e[m"] # just green
17
- end
18
-
19
- ##
20
- # Maps attributes to ANSI sequences
21
-
22
- ANSI_STYLE_CODES_ON = {
23
- BOLD: 1,
24
- TT: 7,
25
- EM: 4,
26
- STRIKE: 9
27
- }
28
-
29
- ANSI_STYLE_CODES_OFF = {
30
- BOLD: 22,
31
- TT: 27,
32
- EM: 24,
33
- STRIKE: 29
34
- }
35
-
36
- # Apply the given attributes by emitting ANSI sequences.
37
- # Emitting attribute changes are deferred until new text is added and applied in batch.
38
- # This method computes the necessary ANSI codes to transition from the
39
- # current set of applied attributes to the new set of +attributes+.
40
-
41
- def apply_attributes(attributes)
42
- before = @applied_attributes
43
- after = attributes.sort
44
- return if before == after
45
-
46
- if after.empty?
47
- emit_inline("\e[m")
48
- elsif !before.empty? && before.size > (before & after).size + 1
49
- codes = after.map {|attr| ANSI_STYLE_CODES_ON[attr] }.compact
50
- emit_inline("\e[#{[0, *codes].join(';')}m")
51
- else
52
- off_codes = (before - after).map {|attr| ANSI_STYLE_CODES_OFF[attr] }.compact
53
- on_codes = (after - before).map {|attr| ANSI_STYLE_CODES_ON[attr] }.compact
54
- emit_inline("\e[#{(off_codes + on_codes).join(';')}m")
55
- end
56
- @applied_attributes = attributes
57
- end
58
-
59
- def add_text(text)
60
- attrs = @attributes.keys
61
- if @applied_attributes != attrs
62
- apply_attributes(attrs)
63
- end
64
- emit_inline(text)
65
- end
66
-
67
- def handle_inline(text)
68
- @applied_attributes = []
69
- res = super
70
- res << "\e[m" unless @applied_attributes.empty?
71
- @applied_attributes = []
72
- res
73
- end
74
-
75
- ##
76
- # Overrides indent width to ensure output lines up correctly.
77
-
78
- def accept_list_item_end(list_item)
79
- width = case @list_type.last
80
- when :BULLET then
81
- 2
82
- when :NOTE, :LABEL then
83
- if @prefix then
84
- @res << @prefix.strip
85
- @prefix = nil
86
- end
87
-
88
- @res << "\n" unless res.length == 1
89
- 2
90
- else
91
- bullet = @list_index.last.to_s
92
- @list_index[-1] = @list_index.last.succ
93
- bullet.length + 2
94
- end
95
-
96
- @indent -= width
97
- end
98
-
99
- ##
100
- # Adds coloring to note and label list items
101
-
102
- def accept_list_item_start(list_item)
103
- bullet = case @list_type.last
104
- when :BULLET then
105
- '*'
106
- when :NOTE, :LABEL then
107
- labels = Array(list_item.label).map do |label|
108
- attributes(label).strip
109
- end.join "\n"
110
-
111
- labels << ":\n" unless labels.empty?
112
-
113
- labels
114
- else
115
- @list_index.last.to_s + '.'
116
- end
117
-
118
- case @list_type.last
119
- when :NOTE, :LABEL then
120
- @indent += 2
121
- @prefix = bullet + (' ' * @indent)
122
- else
123
- @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
124
-
125
- width = bullet.gsub(/\e\[[\d;]*m/, '').length + 1
126
-
127
- @indent += width
128
146
  end
129
147
  end
130
-
131
- def calculate_text_width(text)
132
- text.gsub(/\e\[[\d;]*m/, '').size
133
- end
134
-
135
- ##
136
- # Starts accepting with a reset screen
137
-
138
- def start_accepting
139
- super
140
-
141
- @res = ["\e[0m"]
142
- end
143
-
144
148
  end
@@ -1,86 +1,90 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # Outputs RDoc markup with hot backspace action! You will probably need a
4
- # pager to use this output format.
5
- #
6
- # This formatter won't work on 1.8.6 because it lacks String#chars.
2
+ module RDoc
3
+ class Markup
4
+ ##
5
+ # Outputs RDoc markup with hot backspace action! You will probably need a
6
+ # pager to use this output format.
7
+ #
8
+ # This formatter won't work on 1.8.6 because it lacks String#chars.
7
9
 
8
- class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
10
+ class ToBs < Markup::ToRdoc
9
11
 
10
- ##
11
- # Returns a new ToBs that is ready for hot backspace action!
12
+ ##
13
+ # Returns a new ToBs that is ready for hot backspace action!
12
14
 
13
- def initialize
14
- super
15
+ def initialize
16
+ super
15
17
 
16
- @in_b = false
17
- @in_em = false
18
- end
19
-
20
- def handle_inline(text)
21
- initial_style = []
22
- initial_style << :BOLD if @in_b
23
- initial_style << :EM if @in_em
24
- super(text, initial_style)
25
- end
18
+ @in_b = false
19
+ @in_em = false
20
+ end
26
21
 
27
- def add_text(text)
28
- attrs = @attributes.keys
29
- if attrs.include? :BOLD
30
- styled = +''
31
- text.chars.each do |c|
32
- styled << "#{c}\b#{c}"
22
+ def handle_inline(text)
23
+ initial_style = []
24
+ initial_style << :BOLD if @in_b
25
+ initial_style << :EM if @in_em
26
+ super(text, initial_style)
33
27
  end
34
- text = styled
35
- elsif attrs.include? :EM
36
- styled = +''
37
- text.chars.each do |c|
38
- styled << "_\b#{c}"
28
+
29
+ def add_text(text)
30
+ attrs = @attributes.keys
31
+ if attrs.include? :BOLD
32
+ styled = +''
33
+ text.chars.each do |c|
34
+ styled << "#{c}\b#{c}"
35
+ end
36
+ text = styled
37
+ elsif attrs.include? :EM
38
+ styled = +''
39
+ text.chars.each do |c|
40
+ styled << "_\b#{c}"
41
+ end
42
+ text = styled
43
+ end
44
+ emit_inline(text)
39
45
  end
40
- text = styled
41
- end
42
- emit_inline(text)
43
- end
44
46
 
45
- ##
46
- # Makes heading text bold.
47
+ ##
48
+ # Makes heading text bold.
47
49
 
48
- def accept_heading(heading)
49
- use_prefix or @res << ' ' * @indent
50
- @res << @headings[heading.level][0]
51
- @in_b = true
52
- @res << attributes(heading.text)
53
- @in_b = false
54
- @res << @headings[heading.level][1]
55
- @res << "\n"
56
- end
50
+ def accept_heading(heading)
51
+ use_prefix or @res << ' ' * @indent
52
+ @res << @headings[heading.level][0]
53
+ @in_b = true
54
+ @res << attributes(heading.text)
55
+ @in_b = false
56
+ @res << @headings[heading.level][1]
57
+ @res << "\n"
58
+ end
57
59
 
58
- ##
59
- # Prepares the visitor for consuming +list_item+
60
+ ##
61
+ # Prepares the visitor for consuming +list_item+
60
62
 
61
- def accept_list_item_start(list_item)
62
- type = @list_type.last
63
+ def accept_list_item_start(list_item)
64
+ type = @list_type.last
63
65
 
64
- case type
65
- when :NOTE, :LABEL then
66
- bullets = Array(list_item.label).map do |label|
67
- attributes(label).strip
68
- end.join "\n"
66
+ case type
67
+ when :NOTE, :LABEL
68
+ bullets = Array(list_item.label).map do |label|
69
+ attributes(label).strip
70
+ end.join "\n"
69
71
 
70
- bullets << ":\n" unless bullets.empty?
72
+ bullets << ":\n" unless bullets.empty?
71
73
 
72
- @prefix = ' ' * @indent
73
- @indent += 2
74
- @prefix << bullets + (' ' * @indent)
75
- else
76
- bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
77
- @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
78
- width = bullet.length + 1
79
- @indent += width
80
- end
81
- end
74
+ @prefix = ' ' * @indent
75
+ @indent += 2
76
+ @prefix << bullets + (' ' * @indent)
77
+ else
78
+ bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
79
+ @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
80
+ width = bullet.length + 1
81
+ @indent += width
82
+ end
83
+ end
82
84
 
83
- def calculate_text_width(text)
84
- text.gsub(/_\x08/, '').gsub(/\x08./, '').size
85
+ def calculate_text_width(text)
86
+ text.gsub(/_\x08/, '').gsub(/\x08./, '').size
87
+ end
88
+ end
85
89
  end
86
90
  end