rdoc 6.14.2 → 6.15.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.
@@ -158,19 +158,16 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
158
158
  def handle_regexp_TIDYLINK(target)
159
159
  text = target.text
160
160
 
161
- return text unless
162
- text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/
163
-
164
- label = $1
165
- url = CGI.escapeHTML($2)
161
+ if tidy_link_capturing?
162
+ return finish_tidy_link(text)
163
+ end
166
164
 
167
- if /^rdoc-image:/ =~ label
168
- label = handle_RDOCLINK(label)
169
- else
170
- label = CGI.escapeHTML(label)
165
+ if text.start_with?('{') && !text.include?('}')
166
+ start_tidy_link text
167
+ return ''
171
168
  end
172
169
 
173
- gen_url url, label
170
+ convert_complete_tidy_link(text)
174
171
  end
175
172
 
176
173
  # :section: Visitor
@@ -458,4 +455,153 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
458
455
  super convert_flow @am.flow item
459
456
  end
460
457
 
458
+ private
459
+
460
+ def convert_flow(flow_items)
461
+ res = []
462
+
463
+ flow_items.each do |item|
464
+ case item
465
+ when String
466
+ append_flow_fragment res, convert_string(item)
467
+ when RDoc::Markup::AttrChanger
468
+ off_tags res, item
469
+ on_tags res, item
470
+ when RDoc::Markup::RegexpHandling
471
+ append_flow_fragment res, convert_regexp_handling(item)
472
+ else
473
+ raise "Unknown flow element: #{item.inspect}"
474
+ end
475
+ end
476
+
477
+ res.join
478
+ end
479
+
480
+ def append_flow_fragment(res, fragment)
481
+ return if fragment.nil? || fragment.empty?
482
+
483
+ emit_tidy_link_fragment(res, fragment)
484
+ end
485
+
486
+ def append_to_tidy_label(fragment)
487
+ @tidy_link_buffer << fragment
488
+ end
489
+
490
+ ##
491
+ # Matches an entire tidy link with a braced label "{label}[url]".
492
+ #
493
+ # Capture 1: label contents.
494
+ # Capture 2: URL text.
495
+ # Capture 3: trailing content.
496
+ TIDY_LINK_WITH_BRACES = /\A\{(.*?)\}\[(.*?)\](.*)\z/
497
+
498
+ ##
499
+ # Matches the tail of a braced tidy link when the opening brace was
500
+ # consumed earlier while accumulating the label text.
501
+ #
502
+ # Capture 1: remaining label content.
503
+ # Capture 2: URL text.
504
+ # Capture 3: trailing content.
505
+ TIDY_LINK_WITH_BRACES_TAIL = /\A(.*?)\}\[(.*?)\](.*)\z/
506
+
507
+ ##
508
+ # Matches a tidy link with a single-word label "label[url]".
509
+ #
510
+ # Capture 1: the single-word label (no whitespace).
511
+ # Capture 2: URL text between the brackets.
512
+ TIDY_LINK_SINGLE_WORD = /\A(\S+)\[(.*?)\](.*)\z/
513
+
514
+ def convert_complete_tidy_link(text)
515
+ return text unless
516
+ text =~ TIDY_LINK_WITH_BRACES or text =~ TIDY_LINK_SINGLE_WORD
517
+
518
+ label = $1
519
+ url = CGI.escapeHTML($2)
520
+
521
+ label_html = if /^rdoc-image:/ =~ label
522
+ handle_RDOCLINK(label)
523
+ else
524
+ render_tidy_link_label(label)
525
+ end
526
+
527
+ gen_url url, label_html
528
+ end
529
+
530
+ def emit_tidy_link_fragment(res, fragment)
531
+ if tidy_link_capturing?
532
+ append_to_tidy_label fragment
533
+ else
534
+ res << fragment
535
+ end
536
+ end
537
+
538
+ def finish_tidy_link(text)
539
+ label_tail, url, trailing = extract_tidy_link_parts(text)
540
+ append_to_tidy_label CGI.escapeHTML(label_tail) unless label_tail.empty?
541
+
542
+ return '' unless url
543
+
544
+ label_html = @tidy_link_buffer
545
+ @tidy_link_buffer = nil
546
+ link = gen_url(url, label_html)
547
+
548
+ return link if trailing.empty?
549
+
550
+ link + CGI.escapeHTML(trailing)
551
+ end
552
+
553
+ def extract_tidy_link_parts(text)
554
+ if text =~ TIDY_LINK_WITH_BRACES
555
+ [$1, CGI.escapeHTML($2), $3]
556
+ elsif text =~ TIDY_LINK_WITH_BRACES_TAIL
557
+ [$1, CGI.escapeHTML($2), $3]
558
+ elsif text =~ TIDY_LINK_SINGLE_WORD
559
+ [$1, CGI.escapeHTML($2), $3]
560
+ else
561
+ [text, nil, '']
562
+ end
563
+ end
564
+
565
+ def on_tags(res, item)
566
+ each_attr_tag(item.turn_on) do |tag|
567
+ emit_tidy_link_fragment(res, annotate(tag.on))
568
+ @in_tt += 1 if tt? tag
569
+ end
570
+ end
571
+
572
+ def off_tags(res, item)
573
+ each_attr_tag(item.turn_off, true) do |tag|
574
+ emit_tidy_link_fragment(res, annotate(tag.off))
575
+ @in_tt -= 1 if tt? tag
576
+ end
577
+ end
578
+
579
+ def start_tidy_link(text)
580
+ @tidy_link_buffer = String.new
581
+ append_to_tidy_label CGI.escapeHTML(text.delete_prefix('{'))
582
+ end
583
+
584
+ def tidy_link_capturing?
585
+ !!@tidy_link_buffer
586
+ end
587
+
588
+ def render_tidy_link_label(label)
589
+ RDoc::Markup::LinkLabelToHtml.render(label, @options, @from_path)
590
+ end
591
+ end
592
+
593
+ ##
594
+ # Formatter dedicated to rendering tidy link labels without mutating the
595
+ # calling formatter's state.
596
+
597
+ class RDoc::Markup::LinkLabelToHtml < RDoc::Markup::ToHtml
598
+ def self.render(label, options, from_path)
599
+ new(options, from_path).to_html(label)
600
+ end
601
+
602
+ def initialize(options, from_path = nil)
603
+ super(options)
604
+
605
+ self.from_path = from_path if from_path
606
+ end
461
607
  end
