rdoc 3.1 → 6.3.3
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 +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +129 -0
- data/RI.rdoc +57 -0
- data/Rakefile +84 -81
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +11 -2
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +1 -2
- data/lib/rdoc/anon_class.rb +3 -2
- data/lib/rdoc/any_method.rb +234 -40
- data/lib/rdoc/attr.rb +79 -11
- data/lib/rdoc/class_module.rb +443 -71
- data/lib/rdoc/code_object.rb +216 -20
- data/lib/rdoc/code_objects.rb +4 -21
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +110 -9
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +392 -172
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +83 -28
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +507 -84
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +27 -74
- 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 +98 -0
- data/lib/rdoc/generator/ri.rb +8 -62
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- 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/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +24 -13
- data/lib/rdoc/ghost_method.rb +1 -2
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +5 -95
- data/lib/rdoc/known_classes.rb +5 -2
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +416 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16684 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +135 -62
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +96 -9
- data/lib/rdoc/markup/formatter.rb +138 -25
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +61 -2
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +25 -4
- data/lib/rdoc/markup/list_item.rb +18 -4
- data/lib/rdoc/markup/paragraph.rb +15 -0
- data/lib/rdoc/markup/parser.rb +180 -88
- data/lib/rdoc/markup/pre_process.rb +183 -38
- data/lib/rdoc/markup/raw.rb +6 -5
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +17 -7
- data/lib/rdoc/markup/to_bs.rb +5 -8
- data/lib/rdoc/markup/to_html.rb +238 -137
- data/lib/rdoc/markup/to_html_crossref.rb +125 -152
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +85 -15
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +2 -4
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +39 -0
- data/lib/rdoc/markup.rb +388 -110
- data/lib/rdoc/meta_method.rb +1 -2
- data/lib/rdoc/method_attr.rb +87 -21
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +39 -10
- data/lib/rdoc/normal_module.rb +22 -7
- data/lib/rdoc/options.rb +613 -73
- data/lib/rdoc/parser/c.rb +621 -287
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +1368 -762
- data/lib/rdoc/parser/ruby_tools.rb +42 -35
- data/lib/rdoc/parser/simple.rb +23 -11
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +162 -89
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +208 -115
- data/lib/rdoc/require.rb +1 -2
- data/lib/rdoc/ri/driver.rb +734 -239
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +91 -48
- data/lib/rdoc/ri/store.rb +3 -261
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +5 -2
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +14 -2
- data/lib/rdoc/stats/normal.rb +19 -12
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +262 -104
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +84 -44
- data/lib/rdoc/text.rb +117 -72
- data/lib/rdoc/token_stream.rb +73 -4
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +111 -261
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +127 -64
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +171 -291
- data/.autotest +0 -16
- data/.document +0 -5
- data/History.txt +0 -594
- data/LICENSE.txt +0 -57
- data/Manifest.txt +0 -158
- data/README.txt +0 -45
- data/RI.txt +0 -58
- data/bin/ri +0 -5
- data/lib/rdoc/gauntlet.rb +0 -52
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
- data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
- data/lib/rdoc/markup/formatter_test_case.rb +0 -689
- data/lib/rdoc/markup/inline.rb +0 -137
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
- data/lib/rdoc/ruby_lex.rb +0 -1291
- data/lib/rdoc/ruby_token.rb +0 -416
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_attribute_manager.rb +0 -120
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -126
- data/test/test_rdoc_attr.rb +0 -61
- data/test/test_rdoc_class_module.rb +0 -233
- data/test/test_rdoc_code_object.rb +0 -165
- data/test/test_rdoc_constant.rb +0 -15
- data/test/test_rdoc_context.rb +0 -370
- data/test/test_rdoc_encoding.rb +0 -166
- data/test/test_rdoc_generator_darkfish.rb +0 -119
- data/test/test_rdoc_generator_ri.rb +0 -76
- data/test/test_rdoc_include.rb +0 -96
- data/test/test_rdoc_markup.rb +0 -37
- data/test/test_rdoc_markup_attribute_manager.rb +0 -240
- data/test/test_rdoc_markup_document.rb +0 -51
- data/test/test_rdoc_markup_paragraph.rb +0 -9
- data/test/test_rdoc_markup_parser.rb +0 -1395
- data/test/test_rdoc_markup_pre_process.rb +0 -185
- data/test/test_rdoc_markup_raw.rb +0 -27
- data/test/test_rdoc_markup_to_ansi.rb +0 -328
- data/test/test_rdoc_markup_to_bs.rb +0 -341
- data/test/test_rdoc_markup_to_html.rb +0 -335
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
- data/test/test_rdoc_markup_to_rdoc.rb +0 -327
- data/test/test_rdoc_method_attr.rb +0 -122
- data/test/test_rdoc_normal_class.rb +0 -17
- data/test/test_rdoc_normal_module.rb +0 -31
- data/test/test_rdoc_options.rb +0 -342
- data/test/test_rdoc_parser.rb +0 -83
- data/test/test_rdoc_parser_c.rb +0 -912
- data/test/test_rdoc_parser_ruby.rb +0 -1754
- data/test/test_rdoc_parser_simple.rb +0 -99
- data/test/test_rdoc_rdoc.rb +0 -164
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -846
- data/test/test_rdoc_ri_paths.rb +0 -43
- data/test/test_rdoc_ri_store.rb +0 -352
- data/test/test_rdoc_ruby_lex.rb +0 -23
- data/test/test_rdoc_stats.rb +0 -38
- data/test/test_rdoc_task.rb +0 -92
- data/test/test_rdoc_text.rb +0 -251
- data/test/test_rdoc_top_level.rb +0 -120
- data/test/xref_data.rb +0 -62
- data/test/xref_test_case.rb +0 -61
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
data/lib/rdoc/code_object.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'rdoc/text'
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
4
2
|
##
|
5
3
|
# Base class for the RDoc code tree.
|
6
4
|
#
|
@@ -23,8 +21,9 @@ require 'rdoc/text'
|
|
23
21
|
# * RDoc::MetaMethod
|
24
22
|
# * RDoc::Alias
|
25
23
|
# * RDoc::Constant
|
26
|
-
# * RDoc::
|
27
|
-
#
|
24
|
+
# * RDoc::Mixin
|
25
|
+
# * RDoc::Require
|
26
|
+
# * RDoc::Include
|
28
27
|
|
29
28
|
class RDoc::CodeObject
|
30
29
|
|
@@ -60,15 +59,20 @@ class RDoc::CodeObject
|
|
60
59
|
|
61
60
|
attr_reader :force_documentation
|
62
61
|
|
62
|
+
##
|
63
|
+
# Line in #file where this CodeObject was defined
|
64
|
+
|
65
|
+
attr_accessor :line
|
66
|
+
|
63
67
|
##
|
64
68
|
# Hash of arbitrary metadata for this CodeObject
|
65
69
|
|
66
70
|
attr_reader :metadata
|
67
71
|
|
68
72
|
##
|
69
|
-
#
|
73
|
+
# Sets the parent CodeObject
|
70
74
|
|
71
|
-
|
75
|
+
attr_writer :parent
|
72
76
|
|
73
77
|
##
|
74
78
|
# Did we ever receive a +:nodoc:+ directive?
|
@@ -76,9 +80,14 @@ class RDoc::CodeObject
|
|
76
80
|
attr_reader :received_nodoc
|
77
81
|
|
78
82
|
##
|
79
|
-
#
|
83
|
+
# Set the section this CodeObject is in
|
84
|
+
|
85
|
+
attr_writer :section
|
86
|
+
|
87
|
+
##
|
88
|
+
# The RDoc::Store for this object.
|
80
89
|
|
81
|
-
|
90
|
+
attr_reader :store
|
82
91
|
|
83
92
|
##
|
84
93
|
# We are the model of the code, but we know that at some point we will be
|
@@ -91,17 +100,33 @@ class RDoc::CodeObject
|
|
91
100
|
# Creates a new CodeObject that will document itself and its children
|
92
101
|
|
93
102
|
def initialize
|
94
|
-
@metadata
|
95
|
-
@comment
|
96
|
-
@parent
|
97
|
-
@
|
98
|
-
@
|
103
|
+
@metadata = {}
|
104
|
+
@comment = ''
|
105
|
+
@parent = nil
|
106
|
+
@parent_name = nil # for loading
|
107
|
+
@parent_class = nil # for loading
|
108
|
+
@section = nil
|
109
|
+
@section_title = nil # for loading
|
110
|
+
@file = nil
|
111
|
+
@full_name = nil
|
112
|
+
@store = nil
|
113
|
+
@track_visibility = true
|
114
|
+
|
115
|
+
initialize_visibility
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Initializes state for visibility of this CodeObject and its children.
|
99
120
|
|
121
|
+
def initialize_visibility # :nodoc:
|
100
122
|
@document_children = true
|
101
123
|
@document_self = true
|
102
124
|
@done_documenting = false
|
103
125
|
@force_documentation = false
|
104
126
|
@received_nodoc = false
|
127
|
+
@ignored = false
|
128
|
+
@suppressed = false
|
129
|
+
@track_visibility = true
|
105
130
|
end
|
106
131
|
|
107
132
|
##
|
@@ -111,20 +136,42 @@ class RDoc::CodeObject
|
|
111
136
|
@comment = case comment
|
112
137
|
when NilClass then ''
|
113
138
|
when RDoc::Markup::Document then comment
|
139
|
+
when RDoc::Comment then comment.normalize
|
114
140
|
else
|
115
141
|
if comment and not comment.empty? then
|
116
142
|
normalize_comment comment
|
117
143
|
else
|
144
|
+
# HACK correct fix is to have #initialize create @comment
|
145
|
+
# with the correct encoding
|
146
|
+
if String === @comment and @comment.empty? then
|
147
|
+
@comment = RDoc::Encoding.change_encoding @comment, comment.encoding
|
148
|
+
end
|
118
149
|
@comment
|
119
150
|
end
|
120
151
|
end
|
121
152
|
end
|
122
153
|
|
154
|
+
##
|
155
|
+
# Should this CodeObject be displayed in output?
|
156
|
+
#
|
157
|
+
# A code object should be displayed if:
|
158
|
+
#
|
159
|
+
# * The item didn't have a nodoc or wasn't in a container that had nodoc
|
160
|
+
# * The item wasn't ignored
|
161
|
+
# * The item has documentation and was not suppressed
|
162
|
+
|
163
|
+
def display?
|
164
|
+
@document_self and not @ignored and
|
165
|
+
(documented? or not @suppressed)
|
166
|
+
end
|
167
|
+
|
123
168
|
##
|
124
169
|
# Enables or disables documentation of this CodeObject's children unless it
|
125
170
|
# has been turned off by :enddoc:
|
126
171
|
|
127
172
|
def document_children=(document_children)
|
173
|
+
return unless @track_visibility
|
174
|
+
|
128
175
|
@document_children = document_children unless @done_documenting
|
129
176
|
end
|
130
177
|
|
@@ -134,6 +181,7 @@ class RDoc::CodeObject
|
|
134
181
|
# documentation is turned off by +:nodoc:+.
|
135
182
|
|
136
183
|
def document_self=(document_self)
|
184
|
+
return unless @track_visibility
|
137
185
|
return if @done_documenting
|
138
186
|
|
139
187
|
@document_self = document_self
|
@@ -157,14 +205,40 @@ class RDoc::CodeObject
|
|
157
205
|
# will have no effect in the current file.
|
158
206
|
|
159
207
|
def done_documenting=(value)
|
160
|
-
|
161
|
-
@
|
208
|
+
return unless @track_visibility
|
209
|
+
@done_documenting = value
|
210
|
+
@document_self = !value
|
162
211
|
@document_children = @document_self
|
163
212
|
end
|
164
213
|
|
214
|
+
##
|
215
|
+
# Yields each parent of this CodeObject. See also
|
216
|
+
# RDoc::ClassModule#each_ancestor
|
217
|
+
|
218
|
+
def each_parent
|
219
|
+
code_object = self
|
220
|
+
|
221
|
+
while code_object = code_object.parent do
|
222
|
+
yield code_object
|
223
|
+
end
|
224
|
+
|
225
|
+
self
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# File name where this CodeObject was found.
|
230
|
+
#
|
231
|
+
# See also RDoc::Context#in_files
|
232
|
+
|
233
|
+
def file_name
|
234
|
+
return unless @file
|
235
|
+
|
236
|
+
@file.absolute_name
|
237
|
+
end
|
238
|
+
|
165
239
|
##
|
166
240
|
# Force the documentation of this object unless documentation
|
167
|
-
# has been turned off by :
|
241
|
+
# has been turned off by :enddoc:
|
168
242
|
#--
|
169
243
|
# HACK untested, was assigning to an ivar
|
170
244
|
|
@@ -181,6 +255,76 @@ class RDoc::CodeObject
|
|
181
255
|
@full_name = full_name
|
182
256
|
end
|
183
257
|
|
258
|
+
##
|
259
|
+
# Use this to ignore a CodeObject and all its children until found again
|
260
|
+
# (#record_location is called). An ignored item will not be displayed in
|
261
|
+
# documentation.
|
262
|
+
#
|
263
|
+
# See github issue #55
|
264
|
+
#
|
265
|
+
# The ignored status is temporary in order to allow implementation details
|
266
|
+
# to be hidden. At the end of processing a file RDoc allows all classes
|
267
|
+
# and modules to add new documentation to previously created classes.
|
268
|
+
#
|
269
|
+
# If a class was ignored (via stopdoc) then reopened later with additional
|
270
|
+
# documentation it should be displayed. If a class was ignored and never
|
271
|
+
# reopened it should not be displayed. The ignore flag allows this to
|
272
|
+
# occur.
|
273
|
+
|
274
|
+
def ignore
|
275
|
+
return unless @track_visibility
|
276
|
+
|
277
|
+
@ignored = true
|
278
|
+
|
279
|
+
stop_doc
|
280
|
+
end
|
281
|
+
|
282
|
+
##
|
283
|
+
# Has this class been ignored?
|
284
|
+
#
|
285
|
+
# See also #ignore
|
286
|
+
|
287
|
+
def ignored?
|
288
|
+
@ignored
|
289
|
+
end
|
290
|
+
|
291
|
+
##
|
292
|
+
# The options instance from the store this CodeObject is attached to, or a
|
293
|
+
# default options instance if the CodeObject is not attached.
|
294
|
+
#
|
295
|
+
# This is used by Text#snippet
|
296
|
+
|
297
|
+
def options
|
298
|
+
if @store and @store.rdoc then
|
299
|
+
@store.rdoc.options
|
300
|
+
else
|
301
|
+
RDoc::Options.new
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# Our parent CodeObject. The parent may be missing for classes loaded from
|
307
|
+
# legacy RI data stores.
|
308
|
+
|
309
|
+
def parent
|
310
|
+
return @parent if @parent
|
311
|
+
return nil unless @parent_name
|
312
|
+
|
313
|
+
if @parent_class == RDoc::TopLevel then
|
314
|
+
@parent = @store.add_file @parent_name
|
315
|
+
else
|
316
|
+
@parent = @store.find_class_or_module @parent_name
|
317
|
+
|
318
|
+
return @parent if @parent
|
319
|
+
|
320
|
+
begin
|
321
|
+
@parent = @store.load_class @parent_name
|
322
|
+
rescue RDoc::Store::MissingFileError
|
323
|
+
nil
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
184
328
|
##
|
185
329
|
# File name of our parent
|
186
330
|
|
@@ -199,27 +343,79 @@ class RDoc::CodeObject
|
|
199
343
|
# Records the RDoc::TopLevel (file) where this code object was defined
|
200
344
|
|
201
345
|
def record_location top_level
|
202
|
-
@
|
346
|
+
@ignored = false
|
347
|
+
@suppressed = false
|
348
|
+
@file = top_level
|
349
|
+
end
|
350
|
+
|
351
|
+
##
|
352
|
+
# The section this CodeObject is in. Sections allow grouping of constants,
|
353
|
+
# attributes and methods inside a class or module.
|
354
|
+
|
355
|
+
def section
|
356
|
+
return @section if @section
|
357
|
+
|
358
|
+
@section = parent.add_section @section_title if parent
|
203
359
|
end
|
204
360
|
|
205
361
|
##
|
206
362
|
# Enable capture of documentation unless documentation has been
|
207
|
-
# turned off by :
|
363
|
+
# turned off by :enddoc:
|
208
364
|
|
209
365
|
def start_doc
|
210
366
|
return if @done_documenting
|
211
367
|
|
212
368
|
@document_self = true
|
213
369
|
@document_children = true
|
370
|
+
@ignored = false
|
371
|
+
@suppressed = false
|
214
372
|
end
|
215
373
|
|
216
374
|
##
|
217
375
|
# Disable capture of documentation
|
218
376
|
|
219
377
|
def stop_doc
|
378
|
+
return unless @track_visibility
|
379
|
+
|
220
380
|
@document_self = false
|
221
381
|
@document_children = false
|
222
382
|
end
|
223
383
|
|
224
|
-
|
384
|
+
##
|
385
|
+
# Sets the +store+ that contains this CodeObject
|
386
|
+
|
387
|
+
def store= store
|
388
|
+
@store = store
|
389
|
+
|
390
|
+
return unless @track_visibility
|
391
|
+
|
392
|
+
if :nodoc == options.visibility then
|
393
|
+
initialize_visibility
|
394
|
+
@track_visibility = false
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
##
|
399
|
+
# Use this to suppress a CodeObject and all its children until the next file
|
400
|
+
# it is seen in or documentation is discovered. A suppressed item with
|
401
|
+
# documentation will be displayed while an ignored item with documentation
|
402
|
+
# may not be displayed.
|
403
|
+
|
404
|
+
def suppress
|
405
|
+
return unless @track_visibility
|
225
406
|
|
407
|
+
@suppressed = true
|
408
|
+
|
409
|
+
stop_doc
|
410
|
+
end
|
411
|
+
|
412
|
+
##
|
413
|
+
# Has this class been suppressed?
|
414
|
+
#
|
415
|
+
# See also #suppress
|
416
|
+
|
417
|
+
def suppressed?
|
418
|
+
@suppressed
|
419
|
+
end
|
420
|
+
|
421
|
+
end
|
data/lib/rdoc/code_objects.rb
CHANGED
@@ -1,23 +1,6 @@
|
|
1
|
-
#
|
2
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# This file was used to load all the RDoc::CodeObject subclasses at once. Now
|
3
|
+
# autoload handles this.
|
3
4
|
|
4
|
-
require 'rdoc
|
5
|
-
require 'rdoc/context'
|
6
|
-
require 'rdoc/top_level'
|
7
|
-
|
8
|
-
require 'rdoc/class_module'
|
9
|
-
require 'rdoc/normal_class'
|
10
|
-
require 'rdoc/normal_module'
|
11
|
-
require 'rdoc/anon_class'
|
12
|
-
require 'rdoc/single_class'
|
13
|
-
|
14
|
-
require 'rdoc/any_method'
|
15
|
-
require 'rdoc/alias'
|
16
|
-
require 'rdoc/ghost_method'
|
17
|
-
require 'rdoc/meta_method'
|
18
|
-
|
19
|
-
require 'rdoc/attr'
|
20
|
-
require 'rdoc/constant'
|
21
|
-
require 'rdoc/require'
|
22
|
-
require 'rdoc/include'
|
5
|
+
require 'rdoc'
|
23
6
|
|
data/lib/rdoc/comment.rb
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# A comment holds the text comment for a RDoc::CodeObject and provides a
|
4
|
+
# unified way of cleaning it up and parsing it into an RDoc::Markup::Document.
|
5
|
+
#
|
6
|
+
# Each comment may have a different markup format set by #format=. By default
|
7
|
+
# 'rdoc' is used. The :markup: directive tells RDoc which format to use.
|
8
|
+
#
|
9
|
+
# See RDoc::Markup@Other+directives for instructions on adding an alternate
|
10
|
+
# format.
|
11
|
+
|
12
|
+
class RDoc::Comment
|
13
|
+
|
14
|
+
include RDoc::Text
|
15
|
+
|
16
|
+
##
|
17
|
+
# The format of this comment. Defaults to RDoc::Markup
|
18
|
+
|
19
|
+
attr_reader :format
|
20
|
+
|
21
|
+
##
|
22
|
+
# The RDoc::TopLevel this comment was found in
|
23
|
+
|
24
|
+
attr_accessor :location
|
25
|
+
|
26
|
+
##
|
27
|
+
# Line where this Comment was written
|
28
|
+
|
29
|
+
attr_accessor :line
|
30
|
+
|
31
|
+
##
|
32
|
+
# For duck-typing when merging classes at load time
|
33
|
+
|
34
|
+
alias file location # :nodoc:
|
35
|
+
|
36
|
+
##
|
37
|
+
# The text for this comment
|
38
|
+
|
39
|
+
attr_reader :text
|
40
|
+
|
41
|
+
##
|
42
|
+
# Alias for text
|
43
|
+
|
44
|
+
alias to_s text
|
45
|
+
|
46
|
+
##
|
47
|
+
# Overrides the content returned by #parse. Use when there is no #text
|
48
|
+
# source for this comment
|
49
|
+
|
50
|
+
attr_writer :document
|
51
|
+
|
52
|
+
##
|
53
|
+
# Creates a new comment with +text+ that is found in the RDoc::TopLevel
|
54
|
+
# +location+.
|
55
|
+
|
56
|
+
def initialize text = nil, location = nil, language = nil
|
57
|
+
@location = location
|
58
|
+
@text = text.nil? ? nil : text.dup
|
59
|
+
@language = language
|
60
|
+
|
61
|
+
@document = nil
|
62
|
+
@format = 'rdoc'
|
63
|
+
@normalized = false
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
#--
|
68
|
+
# TODO deep copy @document
|
69
|
+
|
70
|
+
def initialize_copy copy # :nodoc:
|
71
|
+
@text = copy.text.dup
|
72
|
+
end
|
73
|
+
|
74
|
+
def == other # :nodoc:
|
75
|
+
self.class === other and
|
76
|
+
other.text == @text and other.location == @location
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Look for a 'call-seq' in the comment to override the normal parameter
|
81
|
+
# handling. The :call-seq: is indented from the baseline. All lines of the
|
82
|
+
# same indentation level and prefix are consumed.
|
83
|
+
#
|
84
|
+
# For example, all of the following will be used as the :call-seq:
|
85
|
+
#
|
86
|
+
# # :call-seq:
|
87
|
+
# # ARGF.readlines(sep=$/) -> array
|
88
|
+
# # ARGF.readlines(limit) -> array
|
89
|
+
# # ARGF.readlines(sep, limit) -> array
|
90
|
+
# #
|
91
|
+
# # ARGF.to_a(sep=$/) -> array
|
92
|
+
# # ARGF.to_a(limit) -> array
|
93
|
+
# # ARGF.to_a(sep, limit) -> array
|
94
|
+
|
95
|
+
def extract_call_seq method
|
96
|
+
# we must handle situations like the above followed by an unindented first
|
97
|
+
# comment. The difficulty is to make sure not to match lines starting
|
98
|
+
# with ARGF at the same indent, but that are after the first description
|
99
|
+
# paragraph.
|
100
|
+
if @text =~ /^\s*:?call-seq:(.*?(?:\S).*?)^\s*$/m then
|
101
|
+
all_start, all_stop = $~.offset(0)
|
102
|
+
seq_start, seq_stop = $~.offset(1)
|
103
|
+
|
104
|
+
# we get the following lines that start with the leading word at the
|
105
|
+
# same indent, even if they have blank lines before
|
106
|
+
if $1 =~ /(^\s*\n)+^(\s*\w+)/m then
|
107
|
+
leading = $2 # ' * ARGF' in the example above
|
108
|
+
re = %r%
|
109
|
+
\A(
|
110
|
+
(^\s*\n)+
|
111
|
+
(^#{Regexp.escape leading}.*?\n)+
|
112
|
+
)+
|
113
|
+
^\s*$
|
114
|
+
%xm
|
115
|
+
|
116
|
+
if @text[seq_stop..-1] =~ re then
|
117
|
+
all_stop = seq_stop + $~.offset(0).last
|
118
|
+
seq_stop = seq_stop + $~.offset(1).last
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
seq = @text[seq_start..seq_stop]
|
123
|
+
seq.gsub!(/^\s*(\S|\n)/m, '\1')
|
124
|
+
@text.slice! all_start...all_stop
|
125
|
+
|
126
|
+
method.call_seq = seq.chomp
|
127
|
+
|
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
|
136
|
+
end
|
137
|
+
|
138
|
+
method
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# A comment is empty if its text String is empty.
|
143
|
+
|
144
|
+
def empty?
|
145
|
+
@text.empty?
|
146
|
+
end
|
147
|
+
|
148
|
+
##
|
149
|
+
# HACK dubious
|
150
|
+
|
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
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Sets the format of this comment and resets any parsed document
|
163
|
+
|
164
|
+
def format= format
|
165
|
+
@format = format
|
166
|
+
@document = nil
|
167
|
+
end
|
168
|
+
|
169
|
+
def inspect # :nodoc:
|
170
|
+
location = @location ? @location.relative_name : '(unknown)'
|
171
|
+
|
172
|
+
"#<%s:%x %s %p>" % [self.class, object_id, location, @text]
|
173
|
+
end
|
174
|
+
|
175
|
+
##
|
176
|
+
# Normalizes the text. See RDoc::Text#normalize_comment for details
|
177
|
+
|
178
|
+
def normalize
|
179
|
+
return self unless @text
|
180
|
+
return self if @normalized # TODO eliminate duplicate normalization
|
181
|
+
|
182
|
+
@text = normalize_comment @text
|
183
|
+
|
184
|
+
@normalized = true
|
185
|
+
|
186
|
+
self
|
187
|
+
end
|
188
|
+
|
189
|
+
##
|
190
|
+
# Was this text normalized?
|
191
|
+
|
192
|
+
def normalized? # :nodoc:
|
193
|
+
@normalized
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# Parses the comment into an RDoc::Markup::Document. The parsed document is
|
198
|
+
# cached until the text is changed.
|
199
|
+
|
200
|
+
def parse
|
201
|
+
return @document if @document
|
202
|
+
|
203
|
+
@document = super @text, @format
|
204
|
+
@document.file = @location
|
205
|
+
@document
|
206
|
+
end
|
207
|
+
|
208
|
+
##
|
209
|
+
# Removes private sections from this comment. Private sections are flush to
|
210
|
+
# the comment marker and start with <tt>--</tt> and end with <tt>++</tt>.
|
211
|
+
# For C-style comments, a private marker may not start at the opening of the
|
212
|
+
# comment.
|
213
|
+
#
|
214
|
+
# /*
|
215
|
+
# *--
|
216
|
+
# * private
|
217
|
+
# *++
|
218
|
+
# * public
|
219
|
+
# */
|
220
|
+
|
221
|
+
def remove_private
|
222
|
+
# Workaround for gsub encoding for Ruby 1.9.2 and earlier
|
223
|
+
empty = ''
|
224
|
+
empty = RDoc::Encoding.change_encoding empty, @text.encoding
|
225
|
+
|
226
|
+
@text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
|
227
|
+
@text = @text.sub(%r%^\s*[#*]?--.*%m, '')
|
228
|
+
end
|
229
|
+
|
230
|
+
##
|
231
|
+
# Replaces this comment's text with +text+ and resets the parsed document.
|
232
|
+
#
|
233
|
+
# An error is raised if the comment contains a document but no text.
|
234
|
+
|
235
|
+
def text= text
|
236
|
+
raise RDoc::Error, 'replacing document-only comment is not allowed' if
|
237
|
+
@text.nil? and @document
|
238
|
+
|
239
|
+
@document = nil
|
240
|
+
@text = text.nil? ? nil : text.dup
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# Returns true if this comment is in TomDoc format.
|
245
|
+
|
246
|
+
def tomdoc?
|
247
|
+
@format == 'tomdoc'
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|