rdoc 7.0.2 → 7.0.4

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +9 -0
  3. data/lib/rdoc/code_object/class_module.rb +20 -5
  4. data/lib/rdoc/generator/darkfish.rb +1 -1
  5. data/lib/rdoc/generator/json_index.rb +1 -1
  6. data/lib/rdoc/generator/template/aliki/_head.rhtml +1 -1
  7. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
  8. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
  9. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
  10. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
  11. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
  12. data/lib/rdoc/generator/template/aliki/class.rhtml +17 -17
  13. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +1 -1
  14. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
  15. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
  16. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
  17. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +2 -2
  18. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
  20. data/lib/rdoc/generator/template/darkfish/class.rhtml +17 -17
  21. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  22. data/lib/rdoc/markup/blank_line.rb +25 -23
  23. data/lib/rdoc/markup/document.rb +2 -2
  24. data/lib/rdoc/markup/element.rb +21 -0
  25. data/lib/rdoc/markup/formatter.rb +1 -1
  26. data/lib/rdoc/markup/hard_break.rb +30 -27
  27. data/lib/rdoc/markup/heading.rb +96 -79
  28. data/lib/rdoc/markup/indented_paragraph.rb +1 -1
  29. data/lib/rdoc/markup/list.rb +2 -2
  30. data/lib/rdoc/markup/list_item.rb +2 -2
  31. data/lib/rdoc/markup/raw.rb +52 -55
  32. data/lib/rdoc/markup/table.rb +48 -40
  33. data/lib/rdoc/markup/verbatim.rb +1 -1
  34. data/lib/rdoc/markup.rb +1 -0
  35. data/lib/rdoc/parser/c.rb +1 -1
  36. data/lib/rdoc/ri/paths.rb +1 -1
  37. data/lib/rdoc/servlet.rb +1 -1
  38. data/lib/rdoc/version.rb +1 -1
  39. metadata +3 -2
@@ -1,27 +1,29 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # An empty line. This class is a singleton.
4
2
 
5
- class RDoc::Markup::BlankLine
6
-
7
- @instance = new
8
-
9
- ##
10
- # RDoc::Markup::BlankLine is a singleton
11
-
12
- def self.new
13
- @instance
3
+ module RDoc
4
+ class Markup
5
+ # An empty line
6
+ class BlankLine < Element
7
+ @instance = new
8
+
9
+ # RDoc::Markup::BlankLine is a singleton
10
+ #: () -> BlankLine
11
+ def self.new
12
+ @instance
13
+ end
14
+
15
+ # Calls #accept_blank_line on +visitor+
16
+ # @override
17
+ #: (untyped) -> void
18
+ def accept(visitor)
19
+ visitor.accept_blank_line(self)
20
+ end
21
+
22
+ # @override
23
+ #: (PP) -> void
24
+ def pretty_print(q) # :nodoc:
25
+ q.text("blankline")
26
+ end
27
+ end
14
28
  end
15
-
16
- ##
17
- # Calls #accept_blank_line on +visitor+
18
-
19
- def accept(visitor)
20
- visitor.accept_blank_line self
21
- end
22
-
23
- def pretty_print(q) # :nodoc:
24
- q.text 'blankline'
25
- end
26
-
27
29
  end
@@ -26,7 +26,7 @@ class RDoc::Markup::Document
26
26
  ##
27
27
  # Creates a new Document with +parts+
28
28
 
29
- def initialize *parts
29
+ def initialize(*parts)
30
30
  @parts = []
31
31
  @parts.concat parts
32
32
 
@@ -148,7 +148,7 @@ class RDoc::Markup::Document
148
148
  ##
149
149
  # Appends +parts+ to the document
150
150
 
151
- def push *parts
151
+ def push(*parts)
152
152
  self.parts.concat parts
153
153
  end
154
154
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RDoc
4
+ class Markup
5
+ # Base class defining the interface for all markup elements found in documentation
6
+ # @abstract
7
+ class Element
8
+ # @abstract
9
+ #: (untyped) -> void
10
+ def accept(visitor)
11
+ raise NotImplementedError, "#{self.class} must implement the accept method"
12
+ end
13
+
14
+ # @abstract
15
+ #: (PP) -> void
16
+ def pretty_print(q)
17
+ raise NotImplementedError, "#{self.class} must implement the pretty_print method"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -185,7 +185,7 @@ class RDoc::Markup::Formatter
185
185
  #
