rdoc 6.7.0 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/ExampleMarkdown.md +2 -0
  3. data/ExampleRDoc.rdoc +2 -0
  4. data/History.rdoc +64 -62
  5. data/LICENSE.rdoc +2 -0
  6. data/README.rdoc +13 -0
  7. data/RI.md +842 -0
  8. data/TODO.rdoc +8 -7
  9. data/lib/rdoc/{alias.rb → code_object/alias.rb} +1 -1
  10. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +3 -3
  11. data/lib/rdoc/{attr.rb → code_object/attr.rb} +1 -1
  12. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +82 -12
  13. data/lib/rdoc/{constant.rb → code_object/constant.rb} +1 -1
  14. data/lib/rdoc/{context → code_object/context}/section.rb +10 -68
  15. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +17 -5
  16. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +5 -5
  17. data/lib/rdoc/code_object.rb +6 -1
  18. data/lib/rdoc/comment.rb +11 -1
  19. data/lib/rdoc/generator/darkfish.rb +41 -3
  20. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  21. data/lib/rdoc/generator/pot/po_entry.rb +1 -1
  22. data/lib/rdoc/generator/template/darkfish/_head.rhtml +23 -0
  23. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -0
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +3 -8
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  27. data/lib/rdoc/generator/template/darkfish/class.rhtml +69 -43
  28. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +380 -399
  29. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -10
  30. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +24 -1
  31. data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
  32. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
  33. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +5 -2
  34. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +11 -0
  35. data/lib/rdoc/markdown.kpeg +1 -1
  36. data/lib/rdoc/markdown.rb +21 -11
  37. data/lib/rdoc/markup/attribute_manager.rb +2 -2
  38. data/lib/rdoc/markup/formatter.rb +19 -12
  39. data/lib/rdoc/markup/pre_process.rb +26 -6
  40. data/lib/rdoc/markup/to_bs.rb +1 -1
  41. data/lib/rdoc/markup/to_html.rb +1 -1
  42. data/lib/rdoc/markup/to_html_crossref.rb +63 -12
  43. data/lib/rdoc/markup/to_rdoc.rb +5 -5
  44. data/lib/rdoc/markup.rb +18 -13
  45. data/lib/rdoc/options.rb +78 -12
  46. data/lib/rdoc/parser/c.rb +26 -2
  47. data/lib/rdoc/parser/changelog.rb +5 -4
  48. data/lib/rdoc/parser/prism_ruby.rb +1099 -0
  49. data/lib/rdoc/parser/ripper_state_lex.rb +7 -305
  50. data/lib/rdoc/parser/ruby.rb +16 -7
  51. data/lib/rdoc/parser/simple.rb +1 -1
  52. data/lib/rdoc/parser.rb +5 -4
  53. data/lib/rdoc/rd/block_parser.rb +3 -3
  54. data/lib/rdoc/rd/inline_parser.rb +3 -3
  55. data/lib/rdoc/rdoc.rb +6 -3
  56. data/lib/rdoc/ri/driver.rb +74 -29
  57. data/lib/rdoc/rubygems_hook.rb +90 -8
  58. data/lib/rdoc/store.rb +12 -0
  59. data/lib/rdoc/task.rb +2 -3
  60. data/lib/rdoc/tom_doc.rb +1 -7
  61. data/lib/rdoc/version.rb +1 -1
  62. data/lib/rdoc.rb +22 -24
  63. data/lib/rubygems_plugin.rb +23 -0
  64. metadata +27 -26
  65. data/RI.rdoc +0 -57
  66. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  67. data/lib/rdoc/generator/template/json_index/.document +0 -1
  68. /data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +0 -0
  69. /data/lib/rdoc/{context.rb → code_object/context.rb} +0 -0
  70. /data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -0
  71. /data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +0 -0
  72. /data/lib/rdoc/{include.rb → code_object/include.rb} +0 -0
  73. /data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +0 -0
  74. /data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +0 -0
  75. /data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +0 -0
  76. /data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +0 -0
  77. /data/lib/rdoc/{require.rb → code_object/require.rb} +0 -0
  78. /data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +0 -0
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
- === RDoc::VERSION.succ
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
- === More Future
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
- === Crazy Ideas
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
- === Accessibility
50
+ == Accessibility
50
51
 
