rdoc 6.12.0 → 6.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -1
  3. data/lib/rdoc/code_object/alias.rb +2 -9
  4. data/lib/rdoc/code_object/any_method.rb +9 -14
  5. data/lib/rdoc/code_object/attr.rb +6 -9
  6. data/lib/rdoc/code_object/class_module.rb +40 -23
  7. data/lib/rdoc/code_object/constant.rb +5 -5
  8. data/lib/rdoc/code_object/context/section.rb +8 -7
  9. data/lib/rdoc/code_object/context.rb +23 -65
  10. data/lib/rdoc/code_object/method_attr.rb +9 -28
  11. data/lib/rdoc/code_object/mixin.rb +3 -3
  12. data/lib/rdoc/code_object/normal_class.rb +1 -1
  13. data/lib/rdoc/code_object/normal_module.rb +1 -1
  14. data/lib/rdoc/code_object/require.rb +1 -1
  15. data/lib/rdoc/code_object/single_class.rb +1 -1
  16. data/lib/rdoc/code_object/top_level.rb +12 -30
  17. data/lib/rdoc/code_object.rb +6 -37
  18. data/lib/rdoc/comment.rb +7 -10
  19. data/lib/rdoc/cross_reference.rb +3 -3
  20. data/lib/rdoc/encoding.rb +4 -4
  21. data/lib/rdoc/erb_partial.rb +1 -1
  22. data/lib/rdoc/erbio.rb +2 -2
  23. data/lib/rdoc/generator/darkfish.rb +97 -109
  24. data/lib/rdoc/generator/json_index.rb +4 -20
  25. data/lib/rdoc/generator/markup.rb +14 -2
  26. data/lib/rdoc/generator/pot/message_extractor.rb +6 -6
  27. data/lib/rdoc/generator/pot/po.rb +1 -1
  28. data/lib/rdoc/generator/pot/po_entry.rb +7 -7
  29. data/lib/rdoc/generator/pot.rb +1 -6
  30. data/lib/rdoc/generator/ri.rb +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_head.rhtml +5 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -30
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +1 -1
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -0
  36. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +15 -0
  37. data/lib/rdoc/markdown.kpeg +7 -5
  38. data/lib/rdoc/markdown.rb +34 -21
  39. data/lib/rdoc/markup/attribute_manager.rb +5 -5
  40. data/lib/rdoc/markup/attributes.rb +3 -3
  41. data/lib/rdoc/markup/blank_line.rb +2 -2
  42. data/lib/rdoc/markup/block_quote.rb +1 -1
  43. data/lib/rdoc/markup/document.rb +8 -8
  44. data/lib/rdoc/markup/formatter.rb +12 -12
  45. data/lib/rdoc/markup/hard_break.rb +3 -3
  46. data/lib/rdoc/markup/heading.rb +11 -5
  47. data/lib/rdoc/markup/include.rb +3 -3
  48. data/lib/rdoc/markup/indented_paragraph.rb +3 -3
  49. data/lib/rdoc/markup/list.rb +4 -4
  50. data/lib/rdoc/markup/list_item.rb +4 -4
  51. data/lib/rdoc/markup/paragraph.rb +2 -2
  52. data/lib/rdoc/markup/parser.rb +11 -11
  53. data/lib/rdoc/markup/pre_process.rb +6 -6
  54. data/lib/rdoc/markup/raw.rb +5 -5
  55. data/lib/rdoc/markup/rule.rb +2 -2
  56. data/lib/rdoc/markup/table.rb +4 -4
  57. data/lib/rdoc/markup/to_ansi.rb +3 -3
  58. data/lib/rdoc/markup/to_bs.rb +6 -6
  59. data/lib/rdoc/markup/to_html.rb +25 -16
  60. data/lib/rdoc/markup/to_html_crossref.rb +5 -5
  61. data/lib/rdoc/markup/to_html_snippet.rb +17 -17
  62. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
  63. data/lib/rdoc/markup/to_label.rb +6 -5
  64. data/lib/rdoc/markup/to_markdown.rb +12 -12
  65. data/lib/rdoc/markup/to_rdoc.rb +29 -28
  66. data/lib/rdoc/markup/to_table_of_contents.rb +3 -3
  67. data/lib/rdoc/markup/to_test.rb +1 -1
  68. data/lib/rdoc/markup/to_tt_only.rb +8 -8
  69. data/lib/rdoc/markup/verbatim.rb +3 -3
  70. data/lib/rdoc/markup.rb +3 -3
  71. data/lib/rdoc/options.rb +31 -12
  72. data/lib/rdoc/parser/c.rb +20 -23
  73. data/lib/rdoc/parser/changelog.rb +9 -9
  74. data/lib/rdoc/parser/prism_ruby.rb +9 -16
  75. data/lib/rdoc/parser/ruby.rb +50 -53
  76. data/lib/rdoc/parser/simple.rb +2 -2
  77. data/lib/rdoc/parser.rb +8 -8
  78. data/lib/rdoc/rd/inline.rb +4 -4
  79. data/lib/rdoc/rd.rb +1 -1
  80. data/lib/rdoc/rdoc.rb +11 -26
  81. data/lib/rdoc/ri/driver.rb +60 -52
  82. data/lib/rdoc/ri/paths.rb +2 -2
  83. data/lib/rdoc/ri/task.rb +1 -1
  84. data/lib/rdoc/rubygems_hook.rb +14 -17
  85. data/lib/rdoc/servlet.rb +23 -22
  86. data/lib/rdoc/stats/normal.rb +1 -1
  87. data/lib/rdoc/stats/quiet.rb +1 -1
  88. data/lib/rdoc/stats/verbose.rb +3 -3
  89. data/lib/rdoc/stats.rb +14 -14
  90. data/lib/rdoc/store.rb +39 -43
  91. data/lib/rdoc/task.rb +2 -2
  92. data/lib/rdoc/text.rb +13 -13
  93. data/lib/rdoc/token_stream.rb +1 -1
  94. data/lib/rdoc/tom_doc.rb +7 -7
  95. data/lib/rdoc/version.rb +1 -1
  96. data/man/ri.1 +2 -0
  97. data/rdoc.gemspec +69 -0
  98. metadata +18 -5
  99. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  100. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
