rdoc 7.2.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +4 -7
  3. data/LICENSE.rdoc +4 -0
  4. data/README.md +43 -2
  5. data/RI.md +75 -75
  6. data/doc/markup_reference/markdown.md +104 -3
  7. data/exe/rdoc +2 -2
  8. data/lib/rdoc/code_object/alias.rb +70 -74
  9. data/lib/rdoc/code_object/any_method.rb +305 -298
  10. data/lib/rdoc/code_object/attr.rb +150 -143
  11. data/lib/rdoc/code_object/class_module.rb +801 -765
  12. data/lib/rdoc/code_object/constant.rb +178 -150
  13. data/lib/rdoc/code_object/context/section.rb +133 -160
  14. data/lib/rdoc/code_object/context.rb +925 -952
  15. data/lib/rdoc/code_object/extend.rb +7 -5
  16. data/lib/rdoc/code_object/include.rb +7 -5
  17. data/lib/rdoc/code_object/method_attr.rb +325 -324
  18. data/lib/rdoc/code_object/mixin.rb +97 -95
  19. data/lib/rdoc/code_object/normal_class.rb +77 -78
  20. data/lib/rdoc/code_object/normal_module.rb +61 -59
  21. data/lib/rdoc/code_object/require.rb +23 -39
  22. data/lib/rdoc/code_object/single_class.rb +21 -19
  23. data/lib/rdoc/code_object/top_level.rb +212 -213
  24. data/lib/rdoc/code_object.rb +305 -305
  25. data/lib/rdoc/comment.rb +274 -337
  26. data/lib/rdoc/cross_reference.rb +194 -212
  27. data/lib/rdoc/encoding.rb +105 -103
  28. data/lib/rdoc/erb_partial.rb +13 -11
  29. data/lib/rdoc/erbio.rb +29 -27
  30. data/lib/rdoc/generator/aliki.rb +165 -140
  31. data/lib/rdoc/generator/darkfish.rb +647 -631
  32. data/lib/rdoc/generator/json_index.rb +233 -229
  33. data/lib/rdoc/generator/markup.rb +165 -122
  34. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  35. data/lib/rdoc/generator/pot/po.rb +52 -51
  36. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  37. data/lib/rdoc/generator/pot.rb +85 -81
  38. data/lib/rdoc/generator/ri.rb +23 -19
  39. data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
  40. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
  41. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  42. data/lib/rdoc/generator/template/aliki/_head.rhtml +11 -11
  43. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  44. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
  45. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
  46. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
  47. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
  48. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  49. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
  50. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
  51. data/lib/rdoc/generator/template/aliki/class.rhtml +56 -46
  52. data/lib/rdoc/generator/template/aliki/css/rdoc.css +538 -283
  53. data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
  54. data/lib/rdoc/generator/template/aliki/js/aliki.js +80 -102
  55. data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
  56. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
  57. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
  58. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  59. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
  60. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
  61. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
  62. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
  63. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
  64. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
  65. data/lib/rdoc/generator/template/darkfish/class.rhtml +18 -21
  66. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -1
  67. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  68. data/lib/rdoc/generator.rb +48 -46
  69. data/lib/rdoc/i18n/locale.rb +99 -95
  70. data/lib/rdoc/i18n/text.rb +109 -105
  71. data/lib/rdoc/i18n.rb +7 -5
  72. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  73. data/lib/rdoc/markdown.kpeg +30 -21
  74. data/lib/rdoc/markdown.rb +329 -151
  75. data/lib/rdoc/markup/block_quote.rb +12 -8
  76. data/lib/rdoc/markup/document.rb +127 -123
  77. data/lib/rdoc/markup/formatter.rb +215 -221
  78. data/lib/rdoc/markup/heading.rb +1 -4
  79. data/lib/rdoc/markup/include.rb +33 -29
  80. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  81. data/lib/rdoc/markup/inline_parser.rb +281 -277
  82. data/lib/rdoc/markup/list.rb +80 -88
  83. data/lib/rdoc/markup/list_item.rb +73 -85
  84. data/lib/rdoc/markup/paragraph.rb +23 -19
  85. data/lib/rdoc/markup/parser.rb +501 -497
  86. data/lib/rdoc/markup/pre_process.rb +284 -305
  87. data/lib/rdoc/markup/raw.rb +2 -2
  88. data/lib/rdoc/markup/rule.rb +16 -12
  89. data/lib/rdoc/markup/to_ansi.rb +143 -139
  90. data/lib/rdoc/markup/to_bs.rb +72 -68
  91. data/lib/rdoc/markup/to_html.rb +600 -493
  92. data/lib/rdoc/markup/to_html_crossref.rb +221 -191
  93. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  94. data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
  95. data/lib/rdoc/markup/to_label.rb +63 -59
  96. data/lib/rdoc/markup/to_markdown.rb +212 -208
  97. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  98. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  99. data/lib/rdoc/markup/to_test.rb +60 -56
  100. data/lib/rdoc/markup/to_tt_only.rb +83 -86
  101. data/lib/rdoc/markup/verbatim.rb +62 -58
  102. data/lib/rdoc/markup.rb +198 -196
  103. data/lib/rdoc/options.rb +1063 -1076
  104. data/lib/rdoc/parser/c.rb +1039 -1036
  105. data/lib/rdoc/parser/changelog.rb +319 -315
  106. data/lib/rdoc/parser/markdown.rb +17 -13
  107. data/lib/rdoc/parser/rbs.rb +279 -0
  108. data/lib/rdoc/parser/rd.rb +17 -13
  109. data/lib/rdoc/parser/ruby.rb +1231 -2222
  110. data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
  111. data/lib/rdoc/parser/simple.rb +31 -27
  112. data/lib/rdoc/parser/text.rb +12 -8
  113. data/lib/rdoc/parser.rb +230 -221
  114. data/lib/rdoc/rbs_helper.rb +186 -0
  115. data/lib/rdoc/rd/inline.rb +57 -53
  116. data/lib/rdoc/rd.rb +90 -88
  117. data/lib/rdoc/rdoc.rb +547 -366
  118. data/lib/rdoc/ri/driver.rb +1141 -1130
  119. data/lib/rdoc/ri/formatter.rb +7 -3
  120. data/lib/rdoc/ri/paths.rb +140 -136
  121. data/lib/rdoc/ri/servlet.rb +456 -0
  122. data/lib/rdoc/ri/store.rb +4 -2
  123. data/lib/rdoc/ri/task.rb +55 -51
  124. data/lib/rdoc/ri.rb +14 -11
  125. data/lib/rdoc/rubygems_hook.rb +194 -192
  126. data/lib/rdoc/server.rb +462 -0
  127. data/lib/rdoc/stats/normal.rb +46 -42
  128. data/lib/rdoc/stats/quiet.rb +39 -35
  129. data/lib/rdoc/stats/verbose.rb +35 -31
  130. data/lib/rdoc/stats.rb +363 -338
  131. data/lib/rdoc/store.rb +919 -725
  132. data/lib/rdoc/task.rb +260 -255
  133. data/lib/rdoc/text.rb +130 -245
  134. data/lib/rdoc/token_stream.rb +101 -115
  135. data/lib/rdoc/tom_doc.rb +203 -201
  136. data/lib/rdoc/version.rb +1 -1
  137. data/lib/rdoc.rb +35 -7
  138. data/lib/rubygems_plugin.rb +2 -11
  139. data/rdoc-logo.svg +43 -0
  140. data/rdoc.gemspec +6 -4
  141. metadata +36 -20
  142. data/lib/rdoc/code_object/anon_class.rb +0 -10
  143. data/lib/rdoc/code_object/ghost_method.rb +0 -6
  144. data/lib/rdoc/code_object/meta_method.rb +0 -6
  145. data/lib/rdoc/markdown/literals.kpeg +0 -21
  146. data/lib/rdoc/markdown/literals.rb +0 -454
  147. data/lib/rdoc/parser/prism_ruby.rb +0 -1112
  148. data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
  149. data/lib/rdoc/parser/ruby_tools.rb +0 -163
  150. data/lib/rdoc/servlet.rb +0 -452