51
52
  Page title in right hand side
52
53
 
@@ -70,7 +70,7 @@ class RDoc::Alias < RDoc::CodeObject
70
70
  # HTML id-friendly version of +#new_name+.
71
71
 
72
72
  def html_name
73
- CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
73
+ CGI.escape(@new_name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
74
74
  end
75
75
 
76
76
  def inspect # :nodoc:
@@ -198,7 +198,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
198
198
  @full_name = array[2]
199
199
  @singleton = array[3]
200
200
  @visibility = array[4]
201
- @comment = array[5]
201
+ @comment = RDoc::Comment.from_document array[5]
202
202
  @call_seq = array[6]
203
203
  @block_params = array[7]
204
204
  # 8 handled below
@@ -210,8 +210,8 @@ class RDoc::AnyMethod < RDoc::MethodAttr
210
210
  @section_title = array[14]
211
211
  @is_alias_for = array[15]
212
212
 
213
- array[8].each do |new_name, comment|
214
- add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton)
213
+ array[8].each do |new_name, document|
214
+ add_alias RDoc::Alias.new(nil, @name, new_name, RDoc::Comment.from_document(document), @singleton)
215
215
  end
216
216
 
217
217
  @parent_name ||= if @full_name =~ /#/ then
@@ -136,7 +136,7 @@ class RDoc::Attr < RDoc::MethodAttr
136
136
  @full_name = array[2]
137
137
  @rw = array[3]
138
138
  @visibility = array[4]
139
- @comment = array[5]
139
+ @comment = RDoc::Comment.from_document array[5]
140
140
  @singleton = array[6] || false # MARSHAL_VERSION == 0
141
141
  # 7 handled below
142
142
  @parent_name = array[8]
@@ -223,6 +223,7 @@ class RDoc::ClassModule < RDoc::Context
223
223
  def complete min_visibility
224
224
  update_aliases
225
225
  remove_nodoc_children
226
+ embed_mixins
226
227
  update_includes
227
228
  remove_invisible min_visibility
228
229
  end
@@ -358,12 +359,14 @@ class RDoc::ClassModule < RDoc::Context
358
359
  @name = array[1]
359
360
  @full_name = array[2]
360
361
  @superclass = array[3]
361
- @comment = array[4]
362
+ document = array[4]
362
363
 
363
- @comment_location = if RDoc::Markup::Document === @comment.parts.first then
364
- @comment
364
+ @comment = RDoc::Comment.from_document document
365
+
366
+ @comment_location = if RDoc::Markup::Document === document.parts.first then
367
+ document
365
368
  else
366
- RDoc::Markup::Document.new @comment
369
+ RDoc::Markup::Document.new document
367
370
  end
368
371
 
369
372
  array[5].each do |name, rw, visibility, singleton, file|
@@ -377,18 +380,18 @@ class RDoc::ClassModule < RDoc::Context
377
380
  attr.record_location RDoc::TopLevel.new file
378
381
  end
379
382
 
380
- array[6].each do |constant, comment, file|
383
+ array[6].each do |constant, document, file|
381
384
  case constant
382
385
  when RDoc::Constant then
383
386
  add_constant constant
384
387
  else
385
- constant = add_constant RDoc::Constant.new(constant, nil, comment)
388
+ constant = add_constant RDoc::Constant.new(constant, nil, RDoc::Comment.from_document(document))
386
389
  constant.record_location RDoc::TopLevel.new file
387
390
  end
388
391
  end
389
392
 
390
- array[7].each do |name, comment, file|
391
- incl = add_include RDoc::Include.new(name, comment)
393
+ array[7].each do |name, document, file|
394
+ incl = add_include RDoc::Include.new(name, RDoc::Comment.from_document(document))
392
395
  incl.record_location RDoc::TopLevel.new file
