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
data/lib/rdoc/erbio.rb CHANGED
@@ -1,37 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
  require 'erb'
3
3
 
4
- ##
5
- # A subclass of ERB that writes directly to an IO. Credit to Aaron Patterson
6
- # and Masatoshi SEKI.
7
- #
8
- # To use:
9
- #
10
- # erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
11
- #
12
- # File.open 'hello.txt', 'w' do |io|
13
- # erbio.result binding
14
- # end
15
- #
16
- # Note that binding must enclose the io you wish to output on.
4
+ module RDoc
5
+ ##
6
+ # A subclass of ERB that writes directly to an IO. Credit to Aaron Patterson
7
+ # and Masatoshi SEKI.
8
+ #
9
+ # To use:
10
+ #
11
+ # erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
12
+ #
13
+ # File.open 'hello.txt', 'w' do |io|
14
+ # erbio.result binding
15
+ # end
16
+ #
17
+ # Note that binding must enclose the io you wish to output on.
17
18
 
18
- class RDoc::ERBIO < ERB
19
+ class ERBIO < ERB
19
20
 
20
- ##
21
- # Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
21
+ ##
22
+ # Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
22
23
 
23
- def initialize(str, trim_mode: nil, eoutvar: 'io')
24
- super(str, trim_mode: trim_mode, eoutvar: eoutvar)
25
- end
24
+ def initialize(str, trim_mode: nil, eoutvar: 'io')
25
+ super(str, trim_mode: trim_mode, eoutvar: eoutvar)
26
+ end
26
27
 
27
- ##
28
- # Instructs +compiler+ how to write to +io_variable+
28
+ ##
29
+ # Instructs +compiler+ how to write to +io_variable+
29
30
 
30
- def set_eoutvar(compiler, io_variable)
31
- compiler.put_cmd = "#{io_variable}.write"
32
- compiler.insert_cmd = "#{io_variable}.write"
33
- compiler.pre_cmd = []
34
- compiler.post_cmd = []
35
- end
31
+ def set_eoutvar(compiler, io_variable)
32
+ compiler.put_cmd = "#{io_variable}.write"
33
+ compiler.insert_cmd = "#{io_variable}.write"
34
+ compiler.pre_cmd = []
35
+ compiler.post_cmd = []
36
+ end
36
37
 
38
+ end
37
39
  end
@@ -2,199 +2,207 @@
2
2
 
3
3
  require 'uri'
4
4
 
5
- ##
6
- # Aliki theme for RDoc documentation
7
- #
8
- # Author: Stan Lo
9
- #
5
+ module RDoc
6
+ module Generator
7
+ ##
8
+ # Aliki theme for RDoc documentation
9
+ #
10
+ # Author: Stan Lo
11
+ #
12
+
13
+ class Aliki < Generator::Darkfish
14
+ DESCRIPTION = 'HTML generator, written by Stan Lo'
15
+
16
+ RDoc.add_generator self
17
+
18
+ def initialize(store, options)
19
+ super
20
+ aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki'))
21
+ @template_dir = Pathname.new(aliki_template_dir)
22
+ end
10
23
 
11
- class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
12
- DESCRIPTION = 'HTML generator, written by Stan Lo'
24
+ ##
25
+ # Generate documentation. Overrides Darkfish to use Aliki's own search index
26
+ # instead of the JsonIndex generator.
13
27
 
14
- RDoc::RDoc.add_generator self
28
+ def generate
29
+ setup
15
30
 
16
- def initialize(store, options)
17
- super
18
- aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki'))
19
- @template_dir = Pathname.new(aliki_template_dir)
20
- end
31
+ write_style_sheet
32
+ generate_index
33
+ generate_class_files
34
+ generate_file_files
35
+ generate_table_of_contents
36
+ write_search_index
21
37
 
22
- ##
23
- # Generate documentation. Overrides Darkfish to use Aliki's own search index
24
- # instead of the JsonIndex generator.
38
+ copy_static
25
39
 
26
- def generate
27
- setup
40
+ rescue => e
41
+ debug_msg "%s: %s\n %s" % [
42
+ e.class.name, e.message, e.backtrace.join("\n ")
43
+ ]
28
44
 
29
- write_style_sheet
30
- generate_index
31
- generate_class_files
32
- generate_file_files
33
- generate_table_of_contents
34
- write_search_index
45
+ raise
46
+ end
35
47
 
36
- copy_static
48
+ ##
49
+ # Copy only the static assets required by the Aliki theme. Unlike Darkfish we
50
+ # don't ship embedded fonts or image sprites, so limit the asset list to keep
51
+ # generated documentation lightweight.
37
52
 