@@ -2,212 +2,185 @@
2
2
  require 'cgi/escape'
3
3
  require 'cgi/util' unless defined?(CGI::EscapeExt)
4
4
 
5
- ##
6
- # A section of documentation like:
7
- #
8
- # # :section: The title
9
- # # The body
10
- #
11
- # Sections can be referenced multiple times and will be collapsed into a
12
- # single section.
5
+ module RDoc
6
+ class Context
7
+ ##
8
+ # A section of documentation like:
9
+ #
10
+ # # :section: The title
11
+ # # The body
12
+ #
13
+ # Sections can be referenced multiple times and will be collapsed into a
14
+ # single section.
13
15
 
14
- class RDoc::Context::Section
16
+ class Section
15
17
 
16
- include RDoc::Text
18
+ include Text
17
19
 
18
- MARSHAL_VERSION = 0 # :nodoc:
20
+ MARSHAL_VERSION = 0 # :nodoc:
19
21
 
20
- ##
21
- # Section comments
22
+ ##
23
+ # Section comments
22
24
 
23
- attr_reader :comments
25
+ attr_reader :comments
24
26
 
25
- ##
26
- # Context this Section lives in
27
+ ##
28
+ # Context this Section lives in
27
29
 
28
- attr_reader :parent
30
+ attr_reader :parent
29
31
 