186
186
  # alias accept_raw ignore
187
187
 
188
- def ignore *node
188
+ def ignore(*node)
189
189
  end
190
190
 
191
191
  ##
@@ -1,31 +1,34 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A hard-break in the middle of a paragraph.
4
2
 
5
- class RDoc::Markup::HardBreak
6
-
7
- @instance = new
8
-
9
- ##
10
- # RDoc::Markup::HardBreak is a singleton
11
-
12
- def self.new
13
- @instance
14
- end
15
-
16
- ##
17
- # Calls #accept_hard_break on +visitor+
18
-
19
- def accept(visitor)
20
- visitor.accept_hard_break self
3
+ module RDoc
4
+ class Markup
5
+ # A hard-break in the middle of a paragraph.
6
+ class HardBreak < Element
7
+ @instance = new
8
+
9
+ # RDoc::Markup::HardBreak is a singleton
10
+ #: () -> HardBreak
11
+ def self.new
12
+ @instance
13
+ end
14
+
15
+ # Calls #accept_hard_break on +visitor+
16
+ # @override
17
+ #: (untyped) -> void
18
+ def accept(visitor)
19
+ visitor.accept_hard_break(self)
20
+ end
21
+
22
+ #: (top) -> bool
23
+ def ==(other) # :nodoc:
24
+ self.class === other
25
+ end
26
+
27
+ # @override
28
+ #: (PP) -> void
29
+ def pretty_print(q) # :nodoc:
30
+ q.text("[break]")
31
+ end
32
+ end
21
33
  end
22
-
23
- def ==(other) # :nodoc:
24
- self.class === other
25
- end
26
-
27
- def pretty_print(q) # :nodoc:
28
- q.text "[break]"
29
- end
30
-
31
34
  end
@@ -1,84 +1,101 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A heading with a level (1-6) and text
4
2
 
5
- RDoc::Markup::Heading =
6
- Struct.new :level, :text do
7
-
8
- @to_html = nil
9
- @to_label = nil
10
-
11
- ##
12
- # A singleton RDoc::Markup::ToLabel formatter for headings.
13
-
14
- def self.to_label
15
- @to_label ||= RDoc::Markup::ToLabel.new
16
- end
17
-
18
- ##
19
- # A singleton plain HTML formatter for headings. Used for creating labels
20
- # for the Table of Contents
21
-
22
- def self.to_html
23
- return @to_html if @to_html
24
-
25
- markup = RDoc::Markup.new
26
- markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
27
-
28
- @to_html = RDoc::Markup::ToHtml.new nil
29
-
30
- def @to_html.handle_regexp_CROSSREF(target)
31
- target.text.sub(/^\\/, '')
3
+ module RDoc
4
+ class Markup
5
+ # A heading with a level (1-6) and text
6
+ #
7
+ # RDoc syntax:
8
+ # = Heading 1
9
+ # == Heading 2
10
+ # === Heading 3
11
+ #
12
+ # Markdown syntax:
13
+ # # Heading 1
14
+ # ## Heading 2
15
+ # ### Heading 3
16
+ class Heading < Element
17
+ #: String
18
+ attr_reader :text
19
+
20
+ #: Integer
21
+ attr_accessor :level
22
+
23
+ # A singleton RDoc::Markup::ToLabel formatter for headings.
24
+ #: () -> RDoc::Markup::ToLabel
25
+ def self.to_label
26
+ @to_label ||= Markup::ToLabel.new
27
+ end
28
+
29
+ # A singleton plain HTML formatter for headings. Used for creating labels for the Table of Contents
30
+ #: () -> RDoc::Markup::ToHtml
31
+ def self.to_html
32
+ @to_html ||= begin
33
+ markup = Markup.new
34
+ markup.add_regexp_handling CrossReference::CROSSREF_REGEXP, :CROSSREF
35
+
36
+ to_html = Markup::ToHtml.new nil
37
+
38
+ def to_html.handle_regexp_CROSSREF(target)
39
+ target.text.sub(/^\\/, '')
40
+ end
41
+
42
+ to_html
43
+ end
44
+ end
45
+
46
+ #: (Integer, String) -> void
47
+ def initialize(level, text)
48
+ super()
49
+
50
+ @level = level
51
+ @text = text
52
+ end
53
+
54
+ #: (Object) -> bool
55
+ def ==(other)
56
+ other.is_a?(Heading) && other.level == @level && other.text == @text
57
+ end
58
+
59
+ # @override
60
+ #: (untyped) -> void
61
+ def accept(visitor)
62
+ visitor.accept_heading(self)
63
+ end
64
+
65
+ # An HTML-safe anchor reference for this header.
66
+ #: () -> String
67
+ def aref
68
+ "label-#{self.class.to_label.convert text.dup}"
69
+ end
70
+
71
+ # Creates a fully-qualified label which will include the label from +context+. This helps keep ids unique in HTML.
72
+ #: (RDoc::Context?) -> String
73
+ def label(context = nil)
74
+ label = +""
75
+ label << "#{context.aref}-" if context&.respond_to?(:aref)
76
+ label << aref
77
+ label
78
+ end
79
+
80
+ # HTML markup of the text of this label without the surrounding header element.
81
+ #: () -> String
82
+ def plain_html
83
+ no_image_text = text
84
+
85
+ if matched = no_image_text.match(/rdoc-image:[^:]+:(.*)/)
86
+ no_image_text = matched[1]
87
+ end
88
+
89
+ self.class.to_html.to_html(no_image_text)
90
+ end
91
+
92
+ # @override
93
+ #: (PP) -> void
94
+ def pretty_print(q)
95
+ q.group 2, "[head: #{level} ", ']' do
96
+ q.pp text
97
+ end
98
+ end
32
99
  end