data/lib/rdoc/comment.rb CHANGED
@@ -53,7 +53,7 @@ class RDoc::Comment
53
53
  # Creates a new comment with +text+ that is found in the RDoc::TopLevel
54
54
  # +location+.
55
55
 
56
- def initialize text = nil, location = nil, language = nil
56
+ def initialize(text = nil, location = nil, language = nil)
57
57
  @location = location
58
58
  @text = text.nil? ? nil : text.dup
59
59
  @language = language
@@ -67,11 +67,11 @@ class RDoc::Comment
67
67
  #--
68
68
  # TODO deep copy @document
69
69
 
70
- def initialize_copy copy # :nodoc:
70
+ def initialize_copy(copy) # :nodoc:
71
71
  @text = copy.text.dup
72
72
  end
73
73
 
74
- def == other # :nodoc:
74
+ def ==(other) # :nodoc:
75
75
  self.class === other and
76
76
  other.text == @text and other.location == @location
77
77
  end
@@ -92,7 +92,7 @@ class RDoc::Comment
92
92
  # # ARGF.to_a(limit) -> array
93
93
  # # ARGF.to_a(sep, limit) -> array
94
94
 
95
- def extract_call_seq method
95
+ def extract_call_seq
96
96
  # we must handle situations like the above followed by an unindented first
97
97
  # comment. The difficulty is to make sure not to match lines starting
98
98
  # with ARGF at the same indent, but that are after the first description
@@ -116,10 +116,7 @@ class RDoc::Comment
116
116
  @text.slice! all_start...all_stop
117
117
 
118
118
  seq.gsub!(/^\s*/, '')
119
- method.call_seq = seq
120
119
  end
121
-
122
- method
123
120
  end
124
121
 
125
122
  ##
@@ -132,7 +129,7 @@ class RDoc::Comment
132
129
  ##
133
130
  # HACK dubious
134
131
 
135
- def encode! encoding
132
+ def encode!(encoding)
136
133
  @text = String.new @text, encoding: encoding
137
134
  self
138
135
  end