@@ -184,38 +184,35 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
184
184
  end
185
185
  end
186
186
 
187
- def convert_flow(flow)
187
+ def convert_flow(flow_items, &block)
188
188
  res = []
189
189
 
190
190
  i = 0
191
- while i < flow.size
192
- item = flow[i]
193
- i += 1
191
+ while i < flow_items.size
192
+ item = flow_items[i]
193
+
194
194
  case item
195
- when RDoc::Markup::AttrChanger then
196
- # Make "+Class#method+" a cross reference
197
- if tt_tag?(item.turn_on) and
198
- String === (str = flow[i]) and
199
- RDoc::Markup::AttrChanger === flow[i+1] and
200
- tt_tag?(flow[i+1].turn_off, true) and
201
- (@options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP).match?(str) and
202
- (text = cross_reference str) != str
203
- then
204
- text = yield text, res if defined?(yield)
205
- res << text
206
- i += 2
195
+ when RDoc::Markup::AttrChanger
196
+ if !tidy_link_capturing? && (text = convert_tt_crossref(flow_items, i))
197
+ text = block.call(text, res) if block
198
+ append_flow_fragment res, text
199
+ i += 3
207
200
  next
208
201
  end
202
+
209
203
  off_tags res, item
210
- on_tags res, item
211
- when String then
204
+ on_tags res, item
205
+ i += 1
206
+ when String
212
207
  text = convert_string(item)
213
- text = yield text, res if defined?(yield)
214
- res << text
215
- when RDoc::Markup::RegexpHandling then
208
+ text = block.call(text, res) if block
209
+ append_flow_fragment res, text
210
+ i += 1
211
+ when RDoc::Markup::RegexpHandling
216
212
  text = convert_regexp_handling(item)
217
- text = yield text, res if defined?(yield)
218
- res << text
213
+ text = block.call(text, res) if block
214
+ append_flow_fragment res, text
215
+ i += 1
219
216
  else
