rdoc 4.2.1 → 6.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CONTRIBUTING.rdoc +8 -7
- data/Gemfile +12 -0
- data/History.rdoc +48 -4
- data/LEGAL.rdoc +2 -2
- data/README.rdoc +5 -5
- data/Rakefile +73 -155
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +0 -0
- data/{bin → exe}/ri +0 -0
- data/lib/rdoc/alias.rb +1 -0
- data/lib/rdoc/anon_class.rb +1 -0
- data/lib/rdoc/any_method.rb +59 -14
- data/lib/rdoc/attr.rb +1 -0
- data/lib/rdoc/class_module.rb +5 -2
- data/lib/rdoc/code_object.rb +3 -11
- data/lib/rdoc/code_objects.rb +1 -0
- data/lib/rdoc/comment.rb +32 -11
- data/lib/rdoc/constant.rb +3 -2
- data/lib/rdoc/context/section.rb +7 -13
- data/lib/rdoc/context.rb +78 -23
- data/lib/rdoc/cross_reference.rb +33 -14
- data/lib/rdoc/encoding.rb +92 -55
- data/lib/rdoc/erb_partial.rb +2 -1
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +1 -0
- data/lib/rdoc/generator/darkfish.rb +62 -32
- data/lib/rdoc/generator/json_index.rb +8 -5
- data/lib/rdoc/generator/markup.rb +3 -12
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +4 -3
- data/lib/rdoc/generator/ri.rb +1 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -8
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
- 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 +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +6 -6
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +23 -100
- data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
- data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
- data/lib/rdoc/generator/template/json_index/js/searcher.js +7 -6
- data/lib/rdoc/generator.rb +1 -1
- data/lib/rdoc/ghost_method.rb +1 -0
- data/lib/rdoc/i18n/locale.rb +2 -1
- data/lib/rdoc/i18n/text.rb +5 -4
- data/lib/rdoc/i18n.rb +3 -2
- data/lib/rdoc/include.rb +1 -0
- data/lib/rdoc/known_classes.rb +1 -0
- data/lib/rdoc/markdown/entities.rb +1 -0
- data/lib/rdoc/markdown/{literals_1_9.kpeg → literals.kpeg} +1 -0
- data/lib/rdoc/markdown/{literals_1_9.rb → literals.rb} +1 -4
- data/lib/rdoc/markdown.kpeg +94 -51
- data/lib/rdoc/markdown.rb +1171 -619
- data/lib/rdoc/markup/attr_changer.rb +1 -0
- data/lib/rdoc/markup/attr_span.rb +9 -2
- data/lib/rdoc/markup/attribute_manager.rb +115 -49
- data/lib/rdoc/markup/attributes.rb +7 -6
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +1 -0
- data/lib/rdoc/markup/document.rb +1 -0
- data/lib/rdoc/markup/formatter.rb +25 -23
- data/lib/rdoc/markup/hard_break.rb +1 -0
- data/lib/rdoc/markup/heading.rb +4 -3
- data/lib/rdoc/markup/include.rb +1 -0
- data/lib/rdoc/markup/indented_paragraph.rb +1 -0
- data/lib/rdoc/markup/list.rb +1 -0
- data/lib/rdoc/markup/list_item.rb +1 -0
- data/lib/rdoc/markup/paragraph.rb +1 -0
- data/lib/rdoc/markup/parser.rb +78 -61
- data/lib/rdoc/markup/pre_process.rb +12 -9
- data/lib/rdoc/markup/raw.rb +1 -0
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/to_ansi.rb +1 -0
- data/lib/rdoc/markup/to_bs.rb +4 -5
- data/lib/rdoc/markup/to_html.rb +71 -25
- data/lib/rdoc/markup/to_html_crossref.rb +41 -25
- data/lib/rdoc/markup/to_html_snippet.rb +10 -9
- data/lib/rdoc/markup/to_joined_paragraph.rb +7 -31
- data/lib/rdoc/markup/to_label.rb +10 -9
- data/lib/rdoc/markup/to_markdown.rb +9 -8
- data/lib/rdoc/markup/to_rdoc.rb +35 -6
- data/lib/rdoc/markup/to_table_of_contents.rb +2 -0
- data/lib/rdoc/markup/to_test.rb +1 -0
- data/lib/rdoc/markup/to_tt_only.rb +3 -2
- data/lib/rdoc/markup/verbatim.rb +1 -0
- data/lib/rdoc/markup.rb +14 -16
- data/lib/rdoc/meta_method.rb +1 -0
- data/lib/rdoc/method_attr.rb +2 -1
- data/lib/rdoc/mixin.rb +1 -0
- data/lib/rdoc/normal_class.rb +3 -2
- data/lib/rdoc/normal_module.rb +1 -0
- data/lib/rdoc/options.rb +92 -58
- data/lib/rdoc/parser/c.rb +219 -223
- data/lib/rdoc/parser/changelog.rb +155 -18
- data/lib/rdoc/parser/markdown.rb +1 -0
- data/lib/rdoc/parser/rd.rb +1 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +635 -468
- data/lib/rdoc/parser/ruby_tools.rb +33 -33
- data/lib/rdoc/parser/simple.rb +3 -3
- data/lib/rdoc/parser/text.rb +1 -0
- data/lib/rdoc/parser.rb +17 -50
- data/lib/rdoc/rd/block_parser.rb +66 -65
- data/lib/rdoc/rd/block_parser.ry +3 -3
- data/lib/rdoc/rd/inline.rb +5 -4
- data/lib/rdoc/rd/inline_parser.rb +52 -51
- data/lib/rdoc/rd/inline_parser.ry +1 -1
- data/lib/rdoc/rd.rb +1 -0
- data/lib/rdoc/rdoc.rb +68 -63
- data/lib/rdoc/require.rb +1 -0
- data/lib/rdoc/ri/driver.rb +133 -58
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +4 -20
- data/lib/rdoc/ri/store.rb +1 -0
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +1 -0
- data/lib/rdoc/rubygems_hook.rb +5 -12
- data/lib/rdoc/servlet.rb +24 -14
- data/lib/rdoc/single_class.rb +1 -0
- data/lib/rdoc/stats/normal.rb +20 -21
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +1 -0
- data/lib/rdoc/store.rb +41 -41
- data/lib/rdoc/task.rb +2 -3
- data/lib/rdoc/text.rb +19 -38
- data/lib/rdoc/token_stream.rb +56 -32
- data/lib/rdoc/tom_doc.rb +17 -11
- data/lib/rdoc/top_level.rb +9 -2
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +24 -10
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +248 -0
- metadata +43 -236
- data/.autotest +0 -24
- data/.document +0 -5
- data/Manifest.txt +0 -306
- data/lib/gauntlet_rdoc.rb +0 -84
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
- data/lib/rdoc/markdown/literals_1_8.kpeg +0 -18
- data/lib/rdoc/markdown/literals_1_8.rb +0 -416
- data/lib/rdoc/markup/formatter_test_case.rb +0 -767
- data/lib/rdoc/markup/inline.rb +0 -1
- data/lib/rdoc/markup/special.rb +0 -40
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -114
- data/lib/rdoc/ruby_lex.rb +0 -1377
- data/lib/rdoc/ruby_token.rb +0 -460
- data/lib/rdoc/test_case.rb +0 -217
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +0 -21
- data/test/MarkdownTest_1.0.3/Auto links.text +0 -13
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +0 -120
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +0 -11
- data/test/MarkdownTest_1.0.3/Code Blocks.text +0 -14
- data/test/MarkdownTest_1.0.3/Code Spans.text +0 -6
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +0 -8
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +0 -67
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +0 -15
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +0 -69
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +0 -13
- data/test/MarkdownTest_1.0.3/Links, inline style.text +0 -12
- data/test/MarkdownTest_1.0.3/Links, reference style.text +0 -71
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +0 -20
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +0 -7
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +0 -306
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +0 -888
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +0 -5
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +0 -131
- data/test/MarkdownTest_1.0.3/Strong and em together.text +0 -7
- data/test/MarkdownTest_1.0.3/Tabs.text +0 -21
- data/test/MarkdownTest_1.0.3/Tidyness.text +0 -5
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.largedoc +0 -3
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -460
- data/test/test_rdoc_attr.rb +0 -190
- data/test/test_rdoc_class_module.rb +0 -1492
- data/test/test_rdoc_code_object.rb +0 -450
- data/test/test_rdoc_comment.rb +0 -504
- data/test/test_rdoc_constant.rb +0 -181
- data/test/test_rdoc_context.rb +0 -901
- data/test/test_rdoc_context_section.rb +0 -130
- data/test/test_rdoc_cross_reference.rb +0 -192
- data/test/test_rdoc_encoding.rb +0 -227
- data/test/test_rdoc_extend.rb +0 -94
- data/test/test_rdoc_generator_darkfish.rb +0 -229
- data/test/test_rdoc_generator_json_index.rb +0 -324
- data/test/test_rdoc_generator_markup.rb +0 -59
- data/test/test_rdoc_generator_pot.rb +0 -91
- data/test/test_rdoc_generator_pot_po.rb +0 -51
- data/test/test_rdoc_generator_pot_po_entry.rb +0 -139
- data/test/test_rdoc_generator_ri.rb +0 -78
- data/test/test_rdoc_i18n_locale.rb +0 -73
- data/test/test_rdoc_i18n_text.rb +0 -123
- data/test/test_rdoc_include.rb +0 -108
- data/test/test_rdoc_markdown.rb +0 -980
- data/test/test_rdoc_markdown_test.rb +0 -1884
- data/test/test_rdoc_markup.rb +0 -95
- data/test/test_rdoc_markup_attribute_manager.rb +0 -364
- data/test/test_rdoc_markup_attributes.rb +0 -39
- data/test/test_rdoc_markup_document.rb +0 -207
- data/test/test_rdoc_markup_formatter.rb +0 -175
- data/test/test_rdoc_markup_hard_break.rb +0 -31
- data/test/test_rdoc_markup_heading.rb +0 -29
- data/test/test_rdoc_markup_include.rb +0 -19
- data/test/test_rdoc_markup_indented_paragraph.rb +0 -53
- data/test/test_rdoc_markup_paragraph.rb +0 -32
- data/test/test_rdoc_markup_parser.rb +0 -1680
- data/test/test_rdoc_markup_pre_process.rb +0 -473
- data/test/test_rdoc_markup_raw.rb +0 -22
- data/test/test_rdoc_markup_to_ansi.rb +0 -369
- data/test/test_rdoc_markup_to_bs.rb +0 -366
- data/test/test_rdoc_markup_to_html.rb +0 -662
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -225
- data/test/test_rdoc_markup_to_html_snippet.rb +0 -711
- data/test/test_rdoc_markup_to_joined_paragraph.rb +0 -32
- data/test/test_rdoc_markup_to_label.rb +0 -112
- data/test/test_rdoc_markup_to_markdown.rb +0 -389
- data/test/test_rdoc_markup_to_rdoc.rb +0 -377
- data/test/test_rdoc_markup_to_table_of_contents.rb +0 -126
- data/test/test_rdoc_markup_to_tt_only.rb +0 -246
- data/test/test_rdoc_markup_verbatim.rb +0 -29
- data/test/test_rdoc_method_attr.rb +0 -193
- data/test/test_rdoc_normal_class.rb +0 -47
- data/test/test_rdoc_normal_module.rb +0 -42
- data/test/test_rdoc_options.rb +0 -766
- data/test/test_rdoc_parser.rb +0 -327
- data/test/test_rdoc_parser_c.rb +0 -1896
- data/test/test_rdoc_parser_changelog.rb +0 -315
- data/test/test_rdoc_parser_markdown.rb +0 -61
- data/test/test_rdoc_parser_rd.rb +0 -55
- data/test/test_rdoc_parser_ruby.rb +0 -3322
- data/test/test_rdoc_parser_simple.rb +0 -115
- data/test/test_rdoc_rd.rb +0 -30
- data/test/test_rdoc_rd_block_parser.rb +0 -535
- data/test/test_rdoc_rd_inline.rb +0 -63
- data/test/test_rdoc_rd_inline_parser.rb +0 -177
- data/test/test_rdoc_rdoc.rb +0 -455
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -1436
- data/test/test_rdoc_ri_paths.rb +0 -155
- data/test/test_rdoc_ruby_lex.rb +0 -421
- data/test/test_rdoc_ruby_token.rb +0 -19
- data/test/test_rdoc_rubygems_hook.rb +0 -251
- data/test/test_rdoc_servlet.rb +0 -534
- data/test/test_rdoc_single_class.rb +0 -20
- data/test/test_rdoc_stats.rb +0 -722
- data/test/test_rdoc_store.rb +0 -993
- data/test/test_rdoc_task.rb +0 -173
- data/test/test_rdoc_text.rb +0 -557
- data/test/test_rdoc_token_stream.rb +0 -42
- data/test/test_rdoc_tom_doc.rb +0 -520
- data/test/test_rdoc_top_level.rb +0 -287
- data/test/xref_data.rb +0 -76
- data/test/xref_test_case.rb +0 -67
data/lib/rdoc/comment.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
##
|
2
3
|
# A comment holds the text comment for a RDoc::CodeObject and provides a
|
3
4
|
# unified way of cleaning it up and parsing it into an RDoc::Markup::Document.
|
@@ -22,6 +23,11 @@ class RDoc::Comment
|
|
22
23
|
|
23
24
|
attr_accessor :location
|
24
25
|
|
26
|
+
##
|
27
|
+
# Line where this Comment was written
|
28
|
+
|
29
|
+
attr_accessor :line
|
30
|
+
|
25
31
|
##
|
26
32
|
# For duck-typing when merging classes at load time
|
27
33
|
|
@@ -32,6 +38,11 @@ class RDoc::Comment
|
|
32
38
|
|
33
39
|
attr_reader :text
|
34
40
|
|
41
|
+
##
|
42
|
+
# Alias for text
|
43
|
+
|
44
|
+
alias to_s text
|
45
|
+
|
35
46
|
##
|
36
47
|
# Overrides the content returned by #parse. Use when there is no #text
|
37
48
|
# source for this comment
|
@@ -42,9 +53,10 @@ class RDoc::Comment
|
|
42
53
|
# Creates a new comment with +text+ that is found in the RDoc::TopLevel
|
43
54
|
# +location+.
|
44
55
|
|
45
|
-
def initialize text = nil, location = nil
|
56
|
+
def initialize text = nil, location = nil, language = nil
|
46
57
|
@location = location
|
47
|
-
@text = text
|
58
|
+
@text = text.nil? ? nil : text.dup
|
59
|
+
@language = language
|
48
60
|
|
49
61
|
@document = nil
|
50
62
|
@format = 'rdoc'
|
@@ -113,10 +125,14 @@ class RDoc::Comment
|
|
113
125
|
|
114
126
|
method.call_seq = seq.chomp
|
115
127
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
128
|
+
else
|
129
|
+
regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m
|
130
|
+
if regexp =~ @text then
|
131
|
+
@text = @text.sub(regexp, '')
|
132
|
+
seq = $1
|
133
|
+
seq.gsub!(/^\s*/, '')
|
134
|
+
method.call_seq = seq
|
135
|
+
end
|
120
136
|
end
|
121
137
|
|
122
138
|
method
|
@@ -132,8 +148,14 @@ class RDoc::Comment
|
|
132
148
|
##
|
133
149
|
# HACK dubious
|
134
150
|
|
135
|
-
def
|
136
|
-
|
151
|
+
def encode! encoding
|
152
|
+
# TODO: Remove this condition after Ruby 2.2 EOL
|
153
|
+
if RUBY_VERSION < '2.3.0'
|
154
|
+
@text = @text.force_encoding encoding
|
155
|
+
else
|
156
|
+
@text = String.new @text, encoding: encoding
|
157
|
+
end
|
158
|
+
self
|
137
159
|
end
|
138
160
|
|
139
161
|
##
|
@@ -199,7 +221,7 @@ class RDoc::Comment
|
|
199
221
|
def remove_private
|
200
222
|
# Workaround for gsub encoding for Ruby 1.9.2 and earlier
|
201
223
|
empty = ''
|
202
|
-
empty.
|
224
|
+
empty = RDoc::Encoding.change_encoding empty, @text.encoding
|
203
225
|
|
204
226
|
@text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
|
205
227
|
@text = @text.sub(%r%^\s*[#*]?--.*%m, '')
|
@@ -215,7 +237,7 @@ class RDoc::Comment
|
|
215
237
|
@text.nil? and @document
|
216
238
|
|
217
239
|
@document = nil
|
218
|
-
@text = text
|
240
|
+
@text = text.nil? ? nil : text.dup
|
219
241
|
end
|
220
242
|
|
221
243
|
##
|
@@ -226,4 +248,3 @@ class RDoc::Comment
|
|
226
248
|
end
|
227
249
|
|
228
250
|
end
|
229
|
-
|
data/lib/rdoc/constant.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
##
|
2
3
|
# A constant
|
3
4
|
|
@@ -35,7 +36,7 @@ class RDoc::Constant < RDoc::CodeObject
|
|
35
36
|
@value = value
|
36
37
|
|
37
38
|
@is_alias_for = nil
|
38
|
-
@visibility =
|
39
|
+
@visibility = :public
|
39
40
|
|
40
41
|
self.comment = comment
|
41
42
|
end
|
@@ -135,7 +136,7 @@ class RDoc::Constant < RDoc::CodeObject
|
|
135
136
|
initialize array[1], nil, array[5]
|
136
137
|
|
137
138
|
@full_name = array[2]
|
138
|
-
@visibility = array[3]
|
139
|
+
@visibility = array[3] || :public
|
139
140
|
@is_alias_for = array[4]
|
140
141
|
# 5 handled above
|
141
142
|
# 6 handled below
|
data/lib/rdoc/context/section.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
##
|
2
3
|
# A section of documentation like:
|
3
4
|
#
|
@@ -33,8 +34,6 @@ class RDoc::Context::Section
|
|
33
34
|
|
34
35
|
attr_reader :title
|
35
36
|
|
36
|
-
@@sequence = "SEC00000"
|
37
|
-
|
38
37
|
##
|
39
38
|
# Creates a new section with +title+ and +comment+
|
40
39
|
|
@@ -42,9 +41,6 @@ class RDoc::Context::Section
|
|
42
41
|
@parent = parent
|
43
42
|
@title = title ? title.strip : title
|
44
43
|
|
45
|
-
@@sequence.succ!
|
46
|
-
@sequence = @@sequence.dup
|
47
|
-
|
48
44
|
@comments = []
|
49
45
|
|
50
46
|
add_comment comment
|
@@ -57,6 +53,8 @@ class RDoc::Context::Section
|
|
57
53
|
self.class === other and @title == other.title
|
58
54
|
end
|
59
55
|
|
56
|
+
alias eql? ==
|
57
|
+
|
60
58
|
##
|
61
59
|
# Adds +comment+ to this section
|
62
60
|
|
@@ -127,6 +125,10 @@ class RDoc::Context::Section
|
|
127
125
|
"#<%s:0x%x %p>" % [self.class, object_id, title]
|
128
126
|
end
|
129
127
|
|
128
|
+
def hash # :nodoc:
|
129
|
+
@title.hash
|
130
|
+
end
|
131
|
+
|
130
132
|
##
|
131
133
|
# The files comments in this section come from
|
132
134
|
|
@@ -226,13 +228,5 @@ class RDoc::Context::Section
|
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
229
|
-
##
|
230
|
-
# Section sequence number (deprecated)
|
231
|
-
|
232
|
-
def sequence
|
233
|
-
warn "RDoc::Context::Section#sequence is deprecated, use #aref"
|
234
|
-
@sequence
|
235
|
-
end
|
236
|
-
|
237
231
|
end
|
238
232
|
|
data/lib/rdoc/context.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cgi'
|
2
3
|
|
3
4
|
##
|
@@ -97,6 +98,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
97
98
|
|
98
99
|
attr_accessor :visibility
|
99
100
|
|
101
|
+
##
|
102
|
+
# Current visibility of this line
|
103
|
+
|
104
|
+
attr_writer :current_line_visibility
|
105
|
+
|
100
106
|
##
|
101
107
|
# Hash of registered methods. Attributes are also registered here,
|
102
108
|
# twice if they are RW.
|
@@ -147,6 +153,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
147
153
|
@extends = []
|
148
154
|
@constants = []
|
149
155
|
@external_aliases = []
|
156
|
+
@current_line_visibility = nil
|
150
157
|
|
151
158
|
# This Hash maps a method name to a list of unmatched aliases (aliases of
|
152
159
|
# a method not yet encountered).
|
@@ -232,7 +239,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
232
239
|
|
233
240
|
if known then
|
234
241
|
known.comment = attribute.comment if known.comment.empty?
|
235
|
-
elsif registered = @methods_hash[attribute.pretty_name
|
242
|
+
elsif registered = @methods_hash[attribute.pretty_name + '='] and
|
236
243
|
RDoc::Attr === registered then
|
237
244
|
registered.rw = 'RW'
|
238
245
|
else
|
@@ -242,7 +249,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
242
249
|
end
|
243
250
|
|
244
251
|
if attribute.rw.index 'W' then
|
245
|
-
key = attribute.pretty_name
|
252
|
+
key = attribute.pretty_name + '='
|
246
253
|
known = @methods_hash[key]
|
247
254
|
|
248
255
|
if known then
|
@@ -326,7 +333,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
326
333
|
if full_name == 'BasicObject' then
|
327
334
|
superclass = nil
|
328
335
|
elsif full_name == 'Object' then
|
329
|
-
superclass =
|
336
|
+
superclass = '::BasicObject'
|
330
337
|
end
|
331
338
|
|
332
339
|
# find the superclass full name
|
@@ -400,6 +407,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
400
407
|
mod.section = current_section # TODO declaring context? something is
|
401
408
|
# wrong here...
|
402
409
|
mod.parent = self
|
410
|
+
mod.full_name = nil
|
403
411
|
mod.store = @store
|
404
412
|
|
405
413
|
unless @done_documenting then
|
@@ -407,6 +415,10 @@ class RDoc::Context < RDoc::CodeObject
|
|
407
415
|
# this must be done AFTER adding mod to its parent, so that the full
|
408
416
|
# name is correct:
|
409
417
|
all_hash[mod.full_name] = mod
|
418
|
+
if @store.unmatched_constant_alias[mod.full_name] then
|
419
|
+
to, file = @store.unmatched_constant_alias[mod.full_name]
|
420
|
+
add_module_alias mod, mod.name, to, file
|
421
|
+
end
|
410
422
|
end
|
411
423
|
|
412
424
|
mod
|
@@ -477,7 +489,11 @@ class RDoc::Context < RDoc::CodeObject
|
|
477
489
|
end
|
478
490
|
else
|
479
491
|
@methods_hash[key] = method
|
480
|
-
|
492
|
+
if @current_line_visibility
|
493
|
+
method.visibility, @current_line_visibility = @current_line_visibility, nil
|
494
|
+
else
|
495
|
+
method.visibility = @visibility
|
496
|
+
end
|
481
497
|
add_to @method_list, method
|
482
498
|
resolve_aliases method
|
483
499
|
end
|
@@ -499,41 +515,53 @@ class RDoc::Context < RDoc::CodeObject
|
|
499
515
|
add_class_or_module mod, @modules, @store.modules_hash
|
500
516
|
end
|
501
517
|
|
518
|
+
##
|
519
|
+
# Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
|
520
|
+
|
521
|
+
def add_module_by_normal_module(mod)
|
522
|
+
add_class_or_module mod, @modules, @store.modules_hash
|
523
|
+
end
|
524
|
+
|
502
525
|
##
|
503
526
|
# Adds an alias from +from+ (a class or module) to +name+ which was defined
|
504
527
|
# in +file+.
|
505
528
|
|
506
|
-
def add_module_alias from,
|
529
|
+
def add_module_alias from, from_name, to, file
|
507
530
|
return from if @done_documenting
|
508
531
|
|
509
|
-
|
532
|
+
to_full_name = child_name to.name
|
510
533
|
|
511
534
|
# if we already know this name, don't register an alias:
|
512
535
|
# see the metaprogramming in lib/active_support/basic_object.rb,
|
513
536
|
# where we already know BasicObject is a class when we find
|
514
537
|
# BasicObject = BlankSlate
|
515
|
-
return from if @store.find_class_or_module
|
538
|
+
return from if @store.find_class_or_module to_full_name
|
516
539
|
|
517
|
-
|
518
|
-
|
519
|
-
|
540
|
+
unless from
|
541
|
+
@store.unmatched_constant_alias[child_name(from_name)] = [to, file]
|
542
|
+
return to
|
543
|
+
end
|
544
|
+
|
545
|
+
new_to = from.dup
|
546
|
+
new_to.name = to.name
|
547
|
+
new_to.full_name = nil
|
520
548
|
|
521
|
-
if
|
522
|
-
@store.modules_hash[
|
523
|
-
@modules[name] =
|
549
|
+
if new_to.module? then
|
550
|
+
@store.modules_hash[to_full_name] = new_to
|
551
|
+
@modules[to.name] = new_to
|
524
552
|
else
|
525
|
-
@store.classes_hash[
|
526
|
-
@classes[name] =
|
553
|
+
@store.classes_hash[to_full_name] = new_to
|
554
|
+
@classes[to.name] = new_to
|
527
555
|
end
|
528
556
|
|
529
557
|
# Registers a constant for this alias. The constant value and comment
|
530
558
|
# will be updated later, when the Ruby parser adds the constant
|
531
|
-
const = RDoc::Constant.new name, nil,
|
559
|
+
const = RDoc::Constant.new to.name, nil, new_to.comment
|
532
560
|
const.record_location file
|
533
561
|
const.is_alias_for = from
|
534
562
|
add_constant const
|
535
563
|
|
536
|
-
|
564
|
+
new_to
|
537
565
|
end
|
538
566
|
|
539
567
|
##
|
@@ -751,7 +779,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
751
779
|
attributes.default = []
|
752
780
|
|
753
781
|
sort_sections.each do |section|
|
754
|
-
yield section, constants[section].sort, attributes[section].sort
|
782
|
+
yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
|
755
783
|
end
|
756
784
|
end
|
757
785
|
|
@@ -788,7 +816,9 @@ class RDoc::Context < RDoc::CodeObject
|
|
788
816
|
# Finds a constant with +name+ in this context
|
789
817
|
|
790
818
|
def find_constant_named(name)
|
791
|
-
@constants.find
|
819
|
+
@constants.find do |m|
|
820
|
+
m.name == name || m.full_name == name
|
821
|
+
end
|
792
822
|
end
|
793
823
|
|
794
824
|
##
|
@@ -850,7 +880,13 @@ class RDoc::Context < RDoc::CodeObject
|
|
850
880
|
# Finds a method named +name+ with singleton value +singleton+.
|
851
881
|
|
852
882
|
def find_method(name, singleton)
|
853
|
-
@method_list.find { |m|
|
883
|
+
@method_list.find { |m|
|
884
|
+
if m.singleton
|
885
|
+
m.name == name && m.singleton == singleton
|
886
|
+
else
|
887
|
+
m.name == name && !m.singleton && !singleton
|
888
|
+
end
|
889
|
+
}
|
854
890
|
end
|
855
891
|
|
856
892
|
##
|
@@ -954,13 +990,21 @@ class RDoc::Context < RDoc::CodeObject
|
|
954
990
|
@instance_attributes ||= attributes.reject { |a| a.singleton }
|
955
991
|
end
|
956
992
|
|
993
|
+
##
|
994
|
+
# Instance methods
|
995
|
+
|
996
|
+
def instance_methods
|
997
|
+
@instance_methods ||= method_list.reject { |a| a.singleton }
|
998
|
+
end
|
999
|
+
|
957
1000
|
##
|
958
1001
|
# Instance methods
|
959
1002
|
#--
|
960
|
-
# TODO
|
1003
|
+
# TODO remove this later
|
961
1004
|
|
962
1005
|
def instance_method_list
|
963
|
-
|
1006
|
+
warn '#instance_method_list is obsoleted, please use #instance_methods'
|
1007
|
+
@instance_methods ||= method_list.reject { |a| a.singleton }
|
964
1008
|
end
|
965
1009
|
|
966
1010
|
##
|
@@ -1066,6 +1110,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1066
1110
|
return if [:private, :nodoc].include? min_visibility
|
1067
1111
|
remove_invisible_in @method_list, min_visibility
|
1068
1112
|
remove_invisible_in @attributes, min_visibility
|
1113
|
+
remove_invisible_in @constants, min_visibility
|
1069
1114
|
end
|
1070
1115
|
|
1071
1116
|
##
|
@@ -1152,6 +1197,17 @@ class RDoc::Context < RDoc::CodeObject
|
|
1152
1197
|
end
|
1153
1198
|
end
|
1154
1199
|
|
1200
|
+
##
|
1201
|
+
# Given an array +names+ of constants, set the visibility of each constant to
|
1202
|
+
# +visibility+
|
1203
|
+
|
1204
|
+
def set_constant_visibility_for(names, visibility)
|
1205
|
+
names.each do |name|
|
1206
|
+
constant = @constants_hash[name] or next
|
1207
|
+
constant.visibility = visibility
|
1208
|
+
end
|
1209
|
+
end
|
1210
|
+
|
1155
1211
|
##
|
1156
1212
|
# Sorts sections alphabetically (default) or in TomDoc fashion (none,
|
1157
1213
|
# Public, Internal, Deprecated)
|
@@ -1208,4 +1264,3 @@ class RDoc::Context < RDoc::CodeObject
|
|
1208
1264
|
autoload :Section, 'rdoc/context/section'
|
1209
1265
|
|
1210
1266
|
end
|
1211
|
-
|
data/lib/rdoc/cross_reference.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
##
|
2
3
|
# RDoc::CrossReference is a reusable way to create cross references for names.
|
3
4
|
|
@@ -18,16 +19,16 @@ class RDoc::CrossReference
|
|
18
19
|
#
|
19
20
|
# See CLASS_REGEXP_STR
|
20
21
|
|
21
|
-
METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]
|
22
|
+
METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|\+@|-@|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
|
22
23
|
|
23
24
|
##
|
24
25
|
# Regular expressions matching text that should potentially have
|
25
|
-
# cross-reference links generated are passed to
|
26
|
-
# these expressions are meant to pick up text for which cross-references
|
26
|
+
# cross-reference links generated are passed to add_regexp_handling. Note
|
27
|
+
# that these expressions are meant to pick up text for which cross-references
|
27
28
|
# have been suppressed, since the suppression characters are removed by the
|
28
29
|
# code that is triggered.
|
29
30
|
|
30
|
-
CROSSREF_REGEXP = /(
|
31
|
+
CROSSREF_REGEXP = /(?:^|[\s()])
|
31
32
|
(
|
32
33
|
(?:
|
33
34
|
# A::B::C.meth
|
@@ -75,7 +76,7 @@ class RDoc::CrossReference
|
|
75
76
|
# Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
|
76
77
|
|
77
78
|
ALL_CROSSREF_REGEXP = /
|
78
|
-
(
|
79
|
+
(?:^|[\s()])
|
79
80
|
(
|
80
81
|
(?:
|
81
82
|
# A::B::C.meth
|
@@ -126,23 +127,41 @@ class RDoc::CrossReference
|
|
126
127
|
|
127
128
|
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
128
129
|
type = $2
|
129
|
-
|
130
|
-
|
130
|
+
if '.' == type # will find either #method or ::method
|
131
|
+
method = $3
|
132
|
+
else
|
133
|
+
method = "#{type}#{$3}"
|
134
|
+
end
|
131
135
|
container = @context.find_symbol_module($1)
|
132
136
|
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
133
137
|
type = $1
|
134
|
-
|
135
|
-
|
138
|
+
if '.' == type
|
139
|
+
method = $2
|
140
|
+
else
|
141
|
+
method = "#{type}#{$2}"
|
142
|
+
end
|
136
143
|
container = @context
|
137
144
|
else
|
145
|
+
type = nil
|
138
146
|
container = nil
|
139
147
|
end
|
140
148
|
|
141
149
|
if container then
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
150
|
+
unless RDoc::TopLevel === container then
|
151
|
+
if '.' == type then
|
152
|
+
if 'new' == method then # AnyClassName.new will be class method
|
153
|
+
ref = container.find_local_symbol method
|
154
|
+
ref = container.find_ancestor_local_symbol method unless ref
|
155
|
+
else
|
156
|
+
ref = container.find_local_symbol "::#{method}"
|
157
|
+
ref = container.find_ancestor_local_symbol "::#{method}" unless ref
|
158
|
+
ref = container.find_local_symbol "##{method}" unless ref
|
159
|
+
ref = container.find_ancestor_local_symbol "##{method}" unless ref
|
160
|
+
end
|
161
|
+
else
|
162
|
+
ref = container.find_local_symbol method
|
163
|
+
ref = container.find_ancestor_local_symbol method unless ref
|
164
|
+
end
|
146
165
|
end
|
147
166
|
end
|
148
167
|
|
@@ -154,7 +173,7 @@ class RDoc::CrossReference
|
|
154
173
|
end unless ref
|
155
174
|
|
156
175
|
# Try a page name
|
157
|
-
ref = @store.page name if not ref and name =~
|
176
|
+
ref = @store.page name if not ref and name =~ /^[\w.]+$/
|
158
177
|
|
159
178
|
ref = nil if RDoc::Alias === ref # external alias, can't link to it
|
160
179
|
|
data/lib/rdoc/encoding.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: US-ASCII
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
##
|
4
5
|
# This class is a wrapper around File IO and Encoding that helps RDoc load
|
@@ -6,6 +7,18 @@
|
|
6
7
|
|
7
8
|
module RDoc::Encoding
|
8
9
|
|
10
|
+
HEADER_REGEXP = /^
|
11
|
+
(?:
|
12
|
+
\A\#!.*\n
|
13
|
+
|
|
14
|
+
^\#\s+frozen[-_]string[-_]literal[=:].+\n
|
15
|
+
|
|
16
|
+
^\#[^\n]+\b(?:en)?coding[=:]\s*(?<name>[^\s;]+).*\n
|
17
|
+
|
|
18
|
+
<\?xml[^?]*encoding=(?<quote>["'])(?<name>.*?)\k<quote>.*\n
|
19
|
+
)+
|
20
|
+
/xi # :nodoc:
|
21
|
+
|
9
22
|
##
|
10
23
|
# Reads the contents of +filename+ and handles any encoding directives in
|
11
24
|
# the file.
|
@@ -17,50 +30,50 @@ module RDoc::Encoding
|
|
17
30
|
# unknown character in the target encoding will be replaced with '?'
|
18
31
|
|
19
32
|
def self.read_file filename, encoding, force_transcode = false
|
20
|
-
content = open filename, "rb" do |f| f.read end
|
33
|
+
content = File.open filename, "rb" do |f| f.read end
|
21
34
|
content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
|
22
35
|
|
23
36
|
utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
|
24
37
|
|
25
|
-
RDoc::Encoding.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
38
|
+
enc = RDoc::Encoding.detect_encoding content
|
39
|
+
content = RDoc::Encoding.change_encoding content, enc if enc
|
40
|
+
|
41
|
+
begin
|
42
|
+
encoding ||= Encoding.default_external
|
43
|
+
orig_encoding = content.encoding
|
44
|
+
|
45
|
+
if not orig_encoding.ascii_compatible? then
|
46
|
+
content = content.encode encoding
|
47
|
+
elsif utf8 then
|
48
|
+
content = RDoc::Encoding.change_encoding content, Encoding::UTF_8
|
49
|
+
content = content.encode encoding
|
50
|
+
else
|
51
|
+
# assume the content is in our output encoding
|
52
|
+
content = RDoc::Encoding.change_encoding content, encoding
|
53
|
+
end
|
54
|
+
|
55
|
+
unless content.valid_encoding? then
|
56
|
+
# revert and try to transcode
|
57
|
+
content = RDoc::Encoding.change_encoding content, orig_encoding
|
58
|
+
content = content.encode encoding
|
59
|
+
end
|
60
|
+
|
61
|
+
unless content.valid_encoding? then
|
62
|
+
warn "unable to convert #{filename} to #{encoding}, skipping"
|
63
|
+
content = nil
|
64
|
+
end
|
65
|
+
rescue Encoding::InvalidByteSequenceError,
|
66
|
+
Encoding::UndefinedConversionError => e
|
67
|
+
if force_transcode then
|
68
|
+
content = RDoc::Encoding.change_encoding content, orig_encoding
|
69
|
+
content = content.encode(encoding,
|
70
|
+
:invalid => :replace,
|
71
|
+
:undef => :replace,
|
72
|
+
:replace => '?')
|
73
|
+
return content
|
74
|
+
else
|
75
|
+
warn "unable to convert #{e.message} for #{filename}, skipping"
|
76
|
+
return nil
|
64
77
|
end
|
65
78
|
end
|
66
79
|
|
@@ -73,27 +86,51 @@ module RDoc::Encoding
|
|
73
86
|
nil
|
74
87
|
end
|
75
88
|
|
76
|
-
|
77
|
-
# Sets the encoding of +string+ based on the magic comment
|
78
|
-
|
79
|
-
def self.set_encoding string
|
89
|
+
def self.remove_frozen_string_literal string
|
80
90
|
string =~ /\A(?:#!.*\n)?(.*\n)/
|
81
|
-
|
82
91
|
first_line = $1
|
83
92
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
93
|
+
if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
|
94
|
+
string = string.sub first_line, ''
|
95
|
+
end
|
96
|
+
|
97
|
+
string
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Detects the encoding of +string+ based on the magic comment
|
102
|
+
|
103
|
+
def self.detect_encoding string
|
104
|
+
result = HEADER_REGEXP.match string
|
105
|
+
name = result && result[:name]
|
89
106
|
|
90
|
-
|
107
|
+
name ? Encoding.find(name) : nil
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Removes magic comments and shebang
|
91
112
|
|
92
|
-
|
113
|
+
def self.remove_magic_comment string
|
114
|
+
string.sub HEADER_REGEXP do |s|
|
115
|
+
s.gsub(/[^\n]/, '')
|
116
|
+
end
|
117
|
+
end
|
93
118
|
|
94
|
-
|
95
|
-
|
119
|
+
##
|
120
|
+
# Changes encoding based on +encoding+ without converting and returns new
|
121
|
+
# string
|
122
|
+
|
123
|
+
def self.change_encoding text, encoding
|
124
|
+
if text.kind_of? RDoc::Comment
|
125
|
+
text.encode! encoding
|
126
|
+
else
|
127
|
+
# TODO: Remove this condition after Ruby 2.2 EOL
|
128
|
+
if RUBY_VERSION < '2.3.0'
|
129
|
+
text.force_encoding encoding
|
130
|
+
else
|
131
|
+
String.new text, encoding: encoding
|
132
|
+
end
|
133
|
+
end
|
96
134
|
end
|
97
135
|
|
98
136
|
end
|
99
|
-
|