33
-
34
- @to_html
35
- end
36
-
37
- ##
38
- # Calls #accept_heading on +visitor+
39
-
40
- def accept(visitor)
41
- visitor.accept_heading self
42
- end
43
-
44
- ##
45
- # An HTML-safe anchor reference for this header.
46
-
47
- def aref
48
- "label-#{self.class.to_label.convert text.dup}"
49
100
  end
50
-
51
- ##
52
- # Creates a fully-qualified label which will include the label from
53
- # +context+. This helps keep ids unique in HTML.
54
-
55
- def label(context = nil)
56
- label = aref
57
-
58
- label = [context.aref, label].compact.join '-' if
59
- context and context.respond_to? :aref
60
-
61
- label
62
- end
63
-
64
- ##
65
- # HTML markup of the text of this label without the surrounding header
66
- # element.
67
-
68
- def plain_html
69
- text = self.text.dup
70
-
71
- if matched = text.match(/rdoc-image:[^:]+:(.*)/)
72
- text = matched[1]
73
- end
74
-
75
- self.class.to_html.to_html(text)
76
- end
77
-
78
- def pretty_print(q) # :nodoc:
79
- q.group 2, "[head: #{level} ", ']' do
80
- q.pp text
81
- end
82
- end
83
-
84
101
  end
@@ -13,7 +13,7 @@ class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
13
13
  # Creates a new IndentedParagraph containing +parts+ indented with +indent+
14
14
  # spaces
15
15
 
16
- def initialize indent, *parts
16
+ def initialize(indent, *parts)
17
17
  @indent = indent
18
18
 
19
19
  super(*parts)
@@ -37,7 +37,7 @@ class RDoc::Markup::List
37
37
  # Creates a new list of +type+ with +items+. Valid list types are:
38
38
  # +:BULLET+, +:LABEL+, +:LALPHA+, +:NOTE+, +:NUMBER+, +:UALPHA+
39
39
 
40
- def initialize type = nil, *items
40
+ def initialize(type = nil, *items)
41
41
  @type = type
42
42
  @items = []
43
43
  @items.concat items
@@ -94,7 +94,7 @@ class RDoc::Markup::List
94
94
  ##
95
95
  # Appends +items+ to the list
96
96
 
97
- def push *items
97
+ def push(*items)
98
98
  @items.concat items
99
99
  end
100
100
 
@@ -24,7 +24,7 @@ class RDoc::Markup::ListItem
24
24
  ##
25
25
  # Creates a new ListItem with an optional +label+ containing +parts+
26
26
 
27
- def initialize label = nil, *parts
27
+ def initialize(label = nil, *parts)
28
28
  @label = label
29
29
  @parts = []
30
30
  @parts.concat parts
@@ -92,7 +92,7 @@ class RDoc::Markup::ListItem
92
92
  ##
93
93
  # Adds +parts+ to the ListItem
94
94
 
95
- def push *parts
95
+ def push(*parts)
96
96
  @parts.concat parts
97
97
  end
98
98
 
@@ -1,69 +1,66 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A section of text that is added to the output document as-is
4
2
 