393
396
  end
394
397
 
@@ -405,8 +408,8 @@ class RDoc::ClassModule < RDoc::Context
405
408
  end
406
409
  end
407
410
 
408
- array[9].each do |name, comment, file|
409
- ext = add_extend RDoc::Extend.new(name, comment)
411
+ array[9].each do |name, document, file|
412
+ ext = add_extend RDoc::Extend.new(name, RDoc::Comment.from_document(document))
410
413
  ext.record_location RDoc::TopLevel.new file
411
414
  end if array[9] # Support Marshal version 1
412
415
 
@@ -443,7 +446,8 @@ class RDoc::ClassModule < RDoc::Context
443
446
 
444
447
  document = document.merge other_document
445
448
 
446
- @comment = @comment_location = document
449
+ @comment = RDoc::Comment.from_document(document)
450
+ @comment_location = document
447
451
  end
448
452
 
449
453
  cm = class_module
@@ -704,10 +708,37 @@ class RDoc::ClassModule < RDoc::Context
704
708
 
705
709
  ##
706
710
  # Set the superclass of this class to +superclass+
711
+ #
712
+ # where +superclass+ is one of:
713
+ #
714
+ # - +nil+
715
+ # - a String containing the full name of the superclass
716
+ # - the RDoc::ClassModule representing the superclass
707
717
 
708
718
  def superclass=(superclass)
709
719
  raise NoMethodError, "#{full_name} is a module" if module?
710
- @superclass = superclass
720
+ case superclass
721
+ when RDoc::ClassModule
722
+ @superclass = superclass.full_name
723
+ when nil, String
724
+ @superclass = superclass
725
+ else
726
+ raise TypeError, "superclass must be a String or RDoc::ClassModule, not #{superclass.class}"
727
+ end
728
+ end
729
+
730
+ ##
731
+ # Get all super classes of this class in an array. The last element might be
732
+ # a string if the name is unknown.
733
+
734
+ def super_classes
735
+ result = []
736
+ parent = self
737
+ while parent = parent.superclass
738
+ result << parent
739
+ return result if parent.is_a?(String)
740
+ end
741
+ result
711
742
  end
712
743
 
713
744
  def to_s # :nodoc:
@@ -798,4 +829,43 @@ class RDoc::ClassModule < RDoc::Context
798
829
  extends.uniq!
799
830
  end
800
831
 
832
+ def embed_mixins
833
+ return unless options.embed_mixins
834
+
835
+ includes.each do |include|
836
+ next if String === include.module
837
+ include.module.method_list.each do |code_object|
838
+ add_method(prepare_to_embed(code_object))
839
+ end
840
+ include.module.constants.each do |code_object|
841
+ add_constant(prepare_to_embed(code_object))
842
+ end
843
+ include.module.attributes.each do |code_object|
844
+ add_attribute(prepare_to_embed(code_object))
845
+ end
846
+ end
847
+
848
+ extends.each do |ext|
849
+ next if String === ext.module
850
+ ext.module.method_list.each do |code_object|
851
+ add_method(prepare_to_embed(code_object, true))
852
+ end
853
+ ext.module.attributes.each do |code_object|
854
+ add_attribute(prepare_to_embed(code_object, true))
855
+ end
856
+ end
857
+ end
858
+
859
+ private
860
+
861
+ def prepare_to_embed(code_object, singleton=false)
862
+ code_object = code_object.dup
863
+ code_object.mixin_from = code_object.parent
864
+ code_object.singleton = true if singleton
865
+ set_current_section(code_object.section.title, code_object.section.comment)
866
+ # add_method and add_attribute will reassign self's visibility back to the method/attribute
867
+ # so we need to sync self's visibility with the object's to properly retain that information
868
+ self.visibility = code_object.visibility
869
+ code_object
870
+ end
801
871
  end
@@ -133,7 +133,7 @@ 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
139
  @visibility = array[3] || :public