30
- ##
31
- # Section title
32
+ ##
33
+ # Section title
32
34
 
33
- attr_reader :title
35
+ attr_reader :title
34
36
 
35
- ##
36
- # The RDoc::Store for this object.
37
+ ##
38
+ # The RDoc::Store for this object.
37
39
 
38
- attr_reader :store
40
+ attr_reader :store
39
41
 
40
- ##
41
- # Creates a new section with +title+ and +comment+
42
+ ##
43
+ # Creates a new section with +title+ and +comment+
42
44
 
43
- def initialize(parent, title, comment, store = nil)
44
- @parent = parent
45
- @title = title ? title.strip : title
46
- @store = store
45
+ def initialize(parent, title, comment, store = nil)
46
+ @parent = parent
47
+ @title = title ? title.strip : title
48
+ @store = store
47
49
 
48
- @comments = []
50
+ @comments = []
49
51
 
50
- add_comment comment
51
- end
52
+ add_comment comment
53
+ end
52
54
 
53
- ##
54
- # Sections are equal when they have the same #title
55
+ ##
56
+ # Sections are equal when they have the same #title
55
57
 
56
- def ==(other)
57
- self.class === other and @title == other.title
58
- end
58
+ def ==(other)
59
+ self.class === other and @title == other.title
60
+ end
59
61
 
60
- alias eql? ==
62
+ alias eql? ==
61
63
 
62
- ##
63
- # Adds +comment+ to this section
64
+ ##
65
+ # Adds +comment+ to this section
64
66
 
65
- def add_comment(comment)
66
- comments = Array(comment)
67
- comments.each do |c|
68
- extracted_comment = extract_comment(c)
69
- @comments << extracted_comment unless extracted_comment.empty?
70
- end
71
- end
67
+ def add_comment(comment)
68
+ Array(comment).each do |c|
69
+ next if c.nil?
70
+ raise TypeError, "unknown comment #{c.inspect}" unless Comment === c
71
+ @comments << c unless c.empty?
72
+ end
73
+ end
72
74
 
73
- ##
74
- # Anchor reference for linking to this section using GitHub-style format.
75
- #
76
- # Examples:
77
- # "Section" -> "section"
78
- # "One Two" -> "one-two"
79
- # "[untitled]" -> "untitled"
75
+ ##
76
+ # Anchor reference for linking to this section using GitHub-style format.
77
+ #
78
+ # Examples:
79
+ # "Section" -> "section"
80
+ # "One Two" -> "one-two"
81
+ # "[untitled]" -> "untitled"
80
82
 
81
- def aref
82
- title = @title || '[untitled]'
83
+ def aref
84
+ title = @title || '[untitled]'
83
85
 
84
- RDoc::Text.to_anchor(title)
85
- end
86
+ Text.to_anchor(title)
87
+ end
86
88
 
87
- ##
88
- # Legacy anchor reference for backward compatibility.
89
- #
90
- # Examples:
91
- # "Section" -> "section"
92
- # "One Two" -> "one+two"
93
- # "[untitled]" -> "5Buntitled-5D"
89
+ ##
90
+ # Legacy anchor reference for backward compatibility.
91
+ #
92
+ # Examples:
93
+ # "Section" -> "section"
94
+ # "One Two" -> "one+two"
95
+ # "[untitled]" -> "5Buntitled-5D"
94
96
 
95
- def legacy_aref
96
- title = @title || '[untitled]'
97
+ def legacy_aref
98
+ title = @title || '[untitled]'
97
99
 
98
- CGI.escape(title).gsub('%', '-').sub(/^-/, '')
99
- end
100
+ CGI.escape(title).gsub('%', '-').sub(/^-/, '')
101
+ end
100
102
 