220
217
  raise "Unknown flow element: #{item.inspect}"
221
218
  end
@@ -223,4 +220,37 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
223
220
 
224
221
  res.join('')
225
222
  end
223
+
224
+ private
225
+
226
+ ##
227
+ # Detects <tt>...</tt> spans that contain a single cross-reference candidate.
228
+ # When the candidate occupies the whole span (aside from trailing
229
+ # punctuation), the tt markup is replaced by the resolved cross-reference.
230
+
231
+ def convert_tt_crossref(flow_items, index)
232
+ opener = flow_items[index]
233
+ return unless tt_tag?(opener.turn_on)
234
+
235
+ string = flow_items[index + 1]
236
+ closer = flow_items[index + 2]
237
+
238
+ return unless String === string
239
+ return unless RDoc::Markup::AttrChanger === closer
240
+ return unless tt_tag?(closer.turn_off, true)
241
+
242
+ crossref_regexp = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
243
+ match = crossref_regexp.match(string)
244
+ return unless match
245
+ return unless match.begin(1).zero?
246
+
247
+ trailing = match.post_match
248
+ # Only convert when the remainder is punctuation/whitespace so other tt text stays literal.
249
+ return unless trailing.match?(/\A[[:punct:]\s]*\z/)
250
+
251
+ text = cross_reference(string)
252
+ return if text == string
253
+
254
+ text
255
+ end
226
256
  end
data/lib/rdoc/options.rb CHANGED
@@ -327,7 +327,7 @@ class RDoc::Options
327
327
 
328
328
  ##
329
329
  # Warn if rdoc-ref links can't be resolved
330
- # Default is +false+
330
+ # Default is +true+
331
331
 
332
332
  attr_accessor :warn_missing_rdoc_ref
333
333
 
data/lib/rdoc/ri/task.rb CHANGED
@@ -26,8 +26,8 @@ require_relative '../task'
26
26
  # require 'rdoc/ri/task'
27
27
  #
28
28
  # RDoc::RI::Task.new do |ri|
29
- # ri.main = 'README.rdoc'
30
- # ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
29
+ # ri.main = 'README.md'
30
+ # ri.rdoc_files.include 'README.md', 'lib/**/*.rb'
31
31
  # end
32
32
  #
33
33
  # For further configuration details see RDoc::Task.
data/lib/rdoc/store.rb CHANGED
@@ -720,10 +720,10 @@ class RDoc::Store
720
720
  end
721
721
 
722
722
  ##
723
- # Returns the RDoc::TopLevel that is a text file and has the given +name+
723
+ # Returns the RDoc::TopLevel that is a file and has the given +name+
724
724
 
725
725
  def page(name)
726
- @text_files_hash.each_value.find do |file|
726
+ @files_hash.each_value.find do |file|
727
727
  file.page_name == name or file.base_name == name
728
728
  end
729
729
  end
data/lib/rdoc/task.rb CHANGED
@@ -58,8 +58,8 @@ require 'rake/tasklib'
58
58
  # require 'rdoc/task'
59
59
  #
60
60
  # RDoc::Task.new do |rdoc|
61
- # rdoc.main = "README.rdoc"
62
- # rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
61
+ # rdoc.main = "README.md"
62
+ # rdoc.rdoc_files.include("README.md", "lib/**/*.rb")
63
63
  # end
64
64
  #
65
65
  # The +rdoc+ object passed to the block is an RDoc::Task object. See the
@@ -74,8 +74,8 @@ require 'rake/tasklib'
74
74
  # require 'rdoc/task'
75
75
  #
76
76
  # RDoc::Task.new :rdoc_dev do |rdoc|
77
- # rdoc.main = "README.rdoc"
78
- # rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
77
+ # rdoc.main = "README.md"
78
+ # rdoc.rdoc_files.include("README.md", "lib/**/*.rb")
79
79
  # rdoc.options << "--all"
80
80
  # end
81
81
  #
data/lib/rdoc/version.rb CHANGED
@@ -5,6 +5,6 @@ module RDoc
5
5
  ##
6
6
  # RDoc version you are using
7
7
 
8
- VERSION = '6.14.2'
8
+ VERSION = '6.15.0'
9
9
 