@@ -61,19 +61,10 @@ class RDoc::Context::Section
61
61
  # Adds +comment+ to this section
62
62
 
63
63
  def add_comment comment
64
- comment = extract_comment comment
65
-
66
- return if comment.empty?
67
-
68
- case comment
69
- when RDoc::Comment then
70
- @comments << comment
71
- when RDoc::Markup::Document then
72
- @comments.concat comment.parts
73
- when Array then
74
- @comments.concat comment
75
- else
76
- raise TypeError, "unknown comment type: #{comment.inspect}"
64
+ comments = Array(comment)
65
+ comments.each do |c|
66
+ extracted_comment = extract_comment(c)
67
+ @comments << extracted_comment unless extracted_comment.empty?
77
68
  end
78
69
  end
79
70
 
@@ -97,10 +88,6 @@ class RDoc::Context::Section
97
88
 
98
89
  def extract_comment comment
99
90
  case comment
100
- when Array then
101
- comment.map do |c|
102
- extract_comment c
103
- end
104
91
  when nil
105
92
  RDoc::Comment.new ''
106
93
  when RDoc::Comment then
@@ -115,8 +102,6 @@ class RDoc::Context::Section
115
102
  end
116
103
  end
117
104
 
118
- comment
119
- when RDoc::Markup::Document then
120
105
  comment
121
106
  else
122
107
  raise TypeError, "unknown comment #{comment.inspect}"
@@ -135,20 +120,7 @@ class RDoc::Context::Section
135
120
  # The files comments in this section come from
136
121
 
137
122
  def in_files
138
- return [] if @comments.empty?
139
-
140
- case @comments
141
- when Array then
142
- @comments.map do |comment|
143
- comment.file
144
- end
145
- when RDoc::Markup::Document then
146
- @comment.parts.map do |document|
147
- document.file
148
- end
149
- else
150
- raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
151
- end
123
+ @comments.map(&:file)
152
124
  end
153
125
 
154
126
  ##
@@ -170,7 +142,7 @@ class RDoc::Context::Section
170
142
  @parent = nil
171
143
 
172
144
  @title = array[1]
173
- @comments = array[2]
145
+ @comments = array[2].parts.map { |doc| RDoc::Comment.from_document(doc) }
174
146
  end
175
147
 
176
148
  ##
@@ -178,26 +150,7 @@ class RDoc::Context::Section
178
150
  # multiple RDoc::Markup::Documents with their file set.
179
151
 
180
152
  def parse
181
- case @comments
182
- when String then
183
- super
184
- when Array then
185
- docs = @comments.map do |comment, location|
186
- doc = super comment
187
- doc.file = location if location
188
- doc
189
- end
190
-
191
- RDoc::Markup::Document.new(*docs)
192
- when RDoc::Comment then
193
- doc = super @comments.text, comments.format
194
- doc.file = @comments.location
195
- doc
196
- when RDoc::Markup::Document then
197
- return @comments
198
- else
199
- raise ArgumentError, "unknown comment class #{comments.class}"
200
- end
153
+ RDoc::Markup::Document.new(*@comments.map(&:parse))
201
154
  end
202
155
 
203
156
  ##
@@ -213,20 +166,9 @@ class RDoc::Context::Section
213
166
  # Removes a comment from this section if it is from the same file as
214
167
  # +comment+
215
168
 
216
- def remove_comment comment
217
- return if @comments.empty?
218
-
219
- case @comments
220
- when Array then
221
- @comments.delete_if do |my_comment|
222
- my_comment.file == comment.file
223
- end
224
- when RDoc::Markup::Document then
225
- @comments.parts.delete_if do |document|
226
- document.file == comment.file.name
227
- end
228
- else
229
- raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
169
+ def remove_comment target_comment
170
+ @comments.delete_if do |stored_comment|
171
+ stored_comment.file == target_comment.file
230
172
  end
231
173
  end
232
174
 
@@ -114,8 +114,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
114
114
  return unless other.respond_to?(:singleton) &&
115
115
  other.respond_to?(:name)