@@ -140,7 +137,7 @@ class RDoc::Comment
140
137
  ##
141
138
  # Sets the format of this comment and resets any parsed document
142
139
 
143
- def format= format
140
+ def format=(format)
144
141
  @format = format
145
142
  @document = nil
146
143
  end
@@ -211,7 +208,7 @@ class RDoc::Comment
211
208
  #
212
209
  # An error is raised if the comment contains a document but no text.
213
210
 
214
- def text= text
211
+ def text=(text)
215
212
  raise RDoc::Error, 'replacing document-only comment is not allowed' if
216
213
  @text.nil? and @document
217
214
 
@@ -124,7 +124,7 @@ class RDoc::CrossReference
124
124
  # Allows cross-references to be created based on the given +context+
125
125
  # (RDoc::Context).
126
126
 
127
- def initialize context
127
+ def initialize(context)
128
128
  @context = context
129
129
  @store = context.store
130
130
 
@@ -134,7 +134,7 @@ class RDoc::CrossReference
134
134
  ##
135
135
  # Returns a method reference to +name+.
136
136
 
137
- def resolve_method name
137
+ def resolve_method(name)
138
138
  ref = nil
139
139
 
140
140
  if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
@@ -187,7 +187,7 @@ class RDoc::CrossReference
187
187
  # returned. If +name+ is escaped +name+ is returned. If +name+ is not
188
188
  # found +text+ is returned.
189
189
 
190
- def resolve name, text
190
+ def resolve(name, text)
191
191
  return @seen[name] if @seen.include? name
192
192
 
193
193
  ref = case name
data/lib/rdoc/encoding.rb CHANGED
@@ -29,7 +29,7 @@ module RDoc::Encoding
29
29
  # If +force_transcode+ is true the document will be transcoded and any
30
30
  # unknown character in the target encoding will be replaced with '?'
31
31
 
32
- def self.read_file filename, encoding, force_transcode = false
32
+ def self.read_file(filename, encoding, force_transcode = false)
33
33
  content = File.open filename, "rb" do |f| f.read end
34
34
  content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
35
35
 
@@ -89,7 +89,7 @@ module RDoc::Encoding
89
89
  ##
90
90
  # Detects the encoding of +string+ based on the magic comment
91
91
 
92
- def self.detect_encoding string
92
+ def self.detect_encoding(string)
93
93
  result = HEADER_REGEXP.match string
94
94
  name = result && result[:name]
95
95
 
@@ -99,7 +99,7 @@ module RDoc::Encoding
99
99
  ##
100
100
  # Removes magic comments and shebang
101
101
 
102
- def self.remove_magic_comment string
102
+ def self.remove_magic_comment(string)
103
103
  string.sub HEADER_REGEXP do |s|
104
104
  s.gsub(/[^\n]/, '')
105
105
  end
@@ -109,7 +109,7 @@ module RDoc::Encoding
109
109
  # Changes encoding based on +encoding+ without converting and returns new
110
110
  # string
111
111
 
112
- def self.change_encoding text, encoding
112
+ def self.change_encoding(text, encoding)
113
113
  if text.kind_of? RDoc::Comment
114
114
  text.encode! encoding
115
115
  else
@@ -9,7 +9,7 @@ class RDoc::ERBPartial < ERB
9
9
  # Overrides +compiler+ startup to set the +eoutvar+ to an empty string only
10
10
  # if it isn't already set.
11
11
 
12
- def set_eoutvar compiler, eoutvar = '_erbout'
12
+ def set_eoutvar(compiler, eoutvar = '_erbout')
13
13
  super
14
14
 
15
15
  compiler.pre_cmd = ["#{eoutvar} ||= +''"]
data/lib/rdoc/erbio.rb CHANGED
@@ -20,14 +20,14 @@ class RDoc::ERBIO < ERB
20
20
  ##
21
21
  # Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
22
22
 
23
- def initialize str, trim_mode: nil, eoutvar: 'io'
23
+ def initialize(str, trim_mode: nil, eoutvar: 'io')
24
24
  super(str, trim_mode: trim_mode, eoutvar: eoutvar)
25
25
  end
26
26
 
27
27
  ##
