rdoc 3.8 → 3.9

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.

data.tar.gz.sig CHANGED
Binary file
@@ -1,4 +1,24 @@
1
- === 3.8 / ??
1
+ === 3.9 / 2011-07-30
2
+
3
+ * Minor enhancements
4
+ * RDoc::Parser::C now supports :doc: and :nodoc: for class comments
5
+ * Added the <tt>rdoc-ref:</tt> link scheme which links to a named reference.
6
+ <tt>rdoc-ref:</tt> can resolve references to classes, modules, methods,
7
+ files, etc. This can be used to create cross-generator named links unlike
8
+ the <tt>link:</tt> scheme which is dependent upon the exact file name.
9
+ Issue #53 by Simon Chiang
10
+ * Pulled RDoc::CrossReference out of RDoc::Markup::ToHtmlCrossref.
11
+ Cross-references can now be created easily for non-HTML formatters.
12
+ * Bug fixes
13
+ * `ri []` and other special methods now work properly. Issue #52 by
14
+ ddebernardy.
15
+ * `ri` now has space between class comments from multiple files.
16
+ * :stopdoc: no longer creates Object references. Issue #55 by Simon Chiang
17
+ * :nodoc: works on class aliases now. Issue #51 by Steven G. Harms
18
+ * Remove tokenizer restriction on header lengths for verbatim sections.
19
+ Issue #49 by trans
20
+
21
+ === 3.8 / 2011-06-29
2
22
 
3
23
  * Minor enhancements
4
24
  * RDoc::Parser::C can now discover methods on ENV and ARGF.
@@ -18,6 +18,7 @@ lib/rdoc/code_object.rb
18
18
  lib/rdoc/code_objects.rb
19
19
  lib/rdoc/constant.rb
20
20
  lib/rdoc/context.rb
21
+ lib/rdoc/cross_reference.rb
21
22
  lib/rdoc/encoding.rb
22
23
  lib/rdoc/erbio.rb
23
24
  lib/rdoc/gauntlet.rb
@@ -127,6 +128,7 @@ test/test_rdoc_code_object.rb
127
128
  test/test_rdoc_constant.rb
128
129
  test/test_rdoc_context.rb
129
130
  test/test_rdoc_context_section.rb
131
+ test/test_rdoc_cross_reference.rb
130
132
  test/test_rdoc_encoding.rb
131
133
  test/test_rdoc_generator_darkfish.rb
132
134
  test/test_rdoc_generator_ri.rb
data/Rakefile CHANGED
@@ -19,13 +19,27 @@ Hoe.spec 'rdoc' do
19
19
  rdoc_locations << 'docs.seattlerb.org:/data/www/docs.seattlerb.org/rdoc/'
20
20
  rdoc_locations << 'drbrain@rubyforge.org:/var/www/gforge-projects/rdoc/'
21
21
 
22
+
23
+ spec_extras[:post_install_message] = <<-MESSAGE
24
+ Depending on your version of ruby, you may need to install ruby rdoc/ri data:
25
+
26
+ <= 1.8.6 : unsupported
27
+ = 1.8.7 : gem install rdoc-data; rdoc-data --install
28
+ = 1.9.1 : gem install rdoc-data; rdoc-data --install
29
+ >= 1.9.2 : nothing to do! Yay!
30
+ MESSAGE
31
+
22
32
  self.testlib = :minitest
23
- self.isolate_dir = 'tmp/isolate'
33
+ if respond_to? :isolate_dir= then # HACK Hoe issue #7
34
+ self.isolate_dir = 'tmp/isolate'
35
+ else
36
+ warn 'please: gem install isolate'
37
+ end
24
38
 
25
39
  require_ruby_version '>= 1.8.7'
26
- extra_dev_deps << ['minitest', '~> 2']
27
- extra_dev_deps << ['isolate', '~> 3']
28
- extra_dev_deps << ['ZenTest', '~> 4'] # for autotest/isolate
40
+ extra_dev_deps << ['minitest', '~> 2']
41
+ extra_dev_deps << ['isolate', '~> 3']
42
+ extra_dev_deps << ['ZenTest', '~> 4'] # for autotest/isolate
29
43
 
30
44
  extra_rdoc_files << 'Rakefile'
31
45
  spec_extras['required_rubygems_version'] = '>= 1.3'
data/bin/rdoc CHANGED
@@ -8,6 +8,13 @@
8
8
  #