116
116
 
117
- [ @singleton ? 0 : 1, name] <=>
118
- [other.singleton ? 0 : 1, other.name]
117
+ [@singleton ? 0 : 1, name_ord_range, name] <=>
118
+ [other.singleton ? 0 : 1, other.name_ord_range, other.name]
119
119
  end
120
120
 
121
121
  def == other # :nodoc:
@@ -268,8 +268,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
268
268
  when 'const_get' then 'const'
269
269
  when 'new' then
270
270
  $1.split('::').last. # ClassName => class_name
271
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
272
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
271
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
272
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
273
273
  downcase
274
274
  else
275
275
  $2
@@ -291,7 +291,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
291
291
  def html_name
292
292
  require 'cgi/util'
293
293
 
294
- CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
294
+ CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
295
295
  end
296
296
 
297
297
  ##
@@ -415,4 +415,16 @@ class RDoc::MethodAttr < RDoc::CodeObject
415
415
  end
416
416
  end
417
417
 
418
+ def name_ord_range # :nodoc:
419
+ case name.ord
420
+ when 0..64 # anything below "A"
421
+ 1
422
+ when 91..96 # the symbols between "Z" and "a"
423
+ 2
424
+ when 123..126 # 7-bit symbols above "z": "{", "|", "}", "~"
425
+ 3
426
+ else # everythig else can be sorted as normal
427
+ 4
428
+ end
429
+ end
418
430
  end
@@ -183,8 +183,8 @@ class RDoc::TopLevel < RDoc::Context
183
183
  "#<%s:0x%x %p modules: %p classes: %p>" % [
184
184
  self.class, object_id,
185
185
  base_name,
186
- @modules.map { |n,m| m },
187
- @classes.map { |n,c| c }
186
+ @modules.map { |n, m| m },
187
+ @classes.map { |n, c| c }
188
188
  ]
189
189
  end
190
190
 
@@ -214,7 +214,7 @@ class RDoc::TopLevel < RDoc::Context
214
214
  initialize array[1]
215
215
 
216
216
  @parser = array[2]
217
- @comment = array[3]
217
+ @comment = RDoc::Comment.from_document array[3]
218
218
 
219
219
  @file_stat = nil
220
220
  end
@@ -254,8 +254,8 @@ class RDoc::TopLevel < RDoc::Context
254
254
  q.text "base name: #{base_name.inspect}"
255
255
  q.breakable
256
256
 
257
- items = @modules.map { |n,m| m }
258
- items.concat @modules.map { |n,c| c }
257
+ items = @modules.map { |n, m| m }
258
+ items.concat @modules.map { |n, c| c }
259
259
  q.seplist items do |mod| q.pp mod end
260
260
  end
261
261
  end
@@ -96,6 +96,11 @@ class RDoc::CodeObject
96
96
 
97
97
  attr_accessor :viewer
98
98
 
99
+ ##
100
+ # When mixed-in to a class, this points to the Context in which it was originally defined.
101
+
102
+ attr_accessor :mixin_from
103
+
99
104
  ##
100
105
  # Creates a new CodeObject that will document itself and its children
101
106
 
@@ -111,6 +116,7 @@ class RDoc::CodeObject
111
116
  @full_name = nil
112
117
  @store = nil
113
118
  @track_visibility = true
119
+ @mixin_from = nil
114
120
 
115
121
  initialize_visibility
116
122
  end
@@ -135,7 +141,6 @@ class RDoc::CodeObject
135
141
  def comment=(comment)
136
142
  @comment = case comment
137
143
  when NilClass then ''
138
- when RDoc::Markup::Document then comment
139
144
  when RDoc::Comment then comment.normalize
140
145
  else
141
146
  if comment and not comment.empty? then
data/lib/rdoc/comment.rb CHANGED
@@ -126,7 +126,7 @@ class RDoc::Comment
126
126
  # A comment is empty if its text String is empty.
127
127
 
128
128
  def empty?