28
28
  # Instructs +compiler+ how to write to +io_variable+
29
29
 
30
- def set_eoutvar compiler, io_variable
30
+ def set_eoutvar(compiler, io_variable)
31
31
  compiler.put_cmd = "#{io_variable}.write"
32
32
  compiler.insert_cmd = "#{io_variable}.write"
33
33
  compiler.pre_cmd = []
@@ -73,12 +73,6 @@ class RDoc::Generator::Darkfish
73
73
  css/rdoc.css
74
74
  ]
75
75
 
76
- ##
77
- # Path to this file's parent directory. Used to find templates and other
78
- # resources.
79
-
80
- GENERATOR_DIR = File.join 'rdoc', 'generator'
81
-
82
76
  ##
83
77
  # Release Version
84
78
 
@@ -156,7 +150,7 @@ class RDoc::Generator::Darkfish
156
150
  ##
157
151
  # Initialize a few instance variables before we start
158
152
 
159
- def initialize store, options
153
+ def initialize(store, options)
160
154
  @store = store
161
155
  @options = options
162
156
 
@@ -184,22 +178,6 @@ class RDoc::Generator::Darkfish
184
178
  $stderr.puts(*msg)
185
179
  end
186
180
 
187
- ##
188
- # Directory where generated class HTML files live relative to the output
189
- # dir.
190
-
191
- def class_dir
192
- nil
193
- end
194
-
195
- ##
196
- # Directory where generated class HTML files live relative to the output
197
- # dir.
198
-
199
- def file_dir
200
- nil
201
- end
202
-
203
181
  ##
204
182
  # Create the directories the generated docs will live in if they don't
205
183
  # already exist.
@@ -291,7 +269,7 @@ class RDoc::Generator::Darkfish
291
269
  # Return a list of the documented modules sorted by salience first, then
292
270
  # by name.
293
271
 
294
- def get_sorted_module_list classes
272
+ def get_sorted_module_list(classes)
295
273
  classes.select do |klass|
296
274
  klass.display?
297
275
  end.sort
@@ -301,8 +279,6 @@ class RDoc::Generator::Darkfish
301
279
  # Generate an index page which lists all the classes which are documented.
302
280
 
303
281
  def generate_index
304
- setup
305
-
306
282
  template_file = @template_dir + 'index.rhtml'
307
283
  return unless template_file.exist?
308
284
 
@@ -337,9 +313,7 @@ class RDoc::Generator::Darkfish
337
313
  ##
338
314
  # Generates a class file for +klass+
339
315
 
340
- def generate_class klass, template_file = nil
341
- setup
342
-
316
+ def generate_class(klass, template_file = nil)
343
317
  current = klass
344
318
 
345
319
  template_file ||= @template_dir + 'class.rhtml'
@@ -351,7 +325,9 @@ class RDoc::Generator::Darkfish
351
325
  search_index_rel_prefix += @asset_rel_path if @file_output
352
326
 
353
327
  asset_rel_prefix = rel_prefix + @asset_rel_path
354
- svninfo = get_svninfo(current)
328
+
329
+ breadcrumb = # used in templates
330
+ breadcrumb = generate_nesting_namespaces_breadcrumb(current, rel_prefix)
355
331
 
356
332
  @title = "#{klass.type} #{klass.full_name} - #{@options.title}"
357
333
 
@@ -360,7 +336,6 @@ class RDoc::Generator::Darkfish
360
336
  here = binding
361
337
  # suppress 1.9.3 warning
362
338
  here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
363
- here.local_variable_set(:svninfo, svninfo)
364
339
  here
365
340
  end
366
341
  end
@@ -369,8 +344,6 @@ class RDoc::Generator::Darkfish
369
344
  # Generate a documentation file for each class and module
370
345
 
371
346
  def generate_class_files
372
- setup
373
-
374
347
  template_file = @template_dir + 'class.rhtml'
375
348
  template_file = @template_dir + 'classpage.rhtml' unless
376
349
  template_file.exist?
@@ -396,8 +369,6 @@ class RDoc::Generator::Darkfish
396
369
  # Generate a documentation file for each file
397
370
 
398
371
  def generate_file_files