38
- rescue => e
39
- debug_msg "%s: %s\n %s" % [
40
- e.class.name, e.message, e.backtrace.join("\n ")
41
- ]
53
+ def write_style_sheet
54
+ debug_msg "Copying Aliki static files"
55
+ options = { verbose: $DEBUG_RDOC, noop: @dry_run }
42
56
 
43
- raise
44
- end
57
+ install_rdoc_static_file @template_dir + 'css/rdoc.css', "./css/rdoc.css", options
45
58
 
46
- ##
47
- # Copy only the static assets required by the Aliki theme. Unlike Darkfish we
48
- # don't ship embedded fonts or image sprites, so limit the asset list to keep
49
- # generated documentation lightweight.
59
+ unless @options.template_stylesheets.empty?
60
+ FileUtils.cp @options.template_stylesheets, '.', **options
61
+ end
50
62
 
51
- def write_style_sheet
52
- debug_msg "Copying Aliki static files"
53
- options = { verbose: $DEBUG_RDOC, noop: @dry_run }
63
+ Dir[(@template_dir + 'js/**/*').to_s].each do |path|
64
+ next if File.directory?(path)
65
+ next if File.basename(path).start_with?('.')
54
66
 
55
- install_rdoc_static_file @template_dir + 'css/rdoc.css', "./css/rdoc.css", options
67
+ dst = Pathname.new(path).relative_path_from(@template_dir)
56
68
 
57
- unless @options.template_stylesheets.empty?
58
- FileUtils.cp @options.template_stylesheets, '.', **options
59
- end
69
+ install_rdoc_static_file @template_dir + path, dst, options
70
+ end
71
+ end
60
72
 
61
- Dir[(@template_dir + 'js/**/*').to_s].each do |path|
62
- next if File.directory?(path)
63
- next if File.basename(path).start_with?('.')
73
+ ##
74
+ # Build a search index array for Aliki's searcher.
64
75
 
65
- dst = Pathname.new(path).relative_path_from(@template_dir)
76
+ def build_search_index
77
+ setup
66
78
 
67
- install_rdoc_static_file @template_dir + path, dst, options
68
- end
69
- end
79
+ index = []
70
80
 
71
- ##
72
- # Build a search index array for Aliki's searcher.
81
+ @classes.each do |klass|
82
+ next unless klass.display?
73
83
 
74
- def build_search_index
75
- setup
84
+ index << build_class_module_entry(klass)
76
85
 
77
- index = []
86
+ klass.constants.each do |const|
87
+ next unless const.display?
78
88
 
79
- @classes.each do |klass|
80
- next unless klass.display?
89
+ index << build_constant_entry(const, klass)
90
+ end
91
+ end
81
92
 
82
- index << build_class_module_entry(klass)
93
+ @methods.each do |method|
94
+ next unless method.display?
83
95
 
84
- klass.constants.each do |const|
85
- next unless const.display?
96
+ index << build_method_entry(method)
97
+ end
86
98
 
87
- index << build_constant_entry(const, klass)
99
+ index
88
100
  end
89
- end
90
101
 
91
- @methods.each do |method|
92
- next unless method.display?
102
+ ##
103
+ # Write the search index as a JavaScript file
104
+ # Format: var search_data = { index: [...] }
105
+ #
106
+ # We still write to a .js instead of a .json because loading a JSON file triggers CORS check in browsers.
107
+ # And if we simply inspect the generated pages using file://, which is often the case due to lack of the server mode,
108
+ # the JSON file will be blocked by the browser.
93
109
 
94
- index << build_method_entry(method)
95
- end
110
+ def write_search_index
111
+ debug_msg "Writing Aliki search index"
96
112
 
97
- index
98
- end
113
+ index = build_search_index
99
114
 
100
- ##
101
- # Write the search index as a JavaScript file
102
- # Format: var search_data = { index: [...] }
103
- #
104
- # We still write to a .js instead of a .json because loading a JSON file triggers CORS check in browsers.
105
- # And if we simply inspect the generated pages using file://, which is often the case due to lack of the server mode,
106
- # the JSON file will be blocked by the browser.
115
+ FileUtils.mkdir_p 'js' unless @dry_run
107
116
 
108
- def write_search_index
109
- debug_msg "Writing Aliki search index"
117
+ search_index_path = 'js/search_data.js'
118
+ return if @dry_run
110
119
 
111
- index = build_search_index
112
-
113
- FileUtils.mkdir_p 'js' unless @dry_run
120
+ data = { index: index }
121
+ File.write search_index_path, "var search_data = #{JSON.generate(data)};"
122
+ end
114
123
 
115
- search_index_path = 'js/search_data.js'
116
- return if @dry_run
124
+ ##
125
+ # Returns the type signature of +method_attr+ as HTML with linked type names.
126
+ # Returns nil if no type signature is present.
117
127
 
