rdoc 5.1.0 → 6.13.1
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 +5 -5
- data/CONTRIBUTING.rdoc +5 -6
- data/ExampleMarkdown.md +2 -0
- data/ExampleRDoc.rdoc +2 -0
- data/History.rdoc +68 -66
- data/LEGAL.rdoc +1 -1
- data/LICENSE.rdoc +2 -0
- data/README.rdoc +18 -6
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -12
- data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +1 -2
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +83 -26
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +5 -9
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +112 -24
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +4 -5
- data/lib/rdoc/{context → code_object/context}/section.rb +13 -83
- data/lib/rdoc/{context.rb → code_object/context.rb} +69 -70
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +1 -2
- data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +1 -2
- data/lib/rdoc/{include.rb → code_object/include.rb} +1 -2
- data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +1 -2
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +22 -31
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +1 -2
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +4 -5
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +2 -3
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +6 -2
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +22 -32
- data/lib/rdoc/code_object.rb +8 -41
- data/lib/rdoc/code_objects.rb +2 -3
- data/lib/rdoc/comment.rb +48 -41
- data/lib/rdoc/cross_reference.rb +77 -33
- data/lib/rdoc/encoding.rb +50 -38
- data/lib/rdoc/erb_partial.rb +2 -3
- data/lib/rdoc/erbio.rb +4 -5
- data/lib/rdoc/generator/darkfish.rb +178 -125
- data/lib/rdoc/generator/json_index.rb +9 -22
- data/lib/rdoc/generator/markup.rb +6 -17
- data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
- data/lib/rdoc/generator/pot/po.rb +3 -3
- data/lib/rdoc/generator/pot/po_entry.rb +12 -12
- data/lib/rdoc/generator/pot.rb +4 -8
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -12
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +19 -10
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +26 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +27 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +125 -78
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +430 -339
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +13 -13
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -92
- data/lib/rdoc/generator/template/darkfish/js/search.js +35 -34
- data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +20 -18
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +32 -20
- data/lib/rdoc/generator/template/json_index/js/navigation.js +12 -49
- data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
- data/lib/rdoc/generator.rb +6 -6
- data/lib/rdoc/i18n/locale.rb +1 -1
- data/lib/rdoc/i18n/text.rb +5 -5
- data/lib/rdoc/i18n.rb +4 -4
- data/lib/rdoc/known_classes.rb +6 -5
- data/lib/rdoc/markdown/entities.rb +1 -2
- data/lib/rdoc/markdown/literals.kpeg +1 -2
- data/lib/rdoc/markdown/literals.rb +99 -50
- data/lib/rdoc/markdown.kpeg +115 -58
- data/lib/rdoc/markdown.rb +1584 -902
- data/lib/rdoc/markup/attr_changer.rb +1 -2
- data/lib/rdoc/markup/attr_span.rb +9 -4
- data/lib/rdoc/markup/attribute_manager.rb +118 -57
- data/lib/rdoc/markup/attributes.rb +7 -8
- data/lib/rdoc/markup/blank_line.rb +1 -2
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +1 -2
- data/lib/rdoc/markup/formatter.rb +44 -37
- data/lib/rdoc/markup/hard_break.rb +1 -2
- data/lib/rdoc/markup/heading.rb +11 -6
- data/lib/rdoc/markup/include.rb +1 -2
- data/lib/rdoc/markup/indented_paragraph.rb +1 -2
- data/lib/rdoc/markup/list.rb +1 -2
- data/lib/rdoc/markup/list_item.rb +1 -2
- data/lib/rdoc/markup/paragraph.rb +1 -2
- data/lib/rdoc/markup/parser.rb +90 -48
- data/lib/rdoc/markup/pre_process.rb +38 -11
- data/lib/rdoc/markup/raw.rb +1 -2
- data/lib/rdoc/markup/regexp_handling.rb +40 -0
- data/lib/rdoc/markup/rule.rb +1 -2
- data/lib/rdoc/markup/table.rb +56 -0
- data/lib/rdoc/markup/to_ansi.rb +1 -2
- data/lib/rdoc/markup/to_bs.rb +30 -5
- data/lib/rdoc/markup/to_html.rb +95 -40
- data/lib/rdoc/markup/to_html_crossref.rb +108 -43
- data/lib/rdoc/markup/to_html_snippet.rb +13 -11
- data/lib/rdoc/markup/to_joined_paragraph.rb +6 -32
- data/lib/rdoc/markup/to_label.rb +11 -12
- data/lib/rdoc/markup/to_markdown.rb +13 -14
- data/lib/rdoc/markup/to_rdoc.rb +49 -31
- data/lib/rdoc/markup/to_table_of_contents.rb +2 -2
- data/lib/rdoc/markup/to_test.rb +1 -2
- data/lib/rdoc/markup/to_tt_only.rb +3 -4
- data/lib/rdoc/markup/verbatim.rb +1 -2
- data/lib/rdoc/markup.rb +64 -694
- data/lib/rdoc/options.rb +226 -44
- data/lib/rdoc/parser/c.rb +231 -246
- data/lib/rdoc/parser/changelog.rb +169 -23
- data/lib/rdoc/parser/markdown.rb +1 -3
- data/lib/rdoc/parser/prism_ruby.rb +1092 -0
- data/lib/rdoc/parser/rd.rb +1 -2
- data/lib/rdoc/parser/ripper_state_lex.rb +302 -0
- data/lib/rdoc/parser/ruby.rb +695 -478
- data/lib/rdoc/parser/ruby_tools.rb +33 -36
- data/lib/rdoc/parser/simple.rb +4 -4
- data/lib/rdoc/parser/text.rb +1 -2
- data/lib/rdoc/parser.rb +37 -42
- data/lib/rdoc/rd/block_parser.rb +708 -57
- data/lib/rdoc/rd/block_parser.ry +15 -11
- data/lib/rdoc/rd/inline.rb +5 -6
- data/lib/rdoc/rd/inline_parser.rb +787 -140
- data/lib/rdoc/rd/inline_parser.ry +1 -1
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +72 -87
- data/lib/rdoc/ri/driver.rb +236 -152
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +4 -18
- data/lib/rdoc/ri/store.rb +1 -2
- data/lib/rdoc/ri/task.rb +2 -2
- data/lib/rdoc/ri.rb +5 -6
- data/lib/rdoc/rubygems_hook.rb +98 -20
- data/lib/rdoc/servlet.rb +30 -20
- data/lib/rdoc/stats/normal.rb +24 -18
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +1 -3
- data/lib/rdoc/stats.rb +6 -7
- data/lib/rdoc/store.rb +84 -55
- data/lib/rdoc/task.rb +35 -10
- data/lib/rdoc/text.rb +40 -27
- data/lib/rdoc/token_stream.rb +56 -34
- data/lib/rdoc/tom_doc.rb +18 -19
- data/lib/rdoc/version.rb +10 -0
- data/lib/rdoc.rb +80 -56
- data/lib/rubygems_plugin.rb +23 -0
- data/man/ri.1 +247 -0
- metadata +45 -99
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.travis.yml +0 -24
- data/Gemfile +0 -3
- data/RI.rdoc +0 -57
- data/Rakefile +0 -133
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/gauntlet_rdoc.rb +0 -82
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
- data/lib/rdoc/generator/template/json_index/.document +0 -1
- data/lib/rdoc/markup/formatter_test_case.rb +0 -764
- data/lib/rdoc/markup/inline.rb +0 -2
- data/lib/rdoc/markup/special.rb +0 -41
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
- data/lib/rdoc/ruby_lex.rb +0 -1367
- data/lib/rdoc/ruby_token.rb +0 -461
- data/lib/rdoc/test_case.rb +0 -204
- data/rdoc.gemspec +0 -57
data/TODO.rdoc
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
= TODO
|
1
2
|
This file contains some things that might happen in RDoc, or might not.
|
2
3
|
Forward Looking Statements applies.
|
3
4
|
|
4
|
-
|
5
|
+
== RDoc::VERSION.succ
|
5
6
|
|
6
|
-
Blockers:
|
7
|
+
=== Blockers:
|
7
8
|
|
8
9
|
* Update LICENSE to match ruby's switch
|
9
10
|
* The alias keyword should not be bidirectional
|
@@ -13,7 +14,7 @@ Blockers:
|
|
13
14
|
* Fix consumption of , after link like: RDoc[rdoc-ref:RDoc], <- comma here
|
14
15
|
* Remove support for links like Matrix[*rows]
|
15
16
|
|
16
|
-
Nice to have:
|
17
|
+
=== Nice to have:
|
17
18
|
|
18
19
|
* Parse only changed files (like in ruby)
|
19
20
|
* Page of Glory (or Shame) in HTML output showing documentation coverage
|
@@ -26,9 +27,9 @@ Nice to have:
|
|
26
27
|
* Global variable support
|
27
28
|
* Provide the code_object to directive handlers
|
28
29
|
|
29
|
-
|
30
|
+
== More Future
|
30
31
|
|
31
|
-
API changes to RDoc
|
32
|
+
=== API changes to RDoc
|
32
33
|
|
33
34
|
* RDoc::TopLevel#add_method should automatically create the appropriate method
|
34
35
|
class rather than requiring one be passed in.
|
@@ -36,7 +37,7 @@ API changes to RDoc
|
|
36
37
|
* Add versions to RDoc::Markup syntax tree marshal format
|
37
38
|
* Comments can no longer be Strings
|
38
39
|
|
39
|
-
|
40
|
+
== Crazy Ideas
|
40
41
|
|
41
42
|
* Auto-normalize heading levels to look OK. It's weird to see an <h1> in
|
42
43
|
the middle of a method section.
|
@@ -46,7 +47,7 @@ API changes to RDoc
|
|
46
47
|
* Rename Context to Container
|
47
48
|
* Rename NormalClass to Class
|
48
49
|
|
49
|
-
|
50
|
+
== Accessibility
|
50
51
|
|
51
52
|
Page title in right hand side
|
52
53
|
|
data/exe/rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Represent an alias, which is an old_name/new_name pair associated with a
|
4
4
|
# particular context
|
@@ -23,7 +23,7 @@ class RDoc::Alias < RDoc::CodeObject
|
|
23
23
|
##
|
24
24
|
# Is this an alias declared in a singleton context?
|
25
25
|
|
26
|
-
|
26
|
+
attr_reader :singleton
|
27
27
|
|
28
28
|
##
|
29
29
|
# Source file token stream
|
@@ -34,7 +34,7 @@ class RDoc::Alias < RDoc::CodeObject
|
|
34
34
|
# Creates a new Alias with a token stream of +text+ that aliases +old_name+
|
35
35
|
# to +new_name+, has +comment+ and is a +singleton+ context.
|
36
36
|
|
37
|
-
def initialize(text, old_name, new_name, comment, singleton
|
37
|
+
def initialize(text, old_name, new_name, comment, singleton: false)
|
38
38
|
super()
|
39
39
|
|
40
40
|
@text = text
|
@@ -59,18 +59,11 @@ class RDoc::Alias < RDoc::CodeObject
|
|
59
59
|
"#alias-#{type}-#{html_name}"
|
60
60
|
end
|
61
61
|
|
62
|
-
##
|
63
|
-
# Full old name including namespace
|
64
|
-
|
65
|
-
def full_old_name
|
66
|
-
@full_name || "#{parent.name}#{pretty_old_name}"
|
67
|
-
end
|
68
|
-
|
69
62
|
##
|
70
63
|
# HTML id-friendly version of +#new_name+.
|
71
64
|
|
72
65
|
def html_name
|
73
|
-
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
|
66
|
+
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
|
74
67
|
end
|
75
68
|
|
76
69
|
def inspect # :nodoc:
|
@@ -109,4 +102,3 @@ class RDoc::Alias < RDoc::CodeObject
|
|
109
102
|
end
|
110
103
|
|
111
104
|
end
|
112
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# AnyMethod is the base class for objects representing methods
|
4
4
|
|
@@ -26,15 +26,8 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
26
26
|
|
27
27
|
attr_accessor :c_function
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
attr_reader :call_seq
|
33
|
-
|
34
|
-
##
|
35
|
-
# Parameters for this method
|
36
|
-
|
37
|
-
attr_accessor :params
|
29
|
+
# The section title of the method (if defined in a C file via +:category:+)
|
30
|
+
attr_accessor :section_title
|
38
31
|
|
39
32
|
##
|
40
33
|
# If true this method uses +super+ to call a superclass version
|
@@ -46,8 +39,8 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
46
39
|
##
|
47
40
|
# Creates a new AnyMethod with a token stream +text+ and +name+
|
48
41
|
|
49
|
-
def initialize
|
50
|
-
super
|
42
|
+
def initialize(text, name, singleton: false)
|
43
|
+
super(text, name, singleton: singleton)
|
51
44
|
|
52
45
|
@c_function = nil
|
53
46
|
@dont_rename_initialize = false
|
@@ -60,10 +53,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
60
53
|
# Adds +an_alias+ as an alias for this method in +context+.
|
61
54
|
|
62
55
|
def add_alias an_alias, context = nil
|
63
|
-
method = self.class.new an_alias.text, an_alias.new_name
|
56
|
+
method = self.class.new an_alias.text, an_alias.new_name, singleton: singleton
|
64
57
|
|
65
58
|
method.record_location an_alias.file
|
66
|
-
method.singleton = self.singleton
|
67
59
|
method.params = self.params
|
68
60
|
method.visibility = self.visibility
|
69
61
|
method.comment = an_alias.comment
|
@@ -93,6 +85,19 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
93
85
|
end
|
94
86
|
end
|
95
87
|
|
88
|
+
##
|
89
|
+
# Different ways to call this method
|
90
|
+
|
91
|
+
def call_seq
|
92
|
+
unless call_seq = _call_seq
|
93
|
+
call_seq = is_alias_for._call_seq if is_alias_for
|
94
|
+
end
|
95
|
+
|
96
|
+
return unless call_seq
|
97
|
+
|
98
|
+
deduplicate_call_seq(call_seq)
|
99
|
+
end
|
100
|
+
|
96
101
|
##
|
97
102
|
# Sets the different ways you can call this method. If an empty +call_seq+
|
98
103
|
# is given nil is assumed.
|
@@ -100,11 +105,18 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
100
105
|
# See also #param_seq
|
101
106
|
|
102
107
|
def call_seq= call_seq
|
103
|
-
return if call_seq.empty?
|
108
|
+
return if call_seq.nil? || call_seq.empty?
|
104
109
|
|
105
110
|
@call_seq = call_seq
|
106
111
|
end
|
107
112
|
|
113
|
+
##
|
114
|
+
# Whether the method has a call-seq.
|
115
|
+
|
116
|
+
def has_call_seq?
|
117
|
+
!!(@call_seq || is_alias_for&._call_seq)
|
118
|
+
end
|
119
|
+
|
108
120
|
##
|
109
121
|
# Loads is_alias_for from the internal name. Returns nil if the alias
|
110
122
|
# cannot be found.
|
@@ -181,7 +193,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
181
193
|
@full_name = array[2]
|
182
194
|
@singleton = array[3]
|
183
195
|
@visibility = array[4]
|
184
|
-
@comment = array[5]
|
196
|
+
@comment = RDoc::Comment.from_document array[5]
|
185
197
|
@call_seq = array[6]
|
186
198
|
@block_params = array[7]
|
187
199
|
# 8 handled below
|
@@ -193,8 +205,8 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
193
205
|
@section_title = array[14]
|
194
206
|
@is_alias_for = array[15]
|
195
207
|
|
196
|
-
array[8].each do |new_name,
|
197
|
-
add_alias RDoc::Alias.new(nil, @name, new_name,
|
208
|
+
array[8].each do |new_name, document|
|
209
|
+
add_alias RDoc::Alias.new(nil, @name, new_name, RDoc::Comment.from_document(document), singleton: @singleton)
|
198
210
|
end
|
199
211
|
|
200
212
|
@parent_name ||= if @full_name =~ /#/ then
|
@@ -244,9 +256,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
244
256
|
if @block_params then
|
245
257
|
# If this method has explicit block parameters, remove any explicit
|
246
258
|
# &block
|
247
|
-
params.sub
|
259
|
+
params = params.sub(/,?\s*&\w+/, '')
|
248
260
|
else
|
249
|
-
params.sub
|
261
|
+
params = params.sub(/\&(\w+)/, '\1')
|
250
262
|
end
|
251
263
|
|
252
264
|
params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
|
@@ -265,7 +277,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
265
277
|
params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
|
266
278
|
elsif @params then
|
267
279
|
params = @params.gsub(/\s*\#.*/, '')
|
268
|
-
params = params.
|
280
|
+
params = params.tr_s("\n ", " ")
|
269
281
|
params = "(#{params})" unless params[0] == ?(
|
270
282
|
else
|
271
283
|
params = ''
|
@@ -274,12 +286,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
274
286
|
if @block_params then
|
275
287
|
# If this method has explicit block parameters, remove any explicit
|
276
288
|
# &block
|
277
|
-
params.sub
|
289
|
+
params = params.sub(/,?\s*&\w+/, '')
|
278
290
|
|
279
|
-
block = @block_params.
|
280
|
-
block = block.tr("\n", " ").squeeze(" ")
|
291
|
+
block = @block_params.tr_s("\n ", " ")
|
281
292
|
if block[0] == ?(
|
282
|
-
block.sub
|
293
|
+
block = block.sub(/^\(/, '').sub(/\)/, '')
|
283
294
|
end
|
284
295
|
params << " { |#{block}| ... }"
|
285
296
|
end
|
@@ -287,6 +298,14 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
287
298
|
params
|
288
299
|
end
|
289
300
|
|
301
|
+
##
|
302
|
+
# Whether to skip the method description, true for methods that have
|
303
|
+
# aliases with a call-seq that doesn't include the method name.
|
304
|
+
|
305
|
+
def skip_description?
|
306
|
+
has_call_seq? && call_seq.nil? && !!(is_alias_for || !aliases.empty?)
|
307
|
+
end
|
308
|
+
|
290
309
|
##
|
291
310
|
# Sets the store for this method and its referenced code objects.
|
292
311
|
|
@@ -313,5 +332,43 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
313
332
|
@superclass_method
|
314
333
|
end
|
315
334
|
|
316
|
-
|
335
|
+
protected
|
336
|
+
|
337
|
+
##
|
338
|
+
# call_seq without deduplication and alias lookup.
|
339
|
+
|
340
|
+
def _call_seq
|
341
|
+
@call_seq if defined?(@call_seq) && @call_seq
|
342
|
+
end
|
343
|
+
|
344
|
+
private
|
345
|
+
|
346
|
+
##
|
347
|
+
# call_seq with alias examples information removed, if this
|
348
|
+
# method is an alias method.
|
349
|
+
|
350
|
+
def deduplicate_call_seq(call_seq)
|
351
|
+
return call_seq unless is_alias_for || !aliases.empty?
|
352
|
+
|
353
|
+
method_name = self.name
|
354
|
+
method_name = method_name[0, 1] if method_name =~ /\A\[/
|
355
|
+
|
356
|
+
entries = call_seq.split "\n"
|
357
|
+
|
358
|
+
ignore = aliases.map(&:name)
|
359
|
+
if is_alias_for
|
360
|
+
ignore << is_alias_for.name
|
361
|
+
ignore.concat is_alias_for.aliases.map(&:name)
|
362
|
+
end
|
363
|
+
ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
|
364
|
+
ignore.delete(method_name)
|
365
|
+
ignore = Regexp.union(ignore)
|
366
|
+
|
367
|
+
matching = entries.reject do |entry|
|
368
|
+
entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
|
369
|
+
entry =~ /\s#{ignore}\s/
|
370
|
+
end
|
317
371
|
|
372
|
+
matching.empty? ? nil : matching.join("\n")
|
373
|
+
end
|
374
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# An attribute created by \#attr, \#attr_reader, \#attr_writer or
|
4
4
|
# \#attr_accessor
|
@@ -22,11 +22,10 @@ class RDoc::Attr < RDoc::MethodAttr
|
|
22
22
|
# Creates a new Attr with body +text+, +name+, read/write status +rw+ and
|
23
23
|
# +comment+. +singleton+ marks this as a class attribute.
|
24
24
|
|
25
|
-
def initialize(text, name, rw, comment, singleton
|
26
|
-
super
|
25
|
+
def initialize(text, name, rw, comment, singleton: false)
|
26
|
+
super(text, name, singleton: singleton)
|
27
27
|
|
28
28
|
@rw = rw
|
29
|
-
@singleton = singleton
|
30
29
|
self.comment = comment
|
31
30
|
end
|
32
31
|
|
@@ -44,9 +43,7 @@ class RDoc::Attr < RDoc::MethodAttr
|
|
44
43
|
# Add +an_alias+ as an attribute in +context+.
|
45
44
|
|
46
45
|
def add_alias(an_alias, context)
|
47
|
-
new_attr = self.class.new(
|
48
|
-
self.comment, self.singleton)
|
49
|
-
|
46
|
+
new_attr = self.class.new(text, an_alias.new_name, rw, comment, singleton: singleton)
|
50
47
|
new_attr.record_location an_alias.file
|
51
48
|
new_attr.visibility = self.visibility
|
52
49
|
new_attr.is_alias_for = self
|
@@ -136,7 +133,7 @@ class RDoc::Attr < RDoc::MethodAttr
|
|
136
133
|
@full_name = array[2]
|
137
134
|
@rw = array[3]
|
138
135
|
@visibility = array[4]
|
139
|
-
@comment = array[5]
|
136
|
+
@comment = RDoc::Comment.from_document array[5]
|
140
137
|
@singleton = array[6] || false # MARSHAL_VERSION == 0
|
141
138
|
# 7 handled below
|
142
139
|
@parent_name = array[8]
|
@@ -173,4 +170,3 @@ class RDoc::Attr < RDoc::MethodAttr
|
|
173
170
|
end
|
174
171
|
|
175
172
|
end
|
176
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# ClassModule is the base class for objects representing either a class or a
|
4
4
|
# module.
|
@@ -34,8 +34,6 @@ class RDoc::ClassModule < RDoc::Context
|
|
34
34
|
|
35
35
|
attr_accessor :comment_location
|
36
36
|
|
37
|
-
attr_accessor :diagram # :nodoc:
|
38
|
-
|
39
37
|
##
|
40
38
|
# Class or module this constant is an alias for
|
41
39
|
|
@@ -56,7 +54,6 @@ class RDoc::ClassModule < RDoc::Context
|
|
56
54
|
|
57
55
|
klass.parent = mod.parent
|
58
56
|
klass.section = mod.section
|
59
|
-
klass.viewer = mod.viewer
|
60
57
|
|
61
58
|
klass.attributes.concat mod.attributes
|
62
59
|
klass.method_list.concat mod.method_list
|
@@ -110,7 +107,6 @@ class RDoc::ClassModule < RDoc::Context
|
|
110
107
|
|
111
108
|
def initialize(name, superclass = nil)
|
112
109
|
@constant_aliases = []
|
113
|
-
@diagram = nil
|
114
110
|
@is_alias_for = nil
|
115
111
|
@name = name
|
116
112
|
@superclass = superclass
|
@@ -136,7 +132,9 @@ class RDoc::ClassModule < RDoc::Context
|
|
136
132
|
normalize_comment comment
|
137
133
|
end
|
138
134
|
|
139
|
-
|
135
|
+
if location.parser == RDoc::Parser::C
|
136
|
+
@comment_location.delete_if { |(_, l)| l == location }
|
137
|
+
end
|
140
138
|
|
141
139
|
@comment_location << [comment, location]
|
142
140
|
|
@@ -208,7 +206,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
208
206
|
normalize_comment comment
|
209
207
|
end
|
210
208
|
|
211
|
-
comment = "#{@comment}\n---\n#{comment}" unless @comment.empty?
|
209
|
+
comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty?
|
212
210
|
|
213
211
|
super comment
|
214
212
|
end
|
@@ -221,7 +219,9 @@ class RDoc::ClassModule < RDoc::Context
|
|
221
219
|
def complete min_visibility
|
222
220
|
update_aliases
|
223
221
|
remove_nodoc_children
|
222
|
+
embed_mixins
|
224
223
|
update_includes
|
224
|
+
update_extends
|
225
225
|
remove_invisible min_visibility
|
226
226
|
end
|
227
227
|
|
@@ -292,6 +292,25 @@ class RDoc::ClassModule < RDoc::Context
|
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
|
+
##
|
296
|
+
# Return array of full_name splitted by +::+.
|
297
|
+
|
298
|
+
def nesting_namespaces
|
299
|
+
@namespaces ||= full_name.split("::").reject(&:empty?)
|
300
|
+
end
|
301
|
+
|
302
|
+
##
|
303
|
+
# Return array of fully qualified nesting namespaces.
|
304
|
+
#
|
305
|
+
# For example, if full_name is +A::B::C+, this method returns <code>["A", "A::B", "A::B::C"]</code>
|
306
|
+
|
307
|
+
def fully_qualified_nesting_namespaces
|
308
|
+
return nesting_namespaces if nesting_namespaces.length < 2
|
309
|
+
@fqns ||= nesting_namespaces.inject([]) do |list, n|
|
310
|
+
list << (list.empty? ? n : "#{list.last}::#{n}")
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
295
314
|
##
|
296
315
|
# TODO: filter included items by #display?
|
297
316
|
|
@@ -356,37 +375,39 @@ class RDoc::ClassModule < RDoc::Context
|
|
356
375
|
@name = array[1]
|
357
376
|
@full_name = array[2]
|
358
377
|
@superclass = array[3]
|
359
|
-
|
378
|
+
document = array[4]
|
360
379
|
|
361
|
-
@
|
362
|
-
|
380
|
+
@comment = RDoc::Comment.from_document document
|
381
|
+
|
382
|
+
@comment_location = if RDoc::Markup::Document === document.parts.first then
|
383
|
+
document
|
363
384
|
else
|
364
|
-
RDoc::Markup::Document.new
|
385
|
+
RDoc::Markup::Document.new document
|
365
386
|
end
|
366
387
|
|
367
388
|
array[5].each do |name, rw, visibility, singleton, file|
|
368
389
|
singleton ||= false
|
369
390
|
visibility ||= :public
|
370
391
|
|
371
|
-
attr = RDoc::Attr.new nil, name, rw, nil, singleton
|
392
|
+
attr = RDoc::Attr.new nil, name, rw, nil, singleton: singleton
|
372
393
|
|
373
394
|
add_attribute attr
|
374
395
|
attr.visibility = visibility
|
375
396
|
attr.record_location RDoc::TopLevel.new file
|
376
397
|
end
|
377
398
|
|
378
|
-
array[6].each do |constant,
|
399
|
+
array[6].each do |constant, document, file|
|
379
400
|
case constant
|
380
401
|
when RDoc::Constant then
|
381
402
|
add_constant constant
|
382
403
|
else
|
383
|
-
constant = add_constant RDoc::Constant.new(constant, nil,
|
404
|
+
constant = add_constant RDoc::Constant.new(constant, nil, RDoc::Comment.from_document(document))
|
384
405
|
constant.record_location RDoc::TopLevel.new file
|
385
406
|
end
|
386
407
|
end
|
387
408
|
|
388
|
-
array[7].each do |name,
|
389
|
-
incl = add_include RDoc::Include.new(name,
|
409
|
+
array[7].each do |name, document, file|
|
410
|
+
incl = add_include RDoc::Include.new(name, RDoc::Comment.from_document(document))
|
390
411
|
incl.record_location RDoc::TopLevel.new file
|
391
412
|
end
|
392
413
|
|
@@ -395,16 +416,15 @@ class RDoc::ClassModule < RDoc::Context
|
|
395
416
|
@visibility = visibility
|
396
417
|
|
397
418
|
methods.each do |name, file|
|
398
|
-
method = RDoc::AnyMethod.new nil, name
|
399
|
-
method.singleton = true if type == 'class'
|
419
|
+
method = RDoc::AnyMethod.new nil, name, singleton: type == 'class'
|
400
420
|
method.record_location RDoc::TopLevel.new file
|
401
421
|
add_method method
|
402
422
|
end
|
403
423
|
end
|
404
424
|
end
|
405
425
|
|
406
|
-
array[9].each do |name,
|
407
|
-
ext = add_extend RDoc::Extend.new(name,
|
426
|
+
array[9].each do |name, document, file|
|
427
|
+
ext = add_extend RDoc::Extend.new(name, RDoc::Comment.from_document(document))
|
408
428
|
ext.record_location RDoc::TopLevel.new file
|
409
429
|
end if array[9] # Support Marshal version 1
|
410
430
|
|
@@ -441,7 +461,8 @@ class RDoc::ClassModule < RDoc::Context
|
|
441
461
|
|
442
462
|
document = document.merge other_document
|
443
463
|
|
444
|
-
@comment =
|
464
|
+
@comment = RDoc::Comment.from_document(document)
|
465
|
+
@comment_location = document
|
445
466
|
end
|
446
467
|
|
447
468
|
cm = class_module
|
@@ -609,7 +630,9 @@ class RDoc::ClassModule < RDoc::Context
|
|
609
630
|
# Path to this class or module for use with HTML generator output.
|
610
631
|
|
611
632
|
def path
|
612
|
-
|
633
|
+
prefix = options.class_module_path_prefix
|
634
|
+
return http_url unless prefix
|
635
|
+
File.join(prefix, http_url)
|
613
636
|
end
|
614
637
|
|
615
638
|
##
|
@@ -702,10 +725,37 @@ class RDoc::ClassModule < RDoc::Context
|
|
702
725
|
|
703
726
|
##
|
704
727
|
# Set the superclass of this class to +superclass+
|
728
|
+
#
|
729
|
+
# where +superclass+ is one of:
|
730
|
+
#
|
731
|
+
# - +nil+
|
732
|
+
# - a String containing the full name of the superclass
|
733
|
+
# - the RDoc::ClassModule representing the superclass
|
705
734
|
|
706
735
|
def superclass=(superclass)
|
707
736
|
raise NoMethodError, "#{full_name} is a module" if module?
|
708
|
-
|
737
|
+
case superclass
|
738
|
+
when RDoc::ClassModule
|
739
|
+
@superclass = superclass.full_name
|
740
|
+
when nil, String
|
741
|
+
@superclass = superclass
|
742
|
+
else
|
743
|
+
raise TypeError, "superclass must be a String or RDoc::ClassModule, not #{superclass.class}"
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
##
|
748
|
+
# Get all super classes of this class in an array. The last element might be
|
749
|
+
# a string if the name is unknown.
|
750
|
+
|
751
|
+
def super_classes
|
752
|
+
result = []
|
753
|
+
parent = self
|
754
|
+
while parent = parent.superclass
|
755
|
+
result << parent
|
756
|
+
return result if parent.is_a?(String)
|
757
|
+
end
|
758
|
+
result
|
709
759
|
end
|
710
760
|
|
711
761
|
def to_s # :nodoc:
|
@@ -796,5 +846,43 @@ class RDoc::ClassModule < RDoc::Context
|
|
796
846
|
extends.uniq!
|
797
847
|
end
|
798
848
|
|
799
|
-
|
849
|
+
def embed_mixins
|
850
|
+
return unless options.embed_mixins
|
851
|
+
|
852
|
+
includes.each do |include|
|
853
|
+
next if String === include.module
|
854
|
+
include.module.method_list.each do |code_object|
|
855
|
+
add_method(prepare_to_embed(code_object))
|
856
|
+
end
|
857
|
+
include.module.constants.each do |code_object|
|
858
|
+
add_constant(prepare_to_embed(code_object))
|
859
|
+
end
|
860
|
+
include.module.attributes.each do |code_object|
|
861
|
+
add_attribute(prepare_to_embed(code_object))
|
862
|
+
end
|
863
|
+
end
|
800
864
|
|
865
|
+
extends.each do |ext|
|
866
|
+
next if String === ext.module
|
867
|
+
ext.module.method_list.each do |code_object|
|
868
|
+
add_method(prepare_to_embed(code_object, true))
|
869
|
+
end
|
870
|
+
ext.module.attributes.each do |code_object|
|
871
|
+
add_attribute(prepare_to_embed(code_object, true))
|
872
|
+
end
|
873
|
+
end
|
874
|
+
end
|
875
|
+
|
876
|
+
private
|
877
|
+
|
878
|
+
def prepare_to_embed(code_object, singleton=false)
|
879
|
+
code_object = code_object.dup
|
880
|
+
code_object.mixin_from = code_object.parent
|
881
|
+
code_object.singleton = true if singleton
|
882
|
+
set_current_section(code_object.section.title, code_object.section.comment)
|
883
|
+
# add_method and add_attribute will reassign self's visibility back to the method/attribute
|
884
|
+
# so we need to sync self's visibility with the object's to properly retain that information
|
885
|
+
self.visibility = code_object.visibility
|
886
|
+
code_object
|
887
|
+
end
|
888
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# A constant
|
4
4
|
|
@@ -36,7 +36,7 @@ class RDoc::Constant < RDoc::CodeObject
|
|
36
36
|
@value = value
|
37
37
|
|
38
38
|
@is_alias_for = nil
|
39
|
-
@visibility =
|
39
|
+
@visibility = :public
|
40
40
|
|
41
41
|
self.comment = comment
|
42
42
|
end
|
@@ -133,10 +133,10 @@ class RDoc::Constant < RDoc::CodeObject
|
|
133
133
|
# * #parent_name
|
134
134
|
|
135
135
|
def marshal_load array
|
136
|
-
initialize array[1], nil, array[5]
|
136
|
+
initialize array[1], nil, RDoc::Comment.from_document(array[5])
|
137
137
|
|
138
138
|
@full_name = array[2]
|
139
|
-
@visibility = array[3]
|
139
|
+
@visibility = array[3] || :public
|
140
140
|
@is_alias_for = array[4]
|
141
141
|
# 5 handled above
|
142
142
|
# 6 handled below
|
@@ -184,4 +184,3 @@ class RDoc::Constant < RDoc::CodeObject
|
|
184
184
|
end
|
185
185
|
|
186
186
|
end
|
187
|
-
|