399
- setup
400
-
401
372
  page_file = @template_dir + 'page.rhtml'
402
373
  fileinfo_file = @template_dir + 'fileinfo.rhtml'
403
374
 
@@ -464,9 +435,7 @@ class RDoc::Generator::Darkfish
464
435
  ##
465
436
  # Generate a page file for +file+
466
437
 
467
- def generate_page file
468
- setup
469
-
438
+ def generate_page(file)
470
439
  template_file = @template_dir + 'page.rhtml'
471
440
 
472
441
  out_file = @outputdir + file.path
@@ -493,9 +462,7 @@ class RDoc::Generator::Darkfish
493
462
  ##
494
463
  # Generates the 404 page for the RDoc servlet
495
464
 
496
- def generate_servlet_not_found message
497
- setup
498
-
465
+ def generate_servlet_not_found(message)
499
466
  template_file = @template_dir + 'servlet_not_found.rhtml'
500
467
  return unless template_file.exist?
501
468
 
@@ -526,9 +493,7 @@ class RDoc::Generator::Darkfish
526
493
  ##
527
494
  # Generates the servlet root page for the RDoc servlet
528
495
 
529
- def generate_servlet_root installed
530
- setup
531
-
496
+ def generate_servlet_root(installed)
532
497
  template_file = @template_dir + 'servlet_root.rhtml'
533
498
  return unless template_file.exist?
534
499
 
@@ -554,8 +519,6 @@ class RDoc::Generator::Darkfish
554
519
  # Generate an index page which lists all the classes which are documented.
555
520
 
556
521
  def generate_table_of_contents
557
- setup
558
-
559
522
  template_file = @template_dir + 'table_of_contents.rhtml'
560
523
  return unless template_file.exist?
561
524
 
@@ -584,7 +547,7 @@ class RDoc::Generator::Darkfish
584
547
  raise error
585
548
  end
586
549
 
587
- def install_rdoc_static_file source, destination, options # :nodoc:
550
+ def install_rdoc_static_file(source, destination, options) # :nodoc:
588
551
  return unless source.exist?
589
552
 
590
553
  begin
@@ -617,65 +580,13 @@ class RDoc::Generator::Darkfish
617
580
  @modsort = get_sorted_module_list @classes
618
581
  end
619
582
 
620
- ##
621
- # Return a string describing the amount of time in the given number of
622
- # seconds in terms a human can understand easily.
623
-
624
- def time_delta_string seconds
625
- return 'less than a minute' if seconds < 60
626
- return "#{seconds / 60} minute#{seconds / 60 == 1 ? '' : 's'}" if
627
- seconds < 3000 # 50 minutes
628
- return 'about one hour' if seconds < 5400 # 90 minutes
629
- return "#{seconds / 3600} hours" if seconds < 64800 # 18 hours
630
- return 'one day' if seconds < 86400 # 1 day
631
- return 'about one day' if seconds < 172800 # 2 days
632
- return "#{seconds / 86400} days" if seconds < 604800 # 1 week
633
- return 'about one week' if seconds < 1209600 # 2 week
634
- return "#{seconds / 604800} weeks" if seconds < 7257600 # 3 months
635
- return "#{seconds / 2419200} months" if seconds < 31536000 # 1 year
636
- return "#{seconds / 31536000} years"
637
- end
638
-
639
- # %q$Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $"
640
- SVNID_PATTERN = /
641
- \$Id:\s
642
- (\S+)\s # filename
643
- (\d+)\s # rev
644
- (\d{4}-\d{2}-\d{2})\s # Date (YYYY-MM-DD)
645
- (\d{2}:\d{2}:\d{2}Z)\s # Time (HH:MM:SSZ)
646
- (\w+)\s # committer
647
- \$$
648
- /x
649
-
650
- ##
651
- # Try to extract Subversion information out of the first constant whose
652
- # value looks like a subversion Id tag. If no matching constant is found,
653
- # and empty hash is returned.
654
-
655
- def get_svninfo klass
656
- constants = klass.constants or return {}
657
-
658
- constants.find { |c| c.value =~ SVNID_PATTERN } or return {}
659
-
660
- filename, rev, date, time, committer = $~.captures
661
- commitdate = Time.parse "#{date} #{time}"
662
-
663
- return {
664
- :filename => filename,
665
- :rev => Integer(rev),
666
- :commitdate => commitdate,
667
- :commitdelta => time_delta_string(Time.now - commitdate),
668
- :committer => committer,
669
- }
670
- end
671
-
672
583
  ##
