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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -3
- data/RI.md +75 -75
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +71 -69
- data/lib/rdoc/code_object/any_method.rb +305 -303
- data/lib/rdoc/code_object/attr.rb +150 -148
- data/lib/rdoc/code_object/class_module.rb +798 -792
- data/lib/rdoc/code_object/constant.rb +175 -173
- data/lib/rdoc/code_object/context/section.rb +142 -138
- data/lib/rdoc/code_object/context.rb +926 -958
- data/lib/rdoc/code_object/extend.rb +7 -5
- data/lib/rdoc/code_object/include.rb +7 -5
- data/lib/rdoc/code_object/method_attr.rb +326 -319
- data/lib/rdoc/code_object/mixin.rb +97 -95
- data/lib/rdoc/code_object/normal_class.rb +77 -78
- data/lib/rdoc/code_object/normal_module.rb +61 -59
- data/lib/rdoc/code_object/require.rb +23 -39
- data/lib/rdoc/code_object/single_class.rb +21 -19
- data/lib/rdoc/code_object/top_level.rb +212 -219
- data/lib/rdoc/code_object.rb +305 -303
- data/lib/rdoc/comment.rb +275 -273
- data/lib/rdoc/cross_reference.rb +192 -190
- data/lib/rdoc/encoding.rb +105 -103
- data/lib/rdoc/erb_partial.rb +13 -11
- data/lib/rdoc/erbio.rb +29 -27
- data/lib/rdoc/generator/aliki.rb +161 -153
- data/lib/rdoc/generator/darkfish.rb +645 -635
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +164 -146
- data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
- data/lib/rdoc/generator/pot/po.rb +52 -51
- data/lib/rdoc/generator/pot/po_entry.rb +138 -132
- data/lib/rdoc/generator/pot.rb +85 -81
- data/lib/rdoc/generator/ri.rb +23 -19
- data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
- data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- data/lib/rdoc/generator.rb +48 -46
- data/lib/rdoc/i18n/locale.rb +99 -95
- data/lib/rdoc/i18n/text.rb +109 -105
- data/lib/rdoc/i18n.rb +7 -5
- data/lib/rdoc/markdown/byte_runtime.rb +80 -0
- data/lib/rdoc/markdown.kpeg +15 -11
- data/lib/rdoc/markdown.rb +40 -47
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/formatter.rb +219 -215
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +281 -277
- data/lib/rdoc/markup/list.rb +80 -88
- data/lib/rdoc/markup/list_item.rb +73 -85
- data/lib/rdoc/markup/paragraph.rb +23 -19
- data/lib/rdoc/markup/parser.rb +501 -497
- data/lib/rdoc/markup/pre_process.rb +283 -279
- data/lib/rdoc/markup/raw.rb +2 -2
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/to_ansi.rb +143 -139
- data/lib/rdoc/markup/to_bs.rb +72 -68
- data/lib/rdoc/markup/to_html.rb +594 -565
- data/lib/rdoc/markup/to_html_crossref.rb +234 -230
- data/lib/rdoc/markup/to_html_snippet.rb +232 -227
- data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
- data/lib/rdoc/markup/to_label.rb +63 -59
- data/lib/rdoc/markup/to_markdown.rb +212 -208
- data/lib/rdoc/markup/to_rdoc.rb +336 -332
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +60 -56
- data/lib/rdoc/markup/to_tt_only.rb +84 -80
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +198 -196
- data/lib/rdoc/options.rb +1063 -1061
- data/lib/rdoc/parser/c.rb +1039 -1037
- data/lib/rdoc/parser/changelog.rb +319 -315
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +239 -235
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1245 -1124
- data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +228 -220
- data/lib/rdoc/rbs_helper.rb +1 -1
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +500 -491
- data/lib/rdoc/ri/driver.rb +1140 -1135
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +354 -350
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -12
- data/lib/rdoc/rubygems_hook.rb +183 -181
- data/lib/rdoc/server.rb +349 -347
- data/lib/rdoc/stats/normal.rb +46 -42
- data/lib/rdoc/stats/quiet.rb +39 -35
- data/lib/rdoc/stats/verbose.rb +35 -31
- data/lib/rdoc/stats.rb +365 -363
- data/lib/rdoc/store.rb +888 -902
- data/lib/rdoc/task.rb +260 -256
- data/lib/rdoc/text.rb +135 -133
- data/lib/rdoc/token_stream.rb +101 -93
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- metadata +4 -5
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- data/lib/rdoc/markdown/literals.rb +0 -454
|
@@ -1,221 +1,223 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
module RDoc
|
|
3
|
+
##
|
|
4
|
+
# A constant
|
|
4
5
|
|
|
5
|
-
class
|
|
6
|
+
class Constant < CodeObject
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
MARSHAL_VERSION = 0 # :nodoc:
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
##
|
|
11
|
+
# Sets the module or class this is constant is an alias for.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
attr_writer :is_alias_for
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
##
|
|
16
|
+
# The constant's name
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
attr_accessor :name
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
##
|
|
21
|
+
# The constant's value
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
attr_accessor :value
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
##
|
|
26
|
+
# The constant's visibility
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
attr_accessor :visibility
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
##
|
|
31
|
+
# The constant path on the RHS when the RHS is a bare constant reference
|
|
32
|
+
# (+Foo = Bar+ or +Foo = Bar::Baz+). Captured at parse time so
|
|
33
|
+
# #resolved_alias_target doesn't have to re-derive it from the textual
|
|
34
|
+
# #value. nil for other RHS shapes.
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
attr_accessor :is_alias_for_path
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
##
|
|
39
|
+
# Creates a new constant with +name+, +value+ and +comment+
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
def initialize(name, value, comment)
|
|
42
|
+
super()
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
@name = name
|
|
45
|
+
@value = value
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
@is_alias_for = nil
|
|
48
|
+
@is_alias_for_path = nil
|
|
49
|
+
@visibility = :public
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
self.comment = comment
|
|
52
|
+
end
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
##
|
|
55
|
+
# Constants are ordered by name
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
def <=>(other)
|
|
58
|
+
return unless self.class === other
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
[parent_name, name] <=> [other.parent_name, other.name]
|
|
61
|
+
end
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
##
|
|
64
|
+
# Constants are equal when their #parent and #name is the same
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
def ==(other)
|
|
67
|
+
self.class == other.class and
|
|
68
|
+
@parent == other.parent and
|
|
69
|
+
@name == other.name
|
|
70
|
+
end
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
##
|
|
73
|
+
# A constant is documented if it has a comment, or is an alias
|
|
74
|
+
# for a documented class or module.
|
|
75
|
+
|
|
76
|
+
def documented?
|
|
77
|
+
return true if super
|
|
78
|
+
return false unless @is_alias_for
|
|
79
|
+
case @is_alias_for
|
|
80
|
+
when String
|
|
81
|
+
found = @store.find_class_or_module @is_alias_for
|
|
82
|
+
return false unless found
|
|
83
|
+
@is_alias_for = found
|
|
84
|
+
end
|
|
85
|
+
@is_alias_for.documented?
|
|
83
86
|
end
|
|
84
|
-
@is_alias_for.documented?
|
|
85
|
-
end
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
##
|
|
89
|
+
# Full constant name including namespace
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
def full_name
|
|
92
|
+
@full_name ||= "#{parent_name}::#{@name}"
|
|
93
|
+
end
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
##
|
|
96
|
+
# The module or class this constant is an alias for, when one was recorded
|
|
97
|
+
# explicitly (by RDoc::Context#add_module_alias, RDoc::ClassModule#update_aliases,
|
|
98
|
+
# or ri marshal load). Pure accessor; see #resolved_alias_target for the
|
|
99
|
+
# opportunistic lookup path.
|
|
100
|
+
|
|
101
|
+
def is_alias_for
|
|
102
|
+
case @is_alias_for
|
|
103
|
+
when String
|
|
104
|
+
found = @store.find_class_or_module @is_alias_for
|
|
105
|
+
@is_alias_for = found if found
|
|
106
|
+
@is_alias_for
|
|
107
|
+
else
|
|
108
|
+
@is_alias_for
|
|
109
|
+
end
|
|
108
110
|
end
|
|
109
|
-
end
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
##
|
|
113
|
+
# Returns the class/module this constant *would* alias if #is_alias_for_path
|
|
114
|
+
# was set by the parser and that path resolves to a known class/module, or
|
|
115
|
+
# nil. Used to support `Const = RHS` parsed before `class RHS;end` is defined
|
|
116
|
+
# in another file. Pure lookup; does not mutate state. Honors :nodoc:
|
|
117
|
+
# (returns nil if document_self is false). Note that module nesting
|
|
118
|
+
# information is lost, so constant lookup is inaccurate.
|
|
119
|
+
|
|
120
|
+
def resolved_alias_target
|
|
121
|
+
return nil unless document_self
|
|
122
|
+
return nil unless @is_alias_for_path
|
|
123
|
+
parent.find_module_named(@is_alias_for_path)
|
|
124
|
+
end
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
def inspect # :nodoc:
|
|
127
|
+
"#<%s:0x%x %s::%s>" % [
|
|
128
|
+
self.class, object_id,
|
|
129
|
+
parent_name, @name,
|
|
130
|
+
]
|
|
131
|
+
end
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
133
|
+
##
|
|
134
|
+
# Dumps this Constant for use by ri. See also #marshal_load
|
|
135
|
+
|
|
136
|
+
def marshal_dump
|
|
137
|
+
alias_name = case found = is_alias_for
|
|
138
|
+
when CodeObject then found.full_name
|
|
139
|
+
else found
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
[ MARSHAL_VERSION,
|
|
143
|
+
@name,
|
|
144
|
+
full_name,
|
|
145
|
+
@visibility,
|
|
146
|
+
alias_name,
|
|
147
|
+
parse(@comment),
|
|
148
|
+
@file.relative_name,
|
|
149
|
+
parent.name,
|
|
150
|
+
parent.class,
|
|
151
|
+
section.title,
|
|
152
|
+
]
|
|
153
|
+
end
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
155
|
+
##
|
|
156
|
+
# Loads this Constant from +array+. For a loaded Constant the following
|
|
157
|
+
# methods will return cached values:
|
|
158
|
+
#
|
|
159
|
+
# * #full_name
|
|
160
|
+
# * #parent_name
|
|
161
|
+
|
|
162
|
+
def marshal_load(array)
|
|
163
|
+
initialize array[1], nil, Comment.from_document(array[5])
|
|
164
|
+
|
|
165
|
+
@full_name = array[2]
|
|
166
|
+
@visibility = array[3] || :public
|
|
167
|
+
@is_alias_for = array[4]
|
|
168
|
+
# 5 handled above
|
|
169
|
+
# 6 handled below
|
|
170
|
+
@parent_name = array[7]
|
|
171
|
+
@parent_class = array[8]
|
|
172
|
+
@section_title = array[9]
|
|
173
|
+
|
|
174
|
+
@file = TopLevel.new array[6]
|
|
175
|
+
end
|
|
175
176
|
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
##
|
|
178
|
+
# Path to this constant for use with HTML generator output.
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
def path
|
|
181
|
+
"#{@parent.path}##{@name}"
|
|
182
|
+
end
|
|
182
183
|
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
##
|
|
185
|
+
# Returns an HTML snippet of the comment for search results.
|
|
185
186
|
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
def search_snippet
|
|
188
|
+
return '' if comment.empty?
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
snippet(comment)
|
|
191
|
+
end
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
def pretty_print(q) # :nodoc:
|
|
194
|
+
q.group 2, "[#{self.class.name} #{full_name}", "]" do
|
|
195
|
+
unless comment.empty?
|
|
196
|
+
q.breakable
|
|
197
|
+
q.text "comment:"
|
|
198
|
+
q.breakable
|
|
199
|
+
q.pp @comment
|
|
200
|
+
end
|
|
199
201
|
end
|
|
200
202
|
end
|
|
201
|
-
end
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
##
|
|
205
|
+
# Sets the store for this class or module and its contained code objects.
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
def store=(store)
|
|
208
|
+
super
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
@file = @store.add_file @file.full_name if @file
|
|
211
|
+
end
|
|
211
212
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
def to_s # :nodoc:
|
|
214
|
+
parent_name = parent ? parent.full_name : '(unknown)'
|
|
215
|
+
if is_alias_for
|
|
216
|
+
"constant #{parent_name}::#@name -> #{is_alias_for}"
|
|
217
|
+
else
|
|
218
|
+
"constant #{parent_name}::#@name"
|
|
219
|
+
end
|
|
218
220
|
end
|
|
219
|
-
end
|
|
220
221
|
|
|
222
|
+
end
|
|
221
223
|
end
|