10
10
  end
data/rdoc.gemspec CHANGED
@@ -45,7 +45,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
45
45
  "History.rdoc",
46
46
  "LEGAL.rdoc",
47
47
  "LICENSE.rdoc",
48
- "README.rdoc",
48
+ "README.md",
49
49
  "RI.md",
50
50
  "TODO.rdoc",
51
51
  "exe/rdoc",
@@ -60,7 +60,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
60
60
 
61
61
  s.files = (non_lib_files + template_files + lib_files).uniq
62
62
 
63
- s.rdoc_options = ["--main", "README.rdoc"]
63
+ s.rdoc_options = ["--main", "README.md"]
64
64
  s.extra_rdoc_files += s.files.grep(%r[\A[^\/]+\.(?:rdoc|md)\z])
65
65
 
66
66
  s.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
@@ -68,4 +68,5 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
68
68
 
69
69
  s.add_dependency 'psych', '>= 4.0.0'
70
70
  s.add_dependency 'erb'
71
+ s.add_dependency 'tsort'
71
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.14.2
4
+ version: 6.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -13,7 +13,7 @@ authors:
13
13
  - ITOYANAGI Sakura
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2025-07-03 00:00:00.000000000 Z
16
+ date: 2025-10-04 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: psych
@@ -43,6 +43,20 @@ dependencies:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: tsort
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
46
60
  description: |
47
61
  RDoc produces HTML and command-line documentation for Ruby projects.
48
62
  RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentation from the command-line.
@@ -66,7 +80,7 @@ extra_rdoc_files:
66
80
  - History.rdoc
67
81
  - LEGAL.rdoc
68
82
  - LICENSE.rdoc
69
- - README.rdoc
83
+ - README.md
70
84
  - RI.md
71
85
  - TODO.rdoc
72
86
  files:
@@ -77,7 +91,7 @@ files:
77
91
  - History.rdoc
78
92
  - LEGAL.rdoc
79
93
  - LICENSE.rdoc
80
- - README.rdoc
94
+ - README.md
81
95
  - RI.md
82
96
  - TODO.rdoc
83
97
  - exe/rdoc
@@ -268,7 +282,7 @@ metadata:
268
282
  changelog_uri: https://github.com/ruby/rdoc/releases
269
283
  rdoc_options:
270
284
  - "--main"
271
- - README.rdoc
285
+ - README.md
272
286
  require_paths:
273
287
  - lib