9
9
  # $Revision: 15033 $
10
10
 
11
+ begin
12
+ gem 'rdoc'
13
+ rescue NameError => e # --disable-gems
14
+ raise unless e.name == :gem
15
+ rescue Gem::LoadError
16
+ end
17
+
11
18
  require 'rdoc/rdoc'
12
19
 
13
20
  begin
data/bin/ri CHANGED
@@ -1,5 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ begin
4
+ gem 'rdoc'
5
+ rescue NameError => e # --disable-gems
6
+ raise unless e.name == :gem
7
+ rescue Gem::LoadError
8
+ end
9
+
3
10
  require 'rdoc/ri/driver'
4
11
 
5
12
  RDoc::RI::Driver.run ARGV
@@ -104,7 +104,7 @@ module RDoc
104
104
  ##
105
105
  # RDoc version you are using
106
106
 
107
- VERSION = '3.8'
107
+ VERSION = '3.9'
108
108
 
109
109
  ##
110
110
  # Method visibilities
@@ -222,6 +222,9 @@ class RDoc::ClassModule < RDoc::Context
222
222
  end
223
223
  end
224
224
 
225
+ ##
226
+ # TODO: filter included items by #display?
227
+
225
228
  def marshal_dump # :nodoc:
226
229
  attrs = attributes.sort.map do |attr|