5
- class RDoc::Markup::Raw
6
-
7
- ##
8
- # The component parts of the list
9
-
10
- attr_reader :parts
11
-
12
- ##
13
- # Creates a new Raw containing +parts+
14
-
15
- def initialize *parts
16
- @parts = []
17
- @parts.concat parts
18
- end
19
-
20
- ##
21
- # Appends +text+
3
+ module RDoc
4
+ class Markup
5
+ # A section of text that is added to the output document as-is
6
+ class Raw
7
+ # The component parts of the list
8
+ #: Array[String]
9
+ attr_reader :parts
10
+
11
+ # Creates a new Raw containing +parts+
12
+ #: (*String) -> void
13
+ def initialize(*parts)
14
+ @parts = parts
15
+ end
22
16
 
23
- def <<(text)
24
- @parts << text
25
- end
17
+ # Appends +text+
18
+ #: (String) -> void
19
+ def <<(text)
20
+ @parts << text
21
+ end
26
22
 
27
- def ==(other) # :nodoc:
28
- self.class == other.class and @parts == other.parts
29
- end
23
+ #: (top) -> bool
24
+ def ==(other) # :nodoc:
25
+ self.class == other.class && @parts == other.parts
26
+ end
30
27
 
31
- ##
32
- # Calls #accept_raw+ on +visitor+
28
+ # Calls #accept_raw+ on +visitor+
29
+ # @override
30
+ #: (untyped) -> void
31
+ def accept(visitor)
32
+ visitor.accept_raw(self)
33
+ end
33
34
 
34
- def accept(visitor)
35
- visitor.accept_raw self
36
- end
35
+ # Appends +other+'s parts
36
+ #: (Raw) -> void
37
+ def merge(other)
38
+ @parts.concat(other.parts)
39
+ end
37
40
 
38
- ##
39
- # Appends +other+'s parts
41
+ # @override
42
+ #: (PP) -> void
43
+ def pretty_print(q) # :nodoc:
44
+ self.class.name =~ /.*::(\w{1,4})/i
40
45
 
41
- def merge(other)
42
- @parts.concat other.parts
43
- end
46
+ q.group(2, "[#{$1.downcase}: ", ']') do
47
+ q.seplist(@parts) do |part|
48
+ q.pp(part)
49
+ end
50
+ end
51
+ end
44
52
 
45
- def pretty_print(q) # :nodoc:
46
- self.class.name =~ /.*::(\w{1,4})/i
53
+ # Appends +texts+ onto this Paragraph
54
+ #: (*String) -> void
55
+ def push(*texts)
56
+ self.parts.concat(texts)
57
+ end
47
58
 
48
- q.group 2, "[#{$1.downcase}: ", ']' do
49
- q.seplist @parts do |part|
50
- q.pp part
59
+ # The raw text
60
+ #: () -> String
61
+ def text
62
+ @parts.join(" ")
51
63
  end
52
64
  end
53
65
  end
54
-
55
- ##
56
- # Appends +texts+ onto this Paragraph
57
-
58
- def push *texts
59
- self.parts.concat texts
60
- end
61
-
62
- ##
63
- # The raw text
64
-
65
- def text
66
- @parts.join ' '
67
- end
68
-
69
66
  end
@@ -1,52 +1,60 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # A section of table
4
2
 
5
- class RDoc::Markup::Table
6
- # headers of each column
7
- attr_accessor :header
3
+ module RDoc
4
+ class Markup
5
+ # A section of table
6
+ class Table < Element
7
+ # Headers of each column
8
+ #: Array[String]
9
+ attr_accessor :header
8
10
 
9
- # alignments of each column
10
- attr_accessor :align
11
+ # Alignments of each column
12
+ #: Array[Symbol?]
13
+ attr_accessor :align
11
14
 
12
- # body texts of each column
13
- attr_accessor :body
15
+ # Body texts of each column
16
+ #: Array[String]
17
+ attr_accessor :body
14
18
 
15
- # Creates new instance
16
- def initialize(header, align, body)
17
- @header, @align, @body = header, align, body
18
- end
19
-
20
- # :stopdoc:
21
- def ==(other)
22
- self.class == other.class and
23
- @header == other.header and
24
- @align == other.align and
25
- @body == other.body
26
- end
19
+ #: (Array[String], Array[Symbol?], Array[String]) -> void
20
+ def initialize(header, align, body)
21
+ @header, @align, @body = header, align, body
22
+ end
27
23
 