673
584
  # Creates a template from its components and the +body_file+.
674
585
  #
675
586
  # For backwards compatibility, if +body_file+ contains "<html" the body is
676
587
  # used directly.
677
588
 
678
- def assemble_template body_file
589
+ def assemble_template(body_file)
679
590
  body = body_file.read
680
591
  return body if body =~ /<html/
681
592
 
@@ -684,7 +595,7 @@ class RDoc::Generator::Darkfish
684
595
  <<-TEMPLATE
685
596
  <!DOCTYPE html>
686
597
 
687
- <html>
598
+ <html lang="#{@options.locale&.name || 'en'}">
688
599
  <head>
689
600
  #{head_file.read}
690
601
 
@@ -696,7 +607,7 @@ class RDoc::Generator::Darkfish
696
607
  # Renders the ERb contained in +file_name+ relative to the template
697
608
  # directory and returns the result based on the current context.
698
609
 
699
- def render file_name
610
+ def render(file_name)
700
611
  template_file = @template_dir + file_name
701
612
 
702
613
  template = template_for template_file, false, RDoc::ERBPartial
@@ -714,7 +625,7 @@ class RDoc::Generator::Darkfish
714
625
  #
715
626
  # An io will be yielded which must be captured by binding in the caller.
716
627
 
717
- def render_template template_file, out_file = nil # :yield: io
628
+ def render_template(template_file, out_file = nil) # :yield: io
718
629
  io_output = out_file && !@dry_run && @file_output
719
630
  erb_klass = io_output ? RDoc::ERBIO : ERB
720
631
 
@@ -748,7 +659,7 @@ class RDoc::Generator::Darkfish
748
659
  # Creates the result for +template+ with +context+. If an error is raised a
749
660
  # Pathname +template_file+ will indicate the file where the error occurred.
750
661
 
751
- def template_result template, context, template_file
662
+ def template_result(template, context, template_file)
752
663
  template.filename = template_file.to_s
753
664
  template.result context
754
665
  rescue NoMethodError => e
@@ -761,7 +672,7 @@ class RDoc::Generator::Darkfish
761
672
  ##
762
673
  # Retrieves a cache template for +file+, if present, or fills the cache.
763
674
 
764
- def template_for file, page = true, klass = ERB
675
+ def template_for(file, page = true, klass = ERB)
765
676
  template = @template_cache[file]
766
677
 
767
678
  return template if template
@@ -783,6 +694,12 @@ class RDoc::Generator::Darkfish
783
694
  template
784
695
  end
785
696
 
697
+ # :stopdoc:
698
+ ParagraphExcerptRegexpOther = %r[\b\w[^./:]++\.]
699
+ # use \p/\P{letter} instead of \w/\W in Unicode
700
+ ParagraphExcerptRegexpUnicode = %r[\b\p{letter}[^./:]++\.]
701
+ # :startdoc:
702
+
786
703
  # Returns an excerpt of the comment for usage in meta description tags
787
704
  def excerpt(comment)
788
705
  text = case comment
@@ -794,14 +711,22 @@ class RDoc::Generator::Darkfish
794
711
 
795
712
  # Match from a capital letter to the first period, discarding any links, so
796
713
  # 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
714
+ pattern = ParagraphExcerptRegexpUnicode
715
+ begin
716
+ first_paragraph_match = text.match(pattern)
717
+ rescue Encoding::CompatibilityError
718
+ # The doc is non-ASCII text and encoded in other than Unicode base encodings.
719
+ raise if pattern == ParagraphExcerptRegexpOther
720
+ pattern = ParagraphExcerptRegexpOther
721
+ retry
722
+ end
723
+ return text[0...150].tr_s("\n", " ").squeeze(" ") unless first_paragraph_match
799
724
 
800
725
  extracted_text = first_paragraph_match[0]