227
230
  [ attr.name, attr.rw,
@@ -114,6 +114,7 @@ class RDoc::CodeObject
114
114
  @done_documenting = false
115
115
  @force_documentation = false
116
116
  @received_nodoc = false
117
+ @ignored = false
117
118
  end
118
119
 
119
120
  ##
@@ -139,6 +140,13 @@ class RDoc::CodeObject
139
140
  end
140
141
  end
141
142
 
143
+ ##
144
+ # Should this CodeObject be shown in documentation?
145
+
146
+ def display?
147
+ @document_self and not @ignored
148
+ end
149
+
142
150
  ##
143
151
  # Enables or disables documentation of this CodeObject's children unless it
144
152
  # has been turned off by :enddoc:
@@ -195,6 +203,11 @@ class RDoc::CodeObject
195
203
  self
196
204
  end
197
205
 
206
+ ##
207
+ # File name where this CodeObject was found.
208
+ #
209
+ # See also RDoc::Context#in_files
210
+
198
211
  def file_name
199
212
  return unless @file
200
213
 
@@ -220,6 +233,34 @@ class RDoc::CodeObject
220
233
  @full_name = full_name
221
234
  end
222
235
 
236
+ ##
237
+ # Use this to ignore a CodeObject and all its children until found again
238
+ # (#record_location is called). An ignored item will not be shown in
239
+ # documentation.
240
+ #
241
+ # See github issue #55
242
+ #
243
+ # The ignored status is temporary in order to allow implementation details
244
+ # to be hidden. At the end of processing a file RDoc allows all classes
245
+ # and modules to add new documentation to previously created classes.
246
+ #
247
+ # If a class was ignored (via stopdoc) then reopened later with additional
248
+ # documentation it should be shown. If a class was ignored and never
249
+ # reopened it should not be shown. The ignore flag allows this to occur.
250
+
251
+ def ignore
252
+ @ignored = true
253
+
254
+ stop_doc
255
+ end
256
+
257
+ ##
258
+ # Has this class been ignored?
259
+
260
+ def ignored?
261
+ @ignored
262
+ end
263
+
223
264
  ##
224
265
  # File name of our parent
225
266
 
@@ -238,6 +279,7 @@ class RDoc::CodeObject
238
279
  # Records the RDoc::TopLevel (file) where this code object was defined
239
280
 
240
281
  def record_location top_level
282
+ @ignored = false
241
283
  @file = top_level
242
284
  end
243
285
 
@@ -250,6 +292,7 @@ class RDoc::CodeObject
250
292
 
251
293
  @document_self = true
252
294
  @document_children = true
295
+ @ignored = false
253
296
  end
254
297
 
255
298
  ##
@@ -423,6 +423,7 @@ class RDoc::Context < RDoc::CodeObject
423
423
  if klass then
424
424
  # if TopLevel, it may not be registered in the classes:
425
425
  enclosing.classes_hash[name] = klass
426
+
426
427
  # update the superclass if needed
427
428
  if superclass then
428
429
  existing = klass.superclass
@@ -623,8 +624,10 @@ class RDoc::Context < RDoc::CodeObject
623
624
 
624
625
  ##
625
626
  # Is there any content?
626
- # This means any of: comment, aliases, methods, attributes,
627
- # external aliases, require, constant.
627
+ #
628
+ # This means any of: comment, aliases, methods, attributes, external
629
+ # aliases, require, constant.
630
+ #
628
631
  # Includes are also checked unless <tt>includes == false</tt>.
629
632
 
630
633
  def any_content(includes = true)
@@ -0,0 +1,173 @@
1
+ ##
2
+ # RDoc::CrossReference is a reusable way to create cross references for names.
3
+
4
+ class RDoc::CrossReference
5
+
6
+ ##
7
+ # Regular expression to match class references
8
+ #
9
+ # 1. There can be a '\\' in front of text to suppress the cross-reference
10
+ # 2. There can be a '::' in front of class names to reference from the
11
+ # top-level namespace.
12
+ # 3. The method can be followed by parenthesis (not recommended)
13
+
14
+ CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)'
15
+
16
+ ##
17
+ # Regular expression to match method references.
18
+ #
19
+ # See CLASS_REGEXP_STR
20
+
21
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?)(?:\([\w.+*/=<>-]*\))?'
22
+
23
+ ##
24
+ # Regular expressions matching text that should potentially have
25
+ # cross-reference links generated are passed to add_special. Note that
26
+ # these expressions are meant to pick up text for which cross-references
27
+ # have been suppressed, since the suppression characters are removed by the
28
+ # code that is triggered.
29
+
30
+ CROSSREF_REGEXP = /(
31
+ # A::B::C.meth
32
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
33
+
34
+ # Stand-alone method (preceded by a #)
35
+ | \\?\##{METHOD_REGEXP_STR}
36
+
37
+ # Stand-alone method (preceded by ::)
38
+ | ::#{METHOD_REGEXP_STR}
39
+
40
+ # A::B::C
41
+ # The stuff after CLASS_REGEXP_STR is a
42
+ # nasty hack. CLASS_REGEXP_STR unfortunately matches
43
+ # words like dog and cat (these are legal "class"
44
+ # names in Fortran 95). When a word is flagged as a
45
+ # potential cross-reference, limitations in the markup
46
+ # engine suppress other processing, such as typesetting.
47
+ # This is particularly noticeable for contractions.
48
+ # In order that words like "can't" not
49
+ # be flagged as potential cross-references, only
50
+ # flag potential class cross-references if the character
51
+ # after the cross-reference is a space, sentence
52
+ # punctuation, tag start character, or attribute
53
+ # marker.
54
+ | #{CLASS_REGEXP_STR}(?=[\s\)\.\?\!\,\;<\000]|\z)
55
+
56
+ # Things that look like filenames
57
+ # The key thing is that there must be at least
58
+ # one special character (period, slash, or
59
+ # underscore).
60
+ | (?:\.\.\/)*[-\/\w]+[_\/\.][-\w\/\.]+
61
+
62
+ # Things that have markup suppressed
63
+ # Don't process things like '\<' in \<tt>, though.
64
+ # TODO: including < is a hack, not very satisfying.
65
+ | \\[^\s<]
66
+ )/x
67
+
68
+ ##
69
+ # Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
70
+
71
+ ALL_CROSSREF_REGEXP = /(
72
+ # A::B::C.meth
73
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
74
+
75
+ # Stand-alone method
76
+ | \\?#{METHOD_REGEXP_STR}
77
+
78
+ # A::B::C
79
+ | #{CLASS_REGEXP_STR}(?=[\s\)\.\?\!\,\;<\000]|\z)
80
+
81
+ # Things that look like filenames
82
+ | (?:\.\.\/)*[-\/\w]+[_\/\.][-\w\/\.]+
83
+
84
+ # Things that have markup suppressed
85
+ | \\[^\s<]
86
+ )/x
87
+
88
+ attr_accessor :seen
89
+
90
+ ##
91
+ # Allows cross-references to be created based on the given +context+
92
+ # (RDoc::Context).
93
+
94
+ def initialize context
95
+ @context = context
96
+
97
+ @seen = {}
98
+ end
99
+
100
+ ##
101
+ # Returns a reference to +name+.
102
+ #
103
+ # If the reference is found and +name+ is not documented +text+ will be
104
+ # returned. If +name+ is escaped +name+ is returned. If +name+ is not
105
+ # found +text+ is returned.
106
+
107
+ def resolve name, text
108
+ return @seen[name] if @seen.include? name
109
+
110
+ # Find class, module, or method in class or module.
111
+ #
112
+ # Do not, however, use an if/elsif/else chain to do so. Instead, test
113
+ # each possible pattern until one matches. The reason for this is that a
114
+ # string like "YAML.txt" could be the txt() class method of class YAML (in
115
+ # which case it would match the first pattern, which splits the string
116
+ # into container and method components and looks up both) or a filename
117
+ # (in which case it would match the last pattern, which just checks
118
+ # whether the string as a whole is a known symbol).
119
+
120
+ if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
121
+ type = $2
122
+ type = '' if type == '.' # will find either #method or ::method
123
+ method = "#{type}#{$3}"
124
+ container = @context.find_symbol_module($1)
125
+ elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
126
+ type = $1
127
+ type = '' if type == '.'
128
+ method = "#{type}#{$2}"
129
+ container = @context
130
+ else
131
+ container = nil
132
+ end
133
+
134
+ if container then
135
+ ref = container.find_local_symbol method
136
+
137
+ unless ref || RDoc::TopLevel === container then
138
+ ref = container.find_ancestor_local_symbol method
139
+ end
140
+ end
141
+
142
+ ref = case name
143
+ when /^\\(#{CLASS_REGEXP_STR})$/o then
144
+ ref = @context.find_symbol $1
145
+ else
146
+ ref = @context.find_symbol name
147
+ end unless ref
148
+
149
+ ref = nil if RDoc::Alias === ref # external alias: can't link to it
150
+
151
+ out = if name == '\\' then
152
+ name
153
+ elsif name =~ /^\\/ then
154
+ # we remove the \ only in front of what we know:
155
+ # other backslashes are treated later, only outside of <tt>
156
+ ref ? $' : name
157
+ elsif ref then
158
+ if ref.display? then
159
+ ref
160
+ else
161
+ text
162
+ end
163
+ else
164
+ text
165
+ end
166
+
167
+ @seen[name] = out
168
+
169
+ out
170
+ end
171
+
172
+ end
173
+
@@ -192,7 +192,7 @@ class RDoc::Generator::Darkfish
192
192
  top_level = klass.full_name.gsub( /::.*/, '' )
193
193
  [nscounts[top_level] * -1, klass.full_name]
194
194
  end.select do |klass|
195
- klass.document_self
195
+ klass.display?
196
196
  end
197
197
  end
198
198
 
@@ -176,6 +176,8 @@
176
176
  </div><!-- description -->
177
177
 
178
178
  <% klass.each_section do |section, constants, attributes| %>
179
+ <% constants = constants.select { |const| const.display? } %>
180
+ <% attributes = attributes.select { |attr| attr.display? } %>
179
181
  <div id="<%= section.aref %>" class="documentation-section">
180
182
  <% if section.title then %>
181
183
  <h2 class="section-header">
@@ -269,40 +269,43 @@ require 'rdoc'
269
269
  # preceding the first character with a backslash (see <i>Escaping
270
270
  # Text Markup</i>, below).
271
271
  #
272
- # === Hyperlinks
272
+ # === Links
273
273
  #
274
- # Hyperlinks to the web starting with +http:+, +mailto:+, +ftp:+ or +www.+
274
+ # Links to starting with +http:+, +https:+, +mailto:+, +ftp:+ or +www.+
275
275
  # are recognized. An HTTP url that references an external image file is
276
- # converted into an inline <img...>. Hyperlinks starting with +link:+ are
277
- # assumed to refer to local files whose path is relative to the <tt>--op</tt>
278
- # directory.
276
+ # converted into an inline image element.
279
277
  #
280
- # Hyperlinks can also be of the form _label_[_url_], in which
281
- # case _label_ is used in the displayed text, and _url_ is
282
- # used as the target. If _label_ contains multiple words,
283
- # put it in braces: {<em>multi word label</em>}[url].
278
+ # Links starting with <tt>rdoc-ref:</tt> will link to the referenced class,
279
+ # module, method, file, etc. If the referenced item is not documented the
280
+ # text will be and no link will be generated.
284
281
  #
285
- # Example hyperlinks:
282
+ # Links starting with +link:+ refer to local files whose path is relative to
283
+ # the <tt>--op</tt> directory.
286
284
  #
287
- # link:RDoc.html
288
- # http://rdoc.rubyforge.org
285
+ # Links can also be of the form <tt>label[url]</tt>, in which case +label+ is
286
+ # used in the displayed text, and +url+ is used as the target. If +label+
287
+ # contains multiple words, put it in braces: <tt>{multi word label}[url]<tt>.
288
+ #
289
+ # Example links:
290
+ #
291
+ # https://github.com/rdoc/rdoc
289
292
  # mailto:user@example.com
290
293
  # {RDoc Documentation}[http://rdoc.rubyforge.org]
291
- # {RDoc Markup}[link:RDoc/Markup.html]
294
+ # {RDoc Markup}[rdoc-ref:RDoc::Markup]
292
295
  #
293
296
  # === Escaping Text Markup
294
297
  #
295
298
  # Text markup can be escaped with a backslash, as in \<tt>, which was obtained
296
- # with "<tt>\\<tt></tt>". Except in verbatim sections and between \<tt> tags,
297
- # to produce a backslash, you have to double it unless it is followed by a
299
+ # with <tt>\\<tt></tt>. Except in verbatim sections and between \<tt> tags,
300
+ # to produce a backslash you have to double it unless it is followed by a
298
301
  # space, tab or newline. Otherwise, the HTML formatter will discard it, as it
299
- # is used to escape potential hyperlinks:
302
+ # is used to escape potential links:
300
303
  #
301
304
  # * The \ must be doubled if not followed by white space: \\.
302
305
  # * But not in \<tt> tags: in a Regexp, <tt>\S</tt> matches non-space.
303
306
  # * This is a link to {ruby-lang}[www.ruby-lang.org].
304
307
  # * This is not a link, however: \{ruby-lang.org}[www.ruby-lang.org].
305
- # * This will not be hyperlinked to \RDoc::RDoc#document
308
+ # * This will not be linked to \RDoc::RDoc#document
306
309
  #
307
310
  # generates:
308
311
  #
@@ -310,16 +313,16 @@ require 'rdoc'
310
313
  # * But not in \<tt> tags: in a Regexp, <tt>\S</tt> matches non-space.
311
314
  # * This is a link to {ruby-lang}[www.ruby-lang.org]
312
315
  # * This is not a link, however: \{ruby-lang.org}[www.ruby-lang.org]
313
- # * This will not be hyperlinked to \RDoc::RDoc#document
316
+ # * This will not be linked to \RDoc::RDoc#document
314
317
  #
315
- # Inside \<tt> tags, more precisely, leading backslashes are removed
316
- # only if followed by a markup character (<tt><*_+</tt>), a backslash,
317
- # or a known hyperlink reference (a known class or method). So in the
318
- # example above, the backslash of <tt>\S</tt> would be removed
319
- # if there was a class or module named +S+ in the current context.
318
+ # Inside \<tt> tags, more precisely, leading backslashes are removed only if
319
+ # followed by a markup character (<tt><*_+</tt>), a backslash, or a known link
320
+ # reference (a known class or method). So in the example above, the backslash
321
+ # of <tt>\S</tt> would be removed if there was a class or module named +S+ in
322
+ # the current context.
320
323
  #
321
- # This behavior is inherited from RDoc version 1, and has been kept
322
- # for compatibility with existing RDoc documentation.
324
+ # This behavior is inherited from RDoc version 1, and has been kept for
325
+ # compatibility with existing RDoc documentation.
323
326
  #
324
327
  # === Conversion of characters
325
328
  #
@@ -378,11 +381,10 @@ require 'rdoc'
378
381
  # # ...
379
382
  # end
380
383
  #
381
- # Names of classes, files, and any method names containing an
382
- # underscore or preceded by a hash character are automatically hyperlinked
383
- # from comment text to their description. This hyperlinking works inside
384
- # the current class or module, and with ancestor methods (in included modules
385
- # or in the superclass).
384
+ # Names of classes, files, and any method names containing an underscore or
385
+ # preceded by a hash character are automatically linked from comment text to
386
+ # their description. This linking works inside the current class or module,
387
+ # and with ancestor methods (in included modules or in the superclass).
386
388
  #
387
389
  # Method parameter lists are extracted and displayed with the method
388
390
  # description. If a method calls +yield+, then the parameters passed to yield