28
- def accept(visitor)
29
- visitor.accept_table @header, @body, @align
30
- end
24
+ #: (Object) -> bool
25
+ def ==(other)
26
+ self.class == other.class && @header == other.header &&
27
+ @align == other.align && @body == other.body
28
+ end
31
29
 
32
- def pretty_print(q)
33
- q.group 2, '[Table: ', ']' do
34
- q.group 2, '[Head: ', ']' do
35
- q.seplist @header.zip(@align) do |text, align|
36
- q.pp text
37
- if align
38
- q.text ":"
39
- q.breakable
40
- q.text align.to_s
41
- end
42
- end
30
+ # @override
31
+ #: (untyped) -> void
32
+ def accept(visitor)
33
+ visitor.accept_table(@header, @body, @align)
43
34
  end
44
- q.breakable
45
- q.group 2, '[Body: ', ']' do
46
- q.seplist @body do |body|
47
- q.group 2, '[', ']' do
48
- q.seplist body do |text|
35
+
36
+ # @override
37
+ #: (untyped) -> String
38
+ def pretty_print(q)
39
+ q.group 2, '[Table: ', ']' do
40
+ q.group 2, '[Head: ', ']' do
41
+ q.seplist @header.zip(@align) do |text, align|
49
42
  q.pp text
43
+ if align
44
+ q.text ":"
45
+ q.breakable
46
+ q.text align.to_s
47
+ end
48
+ end
49
+ end
50
+ q.breakable
51
+ q.group 2, '[Body: ', ']' do
52
+ q.seplist @body do |body|
53
+ q.group 2, '[', ']' do
54
+ q.seplist body do |text|
55
+ q.pp text
56
+ end
57
+ end
50
58
  end
51
59
  end
52
60
  end
@@ -9,7 +9,7 @@ class RDoc::Markup::Verbatim < RDoc::Markup::Raw
9
9
 
10
10
  attr_accessor :format
11
11
 
12
- def initialize *parts # :nodoc:
12
+ def initialize(*parts) # :nodoc:
13
13
  super
14
14
 
15
15
  @format = nil
data/lib/rdoc/markup.rb CHANGED
@@ -210,6 +210,7 @@ https://github.com/ruby/rdoc/issues
210
210
  autoload :BlankLine, "#{__dir__}/markup/blank_line"
211
211
  autoload :BlockQuote, "#{__dir__}/markup/block_quote"
212
212
  autoload :Document, "#{__dir__}/markup/document"
213
+ autoload :Element, "#{__dir__}/markup/element"
213
214
  autoload :HardBreak, "#{__dir__}/markup/hard_break"
214
215
  autoload :Heading, "#{__dir__}/markup/heading"
215
216
  autoload :Include, "#{__dir__}/markup/include"
data/lib/rdoc/parser/c.rb CHANGED
@@ -1014,7 +1014,7 @@ class RDoc::Parser::C < RDoc::Parser
1014
1014
  file_name = File.join @file_dir, source_file
1015
1015
 
1016
1016
  if File.exist? file_name then
1017
- file_content = File.read file_name
1017
+ file_content = RDoc::Encoding.read_file file_name, @options.encoding
1018
1018
  else
1019
1019
  @options.warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
1020
1020
  end
data/lib/rdoc/ri/paths.rb CHANGED
@@ -30,7 +30,7 @@ module RDoc::RI::Paths
30
30
  # :extra:: ri data directory from the command line. Yielded for each
31
31
  # entry in +extra_dirs+
32
32
 
33
- def self.each system = true, site = true, home = true, gems = :latest, *extra_dirs # :yields: directory, type
33
+ def self.each(system = true, site = true, home = true, gems = :latest, *extra_dirs) # :yields: directory, type
34
34
  return enum_for __method__, system, site, home, gems, *extra_dirs unless
35
35
  block_given?
36
36
 
data/lib/rdoc/servlet.rb CHANGED
@@ -50,7 +50,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
50
50
  # Creates an instance of this servlet that shares cached data between
51
51
  # requests.
52
52
 
53
- def self.get_instance server, *options # :nodoc:
53
+ def self.get_instance(server, *options) # :nodoc:
54
54
  stores = @server_stores[server]
55
55
 
56
56
  new server, stores, @cache, *options
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 = '7.0.2'
8
+ VERSION = '7.0.4'
9
9
 
10
10
  end