801
- second_paragraph = first_paragraph_match.post_match.match(/[A-Z][^\.:\/]+\./)
726
+ second_paragraph = text.match(pattern, first_paragraph_match.end(0))
802
727
  extracted_text << " " << second_paragraph[0] if second_paragraph
803
728
 
804
- extracted_text[0...150].gsub(/\n/, " ").squeeze(" ")
729
+ extracted_text[0...150].tr_s("\n", " ").squeeze(" ")
805
730
  end
806
731
 
807
732
  def generate_ancestor_list(ancestors, klass)
@@ -821,4 +746,67 @@ class RDoc::Generator::Darkfish
821
746
 
822
747
  content << '</li></ul>'
823
748
  end
749
+
750
+ def generate_class_link(klass, rel_prefix)
751
+ if klass.display?
752
+ %(<code><a href="#{rel_prefix}/#{klass.path}">#{klass.name}</a></code>)
753
+ else
754
+ %(<code>#{klass.name}</code>)
755
+ end
756
+ end
757
+
758
+ def generate_class_index_content(classes, rel_prefix)
759
+ grouped_classes = group_classes_by_namespace_for_sidebar(classes)
760
+ return '' unless top = grouped_classes[nil]
761
+
762
+ solo = top.one? { |klass| klass.display? }
763
+ traverse_classes(top, grouped_classes, rel_prefix, solo)
764
+ end
765
+
766
+ def traverse_classes(klasses, grouped_classes, rel_prefix, solo = false)
767
+ content = +'<ul class="link-list">'
768
+
769
+ klasses.each do |index_klass|
770
+ if children = grouped_classes[index_klass.full_name]
771
+ content << %(<li><details#{solo ? ' open' : ''}><summary>#{generate_class_link(index_klass, rel_prefix)}</summary>)
772
+ content << traverse_classes(children, grouped_classes, rel_prefix)
773
+ content << '</details></li>'
774
+ solo = false
775
+ elsif index_klass.display?
776
+ content << %(<li>#{generate_class_link(index_klass, rel_prefix)}</li>)
777
+ end
778
+ end
779
+
780
+ "#{content}</ul>"
781
+ end
782
+
783
+ def group_classes_by_namespace_for_sidebar(classes)
784
+ grouped_classes = classes.group_by do |klass|
785
+ klass.full_name[/\A[^:]++(?:::[^:]++(?=::))*+(?=::[^:]*+\z)/]
786
+ end.select do |_, klasses|
787
+ klasses.any?(&:display?)
788
+ end
789
+
790
+ grouped_classes.values.each(&:uniq!)
791
+ grouped_classes
792
+ end
793
+
794
+ private
795
+
796
+ def nesting_namespaces_to_class_modules(klass)
797
+ tree = {}
798
+
799
+ klass.nesting_namespaces.zip(klass.fully_qualified_nesting_namespaces) do |ns, fqns|
800
+ tree[ns] = @store.classes_hash[fqns] || @store.modules_hash[fqns]
801
+ end
802
+
803
+ tree
804
+ end
805
+
806
+ def generate_nesting_namespaces_breadcrumb(klass, rel_prefix)
807
+ nesting_namespaces_to_class_modules(klass).map do |namespace, class_module|
808
+ path = class_module ? (rel_prefix + class_module.path).to_s : ""
809
+ { name: namespace, path: path, self: klass.full_name == class_module&.full_name }
810
+ end
811
+ end
824
812
  end
@@ -86,12 +86,10 @@ class RDoc::Generator::JsonIndex
86
86
  attr_reader :index # :nodoc:
87
87
 
88
88
  ##
89
- # Creates a new generator. +parent_generator+ is used to determine the
90
- # class_dir and file_dir of links in the output index.
91
- #
89
+ # Creates a new generator.
92
90
  # +options+ are the same options passed to the parent generator.
93
91
 
94
- def initialize parent_generator, options
92
+ def initialize(parent_generator, options)
95
93
  @parent_generator = parent_generator
96
94
  @store = parent_generator.store
97
95
  @options = options
@@ -265,21 +263,7 @@ class RDoc::Generator::JsonIndex
265
263
  end
266
264
  end
267
265
 
268
- ##
269
- # The directory classes are written to
270
-
271
- def class_dir
272
- @parent_generator.class_dir
273
- end
274
-
275
- ##
276
- # The directory files are written to
277
-
278
- def file_dir
279
- @parent_generator.file_dir
280
- end
281
-
282
- def reset files, classes # :nodoc:
266
+ def reset(files, classes) # :nodoc:
283
267
  @files = files
284
268
  @classes = classes
285
269
 
@@ -293,7 +277,7 @@ class RDoc::Generator::JsonIndex
293
277
  ##
294
278
  # Removes whitespace and downcases +string+
295
279
 
296
- def search_string string
280
+ def search_string(string)
297
281
  string.downcase.gsub(/\s/, '')
298
282
  end
299
283
 
@@ -34,7 +34,7 @@ module RDoc::Generator::Markup
34
34
  def formatter
35
35
  return @formatter if defined? @formatter
36
36
 
37
- options = @store.rdoc.options
37
+ options = @store.options
38
38
  this = RDoc::Context === self ? self : @parent
39
39
 
40
40
  @formatter = RDoc::Markup::ToHtmlCrossref.new options, this.path, this
@@ -55,6 +55,18 @@ module RDoc::Generator::Markup
55
55
  end
56
56
  end
57
57
 
58
+ ##
59
+ # The preferred URL for this object.
60
+
61
+ def canonical_url
62
+ options = @store.options
63
+ if path
64
+ File.join(options.canonical_root, path.to_s)
65
+ else
66
+ options.canonical_root
67
+ end
68
+ end
69
+
58
70
  end
59
71
 
60
72
  class RDoc::CodeObject
@@ -147,7 +159,7 @@ class RDoc::TopLevel
147
159
  # command line option to set.
148
160
 
149
161
  def cvs_url
150
- url = @store.rdoc.options.webcvs
162
+ url = @store.options.webcvs
151
163
 
152
164
  if /%s/ =~ url then
153
165
  url % @relative_name
@@ -7,7 +7,7 @@ class RDoc::Generator::POT::MessageExtractor
7
7
  ##
8
8
  # Creates a message extractor for +store+.
9
9
 
10
- def initialize store
10
+ def initialize(store)
11
11
  @store = store
12
12
  @po = RDoc::Generator::POT::PO.new
13
13
  end
@@ -25,7 +25,7 @@ class RDoc::Generator::POT::MessageExtractor
25
25
 
26
26
  private
27
27
 
28
- def extract_from_klass klass
28
+ def extract_from_klass(klass)
29
29
  extract_text(klass.comment_location, klass.full_name)
30
30
 
31
31
  klass.each_section do |section, constants, attributes|
@@ -35,11 +35,11 @@ class RDoc::Generator::POT::MessageExtractor
35
35
  end
36
36
  end
37
37
 
38
- klass.each_constant do |constant|
38
+ klass.constants.each do |constant|
39
39
  extract_text(constant.comment, constant.full_name)
40
40
  end
41
41
 
42
- klass.each_attribute do |attribute|
42
+ klass.attributes.each do |attribute|
43
43
  extract_text(attribute.comment, attribute.full_name)
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ class RDoc::Generator::POT::MessageExtractor
48
48
  end
49
49
  end
50
50
 
51
- def extract_text text, comment, location = nil
51
+ def extract_text(text, comment, location = nil)
52
52
  return if text.nil?
53
53
 
54
54
  options = {
@@ -61,7 +61,7 @@ class RDoc::Generator::POT::MessageExtractor
61
61
  end
62
62
  end
63
63
 
64
- def entry msgid, options
64
+ def entry(msgid, options)
65
65
  RDoc::Generator::POT::POEntry.new(msgid, options)
66
66
  end
67
67
 
@@ -15,7 +15,7 @@ class RDoc::Generator::POT::PO
15
15
  ##
16
16
  # Adds a PO entry to the PO.
17
17
 
18
- def add entry
18
+ def add(entry)
19
19
  existing_entry = @entries[entry.msgid]
20
20
  if existing_entry
21
21
  entry = existing_entry.merge(entry)