274
288
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.rdoc DELETED
@@ -1,144 +0,0 @@
1
- = \RDoc - Ruby Documentation System
2
-
3
- home :: https://github.com/ruby/rdoc
4
- rdoc :: https://ruby.github.io/rdoc
5
- bugs :: https://github.com/ruby/rdoc/issues
6
- code quality :: https://codeclimate.com/github/ruby/rdoc
7
-
8
- == Description
9
-
10
- RDoc produces HTML and command-line documentation for Ruby projects. RDoc
11
- includes the +rdoc+ and +ri+ tools for generating and displaying documentation
12
- from the command-line.
13
-
14
- == Generating Documentation
15
-
16
- Once installed, you can create documentation using the +rdoc+ command
17
-
18
- $ rdoc [options] [names...]
19
-
20
- For an up-to-date option summary, type
21
-
22
- $ rdoc --help
23
-
24
- A typical use might be to generate documentation for a package of Ruby
25
- source (such as RDoc itself).
26
-
27
- $ rdoc
28
-
29
- This command generates documentation for all the Ruby and C source
30
- files in and below the current directory. These will be stored in a
31
- documentation tree starting in the subdirectory +doc+.
32
-
33
- You can make this slightly more useful for your readers by having the
34
- index page contain the documentation for the primary file. In our
35
- case, we could type
36
-
37
- % rdoc --main README.rdoc
38
-
39
- You'll find information on the various formatting tricks you can use
40
- in comment blocks in the documentation this generates.
41
-
42
- RDoc uses file extensions to determine how to process each file. File names
43
- ending +.rb+ and +.rbw+ are assumed to be Ruby source. Files
44
- ending +.c+ are parsed as C files. All other files are assumed to
45
- contain just Markup-style markup (with or without leading '#' comment
46
- markers). If directory names are passed to RDoc, they are scanned
47
- recursively for C and Ruby source files only.
48
-
49
- To generate documentation using +rake+ see RDoc::Task[https://ruby.github.io/rdoc/RDoc/Task.html].
50
-
51
- To generate documentation programmatically:
52
-
53
- gem 'rdoc'
54
- require 'rdoc/rdoc'
55
-
56
- options = RDoc::Options.new
57
- options.files = ['a.rb', 'b.rb']
58
- options.setup_generator 'darkfish'
59
- # see RDoc::Options
60
-
61
- rdoc = RDoc::RDoc.new
62
- rdoc.document options
63
- # see RDoc::RDoc
64
-
65
- You can specify the target files for document generation with +.document+ file in the project root directory.
66
- +.document+ file contains a list of file and directory names including comment lines starting with '#'.
67
- See https://github.com/ruby/rdoc/blob/master/.document as an example.
68
-
69
- == Writing Documentation
70
-
71
- To write documentation for RDoc place a comment above the class, module,
72
- method, constant, or attribute you want documented:
73
-
74
- ##
75
- # This class represents an arbitrary shape by a series of points.
76
-
77
- class Shape
78
-
79
- ##
80
- # Creates a new shape described by a +polyline+.
81
- #
82
- # If the +polyline+ does not end at the same point it started at the
83
- # first pointed is copied and placed at the end of the line.
84
- #
85
- # An ArgumentError is raised if the line crosses itself, but shapes may
86
- # be concave.
87
-
88
- def initialize polyline
89
- # ...
90
- end
91
-
92
- end
93
-
94
- The default comment markup format is the RDoc::Markup format.
95
- TomDoc[rdoc-ref:RDoc::TomDoc], Markdown[rdoc-ref:RDoc::Markdown] and
96
- RD[rdoc-ref:RDoc::RD] format comments are also supported. You can set the
97
- default comment format for your entire project by creating a
98
- <tt>.rdoc_options</tt> file. See RDoc::Options@Saved+Options for instructions
99
- on creating one. You can also set the comment format for a single file
100
- through the +:markup:+ directive, but this is only recommended if you wish to
101
- switch markup formats. See RDoc::Markup@Other+directives.
102
-
103
- Comments can contain directives that tell RDoc information that it cannot
104
- otherwise discover through parsing. See RDoc::Markup@Directives to control
105
- what is or is not documented, to define method arguments or to break up
106
- methods in a class by topic. See RDoc::Parser::Ruby for directives used to
107
- teach RDoc about metaprogrammed methods.
108
-
109
- See RDoc::Parser::C for documenting C extensions with RDoc.
110
-
111
- To determine how well your project is documented run <tt>rdoc -C lib</tt> to
112
- get a documentation coverage report. <tt>rdoc -C1 lib</tt> includes parameter
113
- names in the documentation coverage report.
114
-
115
- == Theme Options
116
-
117
- There are a few community-maintained themes for \RDoc:
118
-
119
- - rorvswild-theme-rdoc[https://github.com/BaseSecrete/rorvswild-theme-rdoc]
120
- - hanna[https://github.com/jeremyevans/hanna] (a fork maintained by {Jeremy Evans}[https://github.com/jeremyevans])
121
-
122
- Please follow the theme's README for usage instructions.
123
-
124
- == Bugs
125
-
126
- See CONTRIBUTING.rdoc for information on filing a bug report. It's OK to file
127
- a bug report for anything you're having a problem with. If you can't figure
128
- out how to make RDoc produce the output you like that is probably a
129
- documentation bug.
130
-
131
- == License
132
-
133
- RDoc is Copyright (c) 2001-2003 Dave Thomas, The Pragmatic Programmers.
134
- Portions (c) 2007-2011 Eric Hodel. Portions copyright others, see individual
135
- files and LEGAL.rdoc for details.
136
-
137
- RDoc is free software, and may be redistributed under the terms specified in
138
- LICENSE.rdoc.
139
-
140
- == Warranty
141
-
142
- This software is provided "as is" and without any express or implied
143
- warranties, including, without limitation, the implied warranties of
144
- merchantability and fitness for a particular purpose.