129
- @text.empty?
129
+ @text.empty? && (@document.nil? || @document.empty?)
130
130
  end
131
131
 
132
132
  ##
@@ -226,4 +226,14 @@ class RDoc::Comment
226
226
  @format == 'tomdoc'
227
227
  end
228
228
 
229
+ ##
230
+ # Create a new parsed comment from a document
231
+
232
+ def self.from_document(document) # :nodoc:
233
+ comment = RDoc::Comment.new('')
234
+ comment.document = document
235
+ comment.location = RDoc::TopLevel.new(document.file) if document.file
236
+ comment
237
+ end
238
+
229
239
  end
@@ -316,11 +316,14 @@ class RDoc::Generator::Darkfish
316
316
  asset_rel_prefix = rel_prefix + @asset_rel_path
317
317
 
318
318
  @title = @options.title
319
+ @main_page = @files.find { |f| f.full_name == @options.main_page }
319
320
 
320
321
  render_template template_file, out_file do |io|
321
322
  here = binding
322
323
  # suppress 1.9.3 warning
323
324
  here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
325
+ # some partials rely on the presence of current variable to render
326
+ here.local_variable_set(:current, @main_page) if @main_page
324
327
  here
325
328
  end
326
329
  rescue => e
@@ -677,7 +680,6 @@ class RDoc::Generator::Darkfish
677
680
  return body if body =~ /<html/
678
681
 
679
682
  head_file = @template_dir + '_head.rhtml'
680
- footer_file = @template_dir + '_footer.rhtml'
681
683
 
682
684
  <<-TEMPLATE
683
685
  <!DOCTYPE html>
@@ -687,8 +689,6 @@ class RDoc::Generator::Darkfish
687
689
  #{head_file.read}
688
690
 
689
691
  #{body}
690
-
691
- #{footer_file.read}
692
692
  TEMPLATE
693
693
  end
694
694
 
@@ -783,4 +783,42 @@ class RDoc::Generator::Darkfish
783
783
  template
784
784
  end
785
785
 
786
+ # Returns an excerpt of the comment for usage in meta description tags
787
+ def excerpt(comment)
788
+ text = case comment
789
+ when RDoc::Comment
790
+ comment.text
791
+ else
792
+ comment
793
+ end
794
+
795
+ # Match from a capital letter to the first period, discarding any links, so
796
+ # that we don't end up matching badges in the README
797
+ first_paragraph_match = text.match(/[A-Z][^\.:\/]+\./)
798
+ return text[0...150].gsub(/\n/, " ").squeeze(" ") unless first_paragraph_match
799
+
800
+ extracted_text = first_paragraph_match[0]
801
+ second_paragraph = first_paragraph_match.post_match.match(/[A-Z][^\.:\/]+\./)
802
+ extracted_text << " " << second_paragraph[0] if second_paragraph
803
+
804
+ extracted_text[0...150].gsub(/\n/, " ").squeeze(" ")
805
+ end
806
+
807
+ def generate_ancestor_list(ancestors, klass)
808
+ return '' if ancestors.empty?
809
+
810
+ ancestor = ancestors.shift
811
+ content = +'<ul><li>'
812
+
813
+ if ancestor.is_a?(RDoc::NormalClass)
814
+ content << "<a href=\"#{klass.aref_to ancestor.path}\">#{ancestor.full_name}</a>"
815
+ else
816
+ content << ancestor.to_s
817
+ end
818
+
819
+ # Recursively call the method for the remaining ancestors
820
+ content << generate_ancestor_list(ancestors, klass)
821
+
822
+ content << '</li></ul>'
823
+ end
786
824
  end
@@ -29,7 +29,7 @@ class RDoc::Generator::POT::MessageExtractor
29
29
  extract_text(klass.comment_location, klass.full_name)
30
30
 
31
31
  klass.each_section do |section, constants, attributes|
32
- extract_text(section.title ,"#{klass.full_name}: section title")
32
+ extract_text(section.title, "#{klass.full_name}: section title")
33
33
  section.comments.each do |comment|