101
- ##
102
- # Extracts the comment for this section from the original comment block.
103
- # If the first line contains :section:, strip it and use the rest.
104
- # Otherwise remove lines up to the line containing :section:, and look
105
- # for those lines again at the end and remove them. This lets us write
106
- #
107
- # # :section: The title
108
- # # The body
109
-
110
- def extract_comment(comment)
111
- case comment
112
- when nil
113
- RDoc::Comment.new ''
114
- when RDoc::Comment then
115
- if comment.text =~ /^#[ \t]*:section:.*\n/ then
116
- start = $`
117
- rest = $'
118
-
119
- comment.text = if start.empty? then
120
- rest
121
- else
122
- rest.sub(/#{start.chomp}\Z/, '')
123
- end
124
- end
125
-
126
- comment
127
- else
128
- raise TypeError, "unknown comment #{comment.inspect}"
129
- end
130
- end
103
+ def inspect # :nodoc:
104
+ "#<%s:0x%x %p>" % [self.class, object_id, title]
105
+ end
131
106
 
132
- def inspect # :nodoc:
133
- "#<%s:0x%x %p>" % [self.class, object_id, title]
134
- end
107
+ def hash # :nodoc:
108
+ @title.hash
109
+ end
135
110
 
136
- def hash # :nodoc:
137
- @title.hash
138
- end
111
+ ##
112
+ # The files comments in this section come from
139
113
 
140
- ##
141
- # The files comments in this section come from
114
+ def in_files
115
+ @comments.map(&:file)
116
+ end
142
117
 
143
- def in_files
144
- @comments.map(&:file)
145
- end
118
+ ##
119
+ # Serializes this Section. The title and parsed comment are saved, but not
120
+ # the section parent which must be restored manually.
146
121
 
147
- ##
148
- # Serializes this Section. The title and parsed comment are saved, but not
149
- # the section parent which must be restored manually.
122
+ def marshal_dump
123
+ [
124
+ MARSHAL_VERSION,
125
+ @title,
126
+ to_document,
127
+ ]
128
+ end
150
129
 
151
- def marshal_dump
152
- [
153
- MARSHAL_VERSION,
154
- @title,
155
- to_document,
156
- ]
157
- end
130
+ ##
131
+ # De-serializes this Section. The section parent must be restored manually.
158
132
 
159
- ##
160
- # De-serializes this Section. The section parent must be restored manually.
133
+ def marshal_load(array)
134
+ @parent = nil
161
135
 
162
- def marshal_load(array)
163
- @parent = nil
136
+ @title = array[1]
137
+ @comments = array[2].parts.map { |doc| Comment.from_document(doc) }
138
+ end
164
139
 
165
- @title = array[1]
166
- @comments = array[2].parts.map { |doc| RDoc::Comment.from_document(doc) }
167
- end
140
+ ##
141
+ # Parses +comment_location+ into an RDoc::Markup::Document composed of
142
+ # multiple RDoc::Markup::Documents with their file set.
168
143
 
169
- ##
170
- # Parses +comment_location+ into an RDoc::Markup::Document composed of
171
- # multiple RDoc::Markup::Documents with their file set.
144
+ def to_document
145
+ Markup::Document.new(*@comments.map(&:parse))
146
+ end
172
147
 
173
- def to_document
174
- RDoc::Markup::Document.new(*@comments.map(&:parse))
175
- end
148
+ ##
149
+ # The section's title, or 'Top Section' if the title is nil.
150
+ #
151
+ # This is used by the table of contents template so the name is silly.
176
152
 
177
- ##
178
- # The section's title, or 'Top Section' if the title is nil.
179
- #
180
- # This is used by the table of contents template so the name is silly.
153
+ def plain_html
154
+ @title || 'Top Section'
155
+ end
181
156
 
182
- def plain_html
183
- @title || 'Top Section'
184
- end
157
+ ##
158
+ # Section comment
185
159
 
186
- ##
187
- # Section comment
160
+ def comment
161
+ return nil if @comments.empty?
162
+ Comment.from_document(to_document)
163
+ end
188
164
 
189
- def comment
190
- return nil if @comments.empty?
191
- RDoc::Comment.from_document(to_document)
192
- end
165
+ def description
166
+ return '' if @comments.empty?
167
+ markup comment
168
+ end
193
169
 
194
- def description
195
- return '' if @comments.empty?
196
- markup comment
197
- end
170
+ def language
171
+ @comments.first&.language
172
+ end
198
173
 
199
- def language
200
- @comments.first&.language
201
- end
174
+ ##
175
+ # Removes a comment from this section if it is from the same file as
176
+ # +comment+
202
177
 
203
- ##
204
- # Removes a comment from this section if it is from the same file as
205
- # +comment+
178
+ def remove_comment(target_comment)
179
+ @comments.delete_if do |stored_comment|
180
+ stored_comment.file == target_comment.file
181
+ end
182
+ end
206
183
 
207
- def remove_comment(target_comment)
208
- @comments.delete_if do |stored_comment|
209
- stored_comment.file == target_comment.file
210
184
  end
211
185
  end
212
-
213
186
  end