118
- data = { index: index }
119
- File.write search_index_path, "var search_data = #{JSON.generate(data)};"
120
- end
128
+ def type_signature_html(method_attr, from_path)
129
+ lines = method_attr.type_signature_lines || @store.rbs_signature_for(method_attr)
130
+ return unless lines
121
131
 
122
- ##
123
- # Returns the type signature of +method_attr+ as HTML with linked type names.
124
- # Returns nil if no type signature is present.
125
-
126
- def type_signature_html(method_attr, from_path)
127
- lines = method_attr.type_signature_lines || @store.rbs_signature_for(method_attr)
128
- return unless lines
132
+ RbsHelper.signature_to_html(
133
+ lines,
134
+ lookup: @store.type_name_lookup,
135
+ from_path: from_path
136
+ )
137
+ end
129
138
 
130
- RDoc::RbsHelper.signature_to_html(
131
- lines,
132
- lookup: @store.type_name_lookup,
133
- from_path: from_path
134
- )
135
- end
139
+ ##
140
+ # Resolves a URL for use in templates. Absolute URLs are returned unchanged.
141
+ # Relative URLs are prefixed with rel_prefix to ensure they resolve correctly from any page.
142
+
143
+ def resolve_url(rel_prefix, url)
144
+ uri = URI.parse(url)
145
+ if uri.absolute?
146
+ url
147
+ else
148
+ "#{rel_prefix}/#{url}"
149
+ end
150
+ rescue URI::InvalidURIError
151
+ "#{rel_prefix}/#{url}"
152
+ end
136
153
 
137
- ##
138
- # Resolves a URL for use in templates. Absolute URLs are returned unchanged.
139
- # Relative URLs are prefixed with rel_prefix to ensure they resolve correctly from any page.
154
+ private
140
155
 
141
- def resolve_url(rel_prefix, url)
142
- uri = URI.parse(url)
143
- if uri.absolute?
144
- url
145
- else
146
- "#{rel_prefix}/#{url}"
147
- end
148
- rescue URI::InvalidURIError
149
- "#{rel_prefix}/#{url}"
150
- end
156
+ def template_encoding
157
+ ::Encoding::UTF_8
158
+ end
151
159
 
152
- private
153
-
154
- def build_class_module_entry(klass)
155
- type = case klass
156
- when RDoc::NormalClass then 'class'
157
- when RDoc::NormalModule then 'module'
158
- else 'class'
159
- end
160
-
161
- entry = {
162
- name: klass.name,
163
- full_name: klass.full_name,
164
- type: type,
165
- path: klass.path
166
- }
167
-
168
- snippet = klass.search_snippet
169
- entry[:snippet] = snippet unless snippet.empty?
170
- entry
171
- end
160
+ def build_class_module_entry(klass)
161
+ type = case klass
162
+ when NormalClass then 'class'
163
+ when NormalModule then 'module'
164
+ else 'class'
165
+ end
166
+
167
+ entry = {
168
+ name: klass.name,
169
+ full_name: klass.full_name,
170
+ type: type,
171
+ path: klass.path
172
+ }
173
+
174
+ snippet = klass.search_snippet
175
+ entry[:snippet] = snippet unless snippet.empty?
176
+ entry
177
+ end
172
178
 
173
- def build_method_entry(method)
174
- type = method.singleton ? 'class_method' : 'instance_method'
179
+ def build_method_entry(method)
180
+ type = method.singleton ? 'class_method' : 'instance_method'
175
181
 
176
- entry = {
177
- name: method.name,
178
- full_name: method.full_name,
179
- type: type,
180
- path: method.path
181
- }
182
+ entry = {
183
+ name: method.name,
184
+ full_name: method.full_name,
185
+ type: type,
186
+ path: method.path
187
+ }
182
188
 
183
- snippet = method.search_snippet
184
- entry[:snippet] = snippet unless snippet.empty?
185
- entry
186
- end
189
+ snippet = method.search_snippet
190
+ entry[:snippet] = snippet unless snippet.empty?
191
+ entry
192
+ end
187
193
 
188
- def build_constant_entry(const, parent)
189
- entry = {
190
- name: const.name,
191
- full_name: "#{parent.full_name}::#{const.name}",
192
- type: 'constant',
193
- path: parent.path
194
- }
195
-
196
- snippet = const.search_snippet
197
- entry[:snippet] = snippet unless snippet.empty?
198
- entry
194
+ def build_constant_entry(const, parent)
195
+ entry = {
196
+ name: const.name,
197
+ full_name: "#{parent.full_name}::#{const.name}",
198
+ type: 'constant',
199
+ path: parent.path
200
+ }
201
+
202
+ snippet = const.search_snippet
203
+ entry[:snippet] = snippet unless snippet.empty?
204
+ entry
205
+ end
206
+ end
199
207
  end
200
208
  end