34
34
  extract_text(comment, "#{klass.full_name}: #{section.title}")
35
35
  end
@@ -23,7 +23,7 @@ class RDoc::Generator::POT::POEntry
23
23
  attr_reader :flags
24
24
 
25
25
  ##
26
- # Creates a PO entry for +msgid+. Other valus can be specified by
26
+ # Creates a PO entry for +msgid+. Other values can be specified by
27
27
  # +options+.
28
28
 
29
29
  def initialize msgid, options = {}
@@ -1,7 +1,30 @@
1
1
  <meta charset="<%= @options.charset %>">
2
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
2
3
 
3
4
  <title><%= h @title %></title>
4
5
 
6
+ <%- if defined?(klass) -%>
7
+ <meta name="keywords" content="ruby,<%= h "#{klass.type},#{klass.full_name}" %>">
8
+
9
+ <%- if klass.comment.empty? -%>
10
+ <meta name="description" content="Documentation for the <%= h "#{klass.full_name} #{klass.type}" %>">
11
+ <%- else -%>
12
+ <meta name="description" content="<%= h "#{klass.type} #{klass.full_name}: #{excerpt(klass.comment)}" %>">
13
+ <%- end -%>
14
+ <%- elsif defined?(file) -%>
15
+ <meta name="keywords" content="ruby,documentation,<%= h file.page_name %>">
16
+ <meta name="description" content="<%= h "#{file.page_name}: #{excerpt(file.comment)}" %>">
17
+ <%- elsif @title -%>
18
+ <meta name="keywords" content="ruby,documentation,<%= h @title %>">
19
+
20
+ <%- if @options.main_page and
21
+ main_page = @files.find { |f| f.full_name == @options.main_page } then %>
22
+ <meta name="description" content="<%= h "#{@title}: #{excerpt(main_page.comment)}" %>">
23
+ <%- else -%>
24
+ <meta name="description" content="Documentation for <%= h @title %>">
25
+ <%- end -%>
26
+ <%- end -%>
27
+
5
28
  <script type="text/javascript">
6
29
  var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
7
30
  var index_rel_prefix = "<%= h rel_prefix %>/";
@@ -18,6 +18,7 @@
18
18
  solo = top.one? {|klass| klass.display?}
19
19
  traverse = proc do |klasses| -%>
20
20
  <ul class="link-list">
21
+ <%- klasses.uniq!(&:full_name) -%>
21
22
  <%- klasses.each do |index_klass| -%>
22
23
  <%- if children = all_classes[index_klass.full_name] -%>
23
24
  <li><details<% if solo; solo = false %> open<% end %>><summary><% link.call(index_klass) %></summary>
@@ -1,12 +1,21 @@
1
- <%- unless klass.method_list.empty? then %>
2
- <!-- Method Quickref -->
3
- <div id="method-list-section" class="nav-section">
4
- <h3>Methods</h3>
1
+ <% if (class_methods = klass.class_method_list.sort).any? %>
2
+ <div class="nav-section">
3
+ <h3>Class Methods</h3>
4
+ <ul class="link-list" role="directory">
5
+ <%- class_methods.each do |meth| -%>
6
+ <li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= h meth.name -%></a></li>
7
+ <%- end -%>
8
+ </ul>
9
+ </div>
10
+ <% end %>
5
11
 
6
- <ul class="link-list" role="directory">
7
- <%- klass.each_method do |meth| -%>
8
- <li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= meth.singleton ? '::' : '#' %><%= h meth.name -%></a>
9
- <%- end -%>
10
- </ul>
11
- </div>
12
- <%- end -%>
12
+ <% if (instance_methods = klass.instance_methods.sort).any? %>
13
+ <div class="nav-section">
14
+ <h3>Instance Methods</h3>
15
+ <ul class="link-list" role="directory">
16
+ <%- instance_methods.each do |meth| -%>
17
+ <li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= h meth.name -%></a></li>
18
+ <%- end -%>
19
+ </ul>
20
+ </div>
21
+ <% end %>