rdoc 7.2.0 → 8.1.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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +4 -7
- data/LICENSE.rdoc +4 -0
- data/README.md +43 -2
- data/RI.md +75 -75
- data/doc/markup_reference/markdown.md +104 -3
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +70 -74
- data/lib/rdoc/code_object/any_method.rb +305 -298
- data/lib/rdoc/code_object/attr.rb +150 -143
- data/lib/rdoc/code_object/class_module.rb +801 -765
- data/lib/rdoc/code_object/constant.rb +178 -150
- data/lib/rdoc/code_object/context/section.rb +133 -160
- data/lib/rdoc/code_object/context.rb +925 -952
- data/lib/rdoc/code_object/extend.rb +7 -5
- data/lib/rdoc/code_object/include.rb +7 -5
- data/lib/rdoc/code_object/method_attr.rb +325 -324
- data/lib/rdoc/code_object/mixin.rb +97 -95
- data/lib/rdoc/code_object/normal_class.rb +77 -78
- data/lib/rdoc/code_object/normal_module.rb +61 -59
- data/lib/rdoc/code_object/require.rb +23 -39
- data/lib/rdoc/code_object/single_class.rb +21 -19
- data/lib/rdoc/code_object/top_level.rb +212 -213
- data/lib/rdoc/code_object.rb +305 -305
- data/lib/rdoc/comment.rb +274 -337
- data/lib/rdoc/cross_reference.rb +194 -212
- data/lib/rdoc/encoding.rb +105 -103
- data/lib/rdoc/erb_partial.rb +13 -11
- data/lib/rdoc/erbio.rb +29 -27
- data/lib/rdoc/generator/aliki.rb +165 -140
- data/lib/rdoc/generator/darkfish.rb +647 -631
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +165 -122
- data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
- data/lib/rdoc/generator/pot/po.rb +52 -51
- data/lib/rdoc/generator/pot/po_entry.rb +138 -132
- data/lib/rdoc/generator/pot.rb +85 -81
- data/lib/rdoc/generator/ri.rb +23 -19
- data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +11 -11
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/class.rhtml +56 -46
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +538 -283
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +80 -102
- data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/class.rhtml +18 -21
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -1
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/generator.rb +48 -46
- data/lib/rdoc/i18n/locale.rb +99 -95
- data/lib/rdoc/i18n/text.rb +109 -105
- data/lib/rdoc/i18n.rb +7 -5
- data/lib/rdoc/markdown/byte_runtime.rb +80 -0
- data/lib/rdoc/markdown.kpeg +30 -21
- data/lib/rdoc/markdown.rb +329 -151
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/formatter.rb +215 -221
- data/lib/rdoc/markup/heading.rb +1 -4
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +281 -277
- data/lib/rdoc/markup/list.rb +80 -88
- data/lib/rdoc/markup/list_item.rb +73 -85
- data/lib/rdoc/markup/paragraph.rb +23 -19
- data/lib/rdoc/markup/parser.rb +501 -497
- data/lib/rdoc/markup/pre_process.rb +284 -305
- data/lib/rdoc/markup/raw.rb +2 -2
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/to_ansi.rb +143 -139
- data/lib/rdoc/markup/to_bs.rb +72 -68
- data/lib/rdoc/markup/to_html.rb +600 -493
- data/lib/rdoc/markup/to_html_crossref.rb +221 -191
- data/lib/rdoc/markup/to_html_snippet.rb +232 -227
- data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
- data/lib/rdoc/markup/to_label.rb +63 -59
- data/lib/rdoc/markup/to_markdown.rb +212 -208
- data/lib/rdoc/markup/to_rdoc.rb +336 -332
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +60 -56
- data/lib/rdoc/markup/to_tt_only.rb +83 -86
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +198 -196
- data/lib/rdoc/options.rb +1063 -1076
- data/lib/rdoc/parser/c.rb +1039 -1036
- data/lib/rdoc/parser/changelog.rb +319 -315
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +279 -0
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1231 -2222
- data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +230 -221
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +547 -366
- data/lib/rdoc/ri/driver.rb +1141 -1130
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +456 -0
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -11
- data/lib/rdoc/rubygems_hook.rb +194 -192
- data/lib/rdoc/server.rb +462 -0
- data/lib/rdoc/stats/normal.rb +46 -42
- data/lib/rdoc/stats/quiet.rb +39 -35
- data/lib/rdoc/stats/verbose.rb +35 -31
- data/lib/rdoc/stats.rb +363 -338
- data/lib/rdoc/store.rb +919 -725
- data/lib/rdoc/task.rb +260 -255
- data/lib/rdoc/text.rb +130 -245
- data/lib/rdoc/token_stream.rb +101 -115
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +35 -7
- data/lib/rubygems_plugin.rb +2 -11
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +6 -4
- metadata +36 -20
- data/lib/rdoc/code_object/anon_class.rb +0 -10
- data/lib/rdoc/code_object/ghost_method.rb +0 -6
- data/lib/rdoc/code_object/meta_method.rb +0 -6
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- data/lib/rdoc/markdown/literals.rb +0 -454
- data/lib/rdoc/parser/prism_ruby.rb +0 -1112
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
- data/lib/rdoc/parser/ruby_tools.rb +0 -163
- data/lib/rdoc/servlet.rb +0 -452
data/lib/rdoc/tom_doc.rb
CHANGED
|
@@ -1,257 +1,259 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
# :markup: tomdoc
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
# The TomDoc specification can be found at http://tomdoc.org.
|
|
7
|
-
#
|
|
8
|
-
# To choose TomDoc as your only default format see RDoc::Options@Saved+Options
|
|
9
|
-
# for instructions on setting up a <code>.rdoc_options</code> file to store
|
|
10
|
-
# your project default.
|
|
11
|
-
#
|
|
12
|
-
# There are a few differences between this parser and the specification. A
|
|
13
|
-
# best-effort was made to follow the specification as closely as possible but
|
|
14
|
-
# some choices to deviate were made.
|
|
15
|
-
#
|
|
16
|
-
# A future version of RDoc will warn when a MUST or MUST NOT is violated and
|
|
17
|
-
# may warn when a SHOULD or SHOULD NOT is violated. RDoc will always try
|
|
18
|
-
# to emit documentation even if given invalid TomDoc.
|
|
19
|
-
#
|
|
20
|
-
# Here are some implementation choices this parser currently makes:
|
|
21
|
-
#
|
|
22
|
-
# This parser allows rdoc-style inline markup but you should not depended on
|
|
23
|
-
# it.
|
|
24
|
-
#
|
|
25
|
-
# This parser allows a space between the comment and the method body.
|
|
26
|
-
#
|
|
27
|
-
# This parser does not require the default value to be described for an
|
|
28
|
-
# optional argument.
|
|
29
|
-
#
|
|
30
|
-
# This parser does not examine the order of sections. An Examples section may
|
|
31
|
-
# precede the Arguments section.
|
|
32
|
-
#
|
|
33
|
-
# This class is documented in TomDoc format. Since this is a subclass of the
|
|
34
|
-
# RDoc markup parser there isn't much to see here, unfortunately.
|
|
35
|
-
|
|
36
|
-
class RDoc::TomDoc < RDoc::Markup::Parser
|
|
37
|
-
|
|
38
|
-
# Internal: Token accessor
|
|
39
|
-
|
|
40
|
-
attr_reader :tokens
|
|
41
|
-
|
|
42
|
-
# Internal: Adds a post-processor which sets the RDoc section based on the
|
|
43
|
-
# comment's status.
|
|
4
|
+
module RDoc
|
|
5
|
+
# A parser for TomDoc based on TomDoc 1.0.0-rc1 (02adef9b5a)
|
|
44
6
|
#
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
def self.add_post_processor # :nodoc:
|
|
48
|
-
RDoc::Markup::PreProcess.post_process do |comment, code_object|
|
|
49
|
-
next unless code_object and
|
|
50
|
-
RDoc::Comment === comment and comment.format == 'tomdoc'
|
|
51
|
-
|
|
52
|
-
comment.text.gsub!(/\A(\s*# |)(Public|Internal|Deprecated):\s+/) do
|
|
53
|
-
section = code_object.add_section $2
|
|
54
|
-
code_object.temporary_section = section
|
|
55
|
-
|
|
56
|
-
$1
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
add_post_processor
|
|
62
|
-
|
|
63
|
-
# Public: Parses TomDoc from text
|
|
7
|
+
# The TomDoc specification can be found at http://tomdoc.org.
|
|
64
8
|
#
|
|
65
|
-
#
|
|
9
|
+
# To choose TomDoc as your only default format see RDoc::Options@Saved+Options
|
|
10
|
+
# for instructions on setting up a <code>.rdoc_options</code> file to store
|
|
11
|
+
# your project default.
|
|
66
12
|
#
|
|
67
|
-
#
|
|
13
|
+
# There are a few differences between this parser and the specification. A
|
|
14
|
+
# best-effort was made to follow the specification as closely as possible but
|
|
15
|
+
# some choices to deviate were made.
|
|
68
16
|
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
17
|
+
# A future version of RDoc will warn when a MUST or MUST NOT is violated and
|
|
18
|
+
# may warn when a SHOULD or SHOULD NOT is violated. RDoc will always try
|
|
19
|
+
# to emit documentation even if given invalid TomDoc.
|
|
71
20
|
#
|
|
72
|
-
#
|
|
73
|
-
# TOMDOC
|
|
74
|
-
# # => #<RDoc::Markup::Document:0xXXX @parts=[...], @file=nil>
|
|
21
|
+
# Here are some implementation choices this parser currently makes:
|
|
75
22
|
#
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
def self.parse(text)
|
|
79
|
-
parser = new
|
|
80
|
-
|
|
81
|
-
parser.tokenize text
|
|
82
|
-
doc = RDoc::Markup::Document.new
|
|
83
|
-
parser.parse doc
|
|
84
|
-
doc
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Internal: Extracts the Signature section's method signature
|
|
23
|
+
# This parser allows rdoc-style inline markup but you should not depended on
|
|
24
|
+
# it.
|
|
88
25
|
#
|
|
89
|
-
#
|
|
90
|
-
# extracted
|
|
26
|
+
# This parser allows a space between the comment and the method body.
|
|
91
27
|
#
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
28
|
+
# This parser does not require the default value to be described for an
|
|
29
|
+
# optional argument.
|
|
30
|
+
#
|
|
31
|
+
# This parser does not examine the order of sections. An Examples section may
|
|
32
|
+
# precede the Arguments section.
|
|
33
|
+
#
|
|
34
|
+
# This class is documented in TomDoc format. Since this is a subclass of the
|
|
35
|
+
# RDoc markup parser there isn't much to see here, unfortunately.
|
|
96
36
|
|
|
97
|
-
|
|
37
|
+
class TomDoc < Markup::Parser
|
|
98
38
|
|
|
99
|
-
|
|
100
|
-
found_heading = false
|
|
101
|
-
found_signature = false
|
|
39
|
+
# Internal: Token accessor
|
|
102
40
|
|
|
103
|
-
|
|
104
|
-
next false if found_signature
|
|
41
|
+
attr_reader :tokens
|
|
105
42
|
|
|
106
|
-
|
|
107
|
-
|
|
43
|
+
# Internal: Adds a post-processor which sets the RDoc section based on the
|
|
44
|
+
# comment's status.
|
|
45
|
+
#
|
|
46
|
+
# Returns nothing.
|
|
108
47
|
|
|
109
|
-
|
|
48
|
+
def self.add_post_processor # :nodoc:
|
|
49
|
+
Markup::PreProcess.post_process do |comment, code_object|
|
|
50
|
+
next unless code_object and
|
|
51
|
+
Comment === comment and comment.format == 'tomdoc'
|
|
110
52
|
|
|
111
|
-
|
|
53
|
+
comment.text.gsub!(/\A(\s*# |)(Public|Internal|Deprecated):\s+/) do
|
|
54
|
+
section = code_object.add_section $2
|
|
55
|
+
code_object.temporary_section = section
|
|
112
56
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
found_signature = true
|
|
57
|
+
$1
|
|
58
|
+
end
|
|
116
59
|
end
|
|
117
60
|
end
|
|
118
61
|
|
|
119
|
-
|
|
120
|
-
|
|
62
|
+
add_post_processor
|
|
63
|
+
|
|
64
|
+
# Public: Parses TomDoc from text
|
|
65
|
+
#
|
|
66
|
+
# text - A String containing TomDoc-format text.
|
|
67
|
+
#
|
|
68
|
+
# Examples
|
|
69
|
+
#
|
|
70
|
+
# RDoc::TomDoc.parse <<-TOMDOC
|
|
71
|
+
# This method does some things
|
|
72
|
+
#
|
|
73
|
+
# Returns nothing.
|
|
74
|
+
# TOMDOC
|
|
75
|
+
# # => #<RDoc::Markup::Document:0xXXX @parts=[...], @file=nil>
|
|
76
|
+
#
|
|
77
|
+
# Returns an RDoc::Markup::Document representing the TomDoc format.
|
|
78
|
+
|
|
79
|
+
def self.parse(text)
|
|
80
|
+
parser = new
|
|
81
|
+
|
|
82
|
+
parser.tokenize text
|
|
83
|
+
doc = Markup::Document.new
|
|
84
|
+
parser.parse doc
|
|
85
|
+
doc
|
|
86
|
+
end
|
|
121
87
|
|
|
122
|
-
|
|
88
|
+
# Internal: Extracts the Signature section's method signature
|
|
89
|
+
#
|
|
90
|
+
# comment - An RDoc::Comment that will be parsed and have the signature
|
|
91
|
+
# extracted
|
|
92
|
+
#
|
|
93
|
+
# Returns a String containing the signature and nil if not
|
|
123
94
|
|
|
124
|
-
|
|
125
|
-
|
|
95
|
+
def self.signature(comment)
|
|
96
|
+
return unless comment.tomdoc?
|
|
126
97
|
|
|
127
|
-
|
|
128
|
-
@seen_returns = false
|
|
129
|
-
end
|
|
98
|
+
document = comment.parse
|
|
130
99
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
#
|
|
135
|
-
# Returns an RDoc::Markup::Heading
|
|
100
|
+
signature = nil
|
|
101
|
+
found_heading = false
|
|
102
|
+
found_signature = false
|
|
136
103
|
|
|
137
|
-
|
|
138
|
-
|
|
104
|
+
document.parts.delete_if do |part|
|
|
105
|
+
next false if found_signature
|
|
139
106
|
|
|
140
|
-
|
|
107
|
+
found_heading ||=
|
|
108
|
+
Markup::Heading === part && part.text == 'Signature'
|
|
141
109
|
|
|
142
|
-
|
|
143
|
-
end
|
|
110
|
+
next false unless found_heading
|
|
144
111
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
112
|
+
next true if Markup::BlankLine === part
|
|
113
|
+
|
|
114
|
+
if Markup::Verbatim === part
|
|
115
|
+
signature = part
|
|
116
|
+
found_signature = true
|
|
117
|
+
end
|
|
118
|
+
end
|
|
152
119
|
|
|
153
|
-
|
|
154
|
-
|
|
120
|
+
signature and signature.text
|
|
121
|
+
end
|
|
155
122
|
|
|
156
|
-
|
|
123
|
+
# Public: Creates a new TomDoc parser. See also RDoc::Markup::parse
|
|
157
124
|
|
|
158
|
-
|
|
159
|
-
|
|
125
|
+
def initialize
|
|
126
|
+
super
|
|
160
127
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
#
|
|
165
|
-
# Returns an RDoc::Markup::Paragraph.
|
|
128
|
+
@section = nil
|
|
129
|
+
@seen_returns = false
|
|
130
|
+
end
|
|
166
131
|
|
|
167
|
-
|
|
168
|
-
|
|
132
|
+
# Internal: Builds a heading from the token stream
|
|
133
|
+
#
|
|
134
|
+
# level - The level of heading to create
|
|
135
|
+
#
|
|
136
|
+
# Returns an RDoc::Markup::Heading
|
|
169
137
|
|
|
170
|
-
|
|
138
|
+
def build_heading(level)
|
|
139
|
+
heading = super
|
|
171
140
|
|
|
172
|
-
|
|
173
|
-
type, data, = get
|
|
141
|
+
@section = heading.text
|
|
174
142
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
@section = 'Returns' if data =~ /\A(Returns|Raises)/
|
|
143
|
+
heading
|
|
144
|
+
end
|
|
178
145
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
146
|
+
# Internal: Builds a verbatim from the token stream. A verbatim in the
|
|
147
|
+
# Examples section will be marked as in Ruby format.
|
|
148
|
+
#
|
|
149
|
+
# margin - The indentation from the margin for lines that belong to this
|
|
150
|
+
# verbatim section.
|
|
151
|
+
#
|
|
152
|
+
# Returns an RDoc::Markup::Verbatim
|
|
153
|
+
|
|
154
|
+
def build_verbatim(margin)
|
|
155
|
+
verbatim = super
|
|
156
|
+
|
|
157
|
+
verbatim.format = :ruby if @section == 'Examples'
|
|
158
|
+
|
|
159
|
+
verbatim
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Internal: Builds a paragraph from the token stream
|
|
163
|
+
#
|
|
164
|
+
# margin - Unused
|
|
165
|
+
#
|
|
166
|
+
# Returns an RDoc::Markup::Paragraph.
|
|
167
|
+
|
|
168
|
+
def build_paragraph(margin)
|
|
169
|
+
p :paragraph_start => margin if @debug
|
|
170
|
+
|
|
171
|
+
paragraph = Markup::Paragraph.new
|
|
172
|
+
|
|
173
|
+
until @tokens.empty? do
|
|
174
|
+
type, data, = get
|
|
175
|
+
|
|
176
|
+
case type
|
|
177
|
+
when :TEXT
|
|
178
|
+
@section = 'Returns' if data =~ /\A(Returns|Raises)/
|
|
179
|
+
|
|
180
|
+
paragraph << data
|
|
181
|
+
when :NEWLINE
|
|
182
|
+
if :TEXT == peek_token[0]
|
|
183
|
+
# Lines beginning with 'Raises' in the Returns section should not be
|
|
184
|
+
# treated as multiline text
|
|
185
|
+
if 'Returns' == @section and
|
|
186
|
+
peek_token[1].start_with?('Raises')
|
|
187
|
+
break
|
|
188
|
+
else
|
|
189
|
+
paragraph << ' '
|
|
190
|
+
end
|
|
187
191
|
else
|
|
188
|
-
|
|
192
|
+
break
|
|
189
193
|
end
|
|
190
194
|
else
|
|
195
|
+
unget
|
|
191
196
|
break
|
|
192
197
|
end
|
|
193
|
-
else
|
|
194
|
-
unget
|
|
195
|
-
break
|
|
196
198
|
end
|
|
197
|
-
end
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
p :paragraph_end => margin if @debug
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
paragraph
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
##
|
|
206
|
+
# Detects a section change to "Returns" and adds a heading
|
|
203
207
|
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
def parse_text(parent, indent) # :nodoc:
|
|
209
|
+
paragraph = build_paragraph indent
|
|
206
210
|
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
if false == @seen_returns and 'Returns' == @section
|
|
212
|
+
@seen_returns = true
|
|
213
|
+
parent << Markup::Heading.new(3, 'Returns')
|
|
214
|
+
parent << Markup::BlankLine.new
|
|
215
|
+
end
|
|
209
216
|
|
|
210
|
-
|
|
211
|
-
@seen_returns = true
|
|
212
|
-
parent << RDoc::Markup::Heading.new(3, 'Returns')
|
|
213
|
-
parent << RDoc::Markup::BlankLine.new
|
|
217
|
+
parent << paragraph
|
|
214
218
|
end
|
|
215
219
|
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
# Internal: Turns text into an Array of tokens
|
|
221
|
+
#
|
|
222
|
+
# text - A String containing TomDoc-format text.
|
|
223
|
+
#
|
|
224
|
+
# Returns self.
|
|
225
|
+
|
|
226
|
+
def tokenize(text)
|
|
227
|
+
text = text.sub(/\A(Public|Internal|Deprecated):\s+/, '')
|
|
228
|
+
|
|
229
|
+
setup_scanner text
|
|
230
|
+
|
|
231
|
+
until @s.eos? do
|
|
232
|
+
pos = @s.pos
|
|
233
|
+
|
|
234
|
+
# leading spaces will be reflected by the column of the next token
|
|
235
|
+
# the only thing we loose are trailing spaces at the end of the file
|
|
236
|
+
next if @s.scan(/ +/)
|
|
237
|
+
|
|
238
|
+
@tokens << case
|
|
239
|
+
when @s.scan(/\r?\n/)
|
|
240
|
+
token = [:NEWLINE, @s.matched, *pos]
|
|
241
|
+
@s.newline!
|
|
242
|
+
token
|
|
243
|
+
when @s.scan(/(Examples|Signature)$/)
|
|
244
|
+
@tokens << [:HEADER, 3, *pos]
|
|
245
|
+
|
|
246
|
+
[:TEXT, @s[1], *pos]
|
|
247
|
+
when @s.scan(/([:\w][\w\[\]]*)[ ]+- /)
|
|
248
|
+
[:NOTE, @s[1], *pos]
|
|
249
|
+
else
|
|
250
|
+
@s.scan(/.*/)
|
|
251
|
+
[:TEXT, @s.matched.sub(/\r$/, ''), *pos]
|
|
252
|
+
end
|
|
253
|
+
end
|
|
218
254
|
|
|
219
|
-
|
|
220
|
-
#
|
|
221
|
-
# text - A String containing TomDoc-format text.
|
|
222
|
-
#
|
|
223
|
-
# Returns self.
|
|
224
|
-
|
|
225
|
-
def tokenize(text)
|
|
226
|
-
text = text.sub(/\A(Public|Internal|Deprecated):\s+/, '')
|
|
227
|
-
|
|
228
|
-
setup_scanner text
|
|
229
|
-
|
|
230
|
-
until @s.eos? do
|
|
231
|
-
pos = @s.pos
|
|
232
|
-
|
|
233
|
-
# leading spaces will be reflected by the column of the next token
|
|
234
|
-
# the only thing we loose are trailing spaces at the end of the file
|
|
235
|
-
next if @s.scan(/ +/)
|
|
236
|
-
|
|
237
|
-
@tokens << case
|
|
238
|
-
when @s.scan(/\r?\n/) then
|
|
239
|
-
token = [:NEWLINE, @s.matched, *pos]
|
|
240
|
-
@s.newline!
|
|
241
|
-
token
|
|
242
|
-
when @s.scan(/(Examples|Signature)$/) then
|
|
243
|
-
@tokens << [:HEADER, 3, *pos]
|
|
244
|
-
|
|
245
|
-
[:TEXT, @s[1], *pos]
|
|
246
|
-
when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
|
|
247
|
-
[:NOTE, @s[1], *pos]
|
|
248
|
-
else
|
|
249
|
-
@s.scan(/.*/)
|
|
250
|
-
[:TEXT, @s.matched.sub(/\r$/, ''), *pos]
|
|
251
|
-
end
|
|
255
|
+
self
|
|
252
256
|
end
|
|
253
257
|
|
|
254
|
-
self
|
|
255
258
|
end
|
|
256
|
-
|
|
257
259
|
end
|
data/lib/rdoc/version.rb
CHANGED
data/lib/rdoc.rb
CHANGED
|
@@ -100,7 +100,14 @@ module RDoc
|
|
|
100
100
|
%w[arg args yield yields notnew not-new not_new doc]
|
|
101
101
|
|
|
102
102
|
##
|
|
103
|
-
# Loads the
|
|
103
|
+
# Loads the YAML backend used for <tt>.rdoc_options</tt>.
|
|
104
|
+
#
|
|
105
|
+
# Psych is preferred and used whenever it can be required. Requiring +yaml+
|
|
106
|
+
# is not attempted as a fallback because +yaml+ is merely a thin wrapper that
|
|
107
|
+
# loads Psych anyway. When Psych is genuinely unavailable, a minimal
|
|
108
|
+
# serializer shipped with RubyGems or Bundler is loaded instead, so that RDoc
|
|
109
|
+
# does not need a runtime dependency on Psych. Callers branch on whether
|
|
110
|
+
# Psych is defined and use ::yaml_serializer otherwise.
|
|
104
111
|
|
|
105
112
|
def self.load_yaml
|
|
106
113
|
begin
|
|
@@ -113,11 +120,25 @@ module RDoc
|
|
|
113
120
|
begin
|
|
114
121
|
require 'psych'
|
|
115
122
|
rescue ::LoadError
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
# Psych is unavailable; load the stub serializer shipped with RubyGems,
|
|
124
|
+
# or Bundler's copy on RubyGems older than 3.5 (Ruby 3.2) where
|
|
125
|
+
# rubygems/yaml_serializer does not exist yet.
|
|
126
|
+
begin
|
|
127
|
+
require 'rubygems/yaml_serializer'
|
|
128
|
+
rescue ::LoadError
|
|
129
|
+
require 'bundler/yaml_serializer'
|
|
130
|
+
end
|
|
118
131
|
end
|
|
119
132
|
end
|
|
120
133
|
|
|
134
|
+
##
|
|
135
|
+
# The minimal YAML serializer module loaded by ::load_yaml as a fallback.
|
|
136
|
+
# Only meaningful when Psych is not defined.
|
|
137
|
+
|
|
138
|
+
def self.yaml_serializer
|
|
139
|
+
defined?(Gem::YAMLSerializer) ? Gem::YAMLSerializer : Bundler::YAMLSerializer
|
|
140
|
+
end
|
|
141
|
+
|
|
121
142
|
##
|
|
122
143
|
# Searches and returns the directory for settings.
|
|
123
144
|
#
|
|
@@ -151,6 +172,16 @@ module RDoc
|
|
|
151
172
|
end
|
|
152
173
|
end
|
|
153
174
|
|
|
175
|
+
##
|
|
176
|
+
# Returns +File.mtime(file)+, or +nil+ if the file cannot be stat'd
|
|
177
|
+
# (missing, permission denied, etc.).
|
|
178
|
+
|
|
179
|
+
def self.safe_mtime(file)
|
|
180
|
+
File.mtime(file)
|
|
181
|
+
rescue SystemCallError
|
|
182
|
+
nil
|
|
183
|
+
end
|
|
184
|
+
|
|
154
185
|
autoload :RDoc, "#{__dir__}/rdoc/rdoc"
|
|
155
186
|
|
|
156
187
|
autoload :CrossReference, "#{__dir__}/rdoc/cross_reference"
|
|
@@ -160,7 +191,7 @@ module RDoc
|
|
|
160
191
|
autoload :Generator, "#{__dir__}/rdoc/generator"
|
|
161
192
|
autoload :Options, "#{__dir__}/rdoc/options"
|
|
162
193
|
autoload :Parser, "#{__dir__}/rdoc/parser"
|
|
163
|
-
autoload :
|
|
194
|
+
autoload :Server, "#{__dir__}/rdoc/server"
|
|
164
195
|
autoload :RI, "#{__dir__}/rdoc/ri"
|
|
165
196
|
autoload :Stats, "#{__dir__}/rdoc/stats"
|
|
166
197
|
autoload :Store, "#{__dir__}/rdoc/store"
|
|
@@ -189,7 +220,6 @@ module RDoc
|
|
|
189
220
|
autoload :Context, "#{__dir__}/rdoc/code_object/context"
|
|
190
221
|
autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level"
|
|
191
222
|
|
|
192
|
-
autoload :AnonClass, "#{__dir__}/rdoc/code_object/anon_class"
|
|
193
223
|
autoload :ClassModule, "#{__dir__}/rdoc/code_object/class_module"
|
|
194
224
|
autoload :NormalClass, "#{__dir__}/rdoc/code_object/normal_class"
|
|
195
225
|
autoload :NormalModule, "#{__dir__}/rdoc/code_object/normal_module"
|
|
@@ -198,8 +228,6 @@ module RDoc
|
|
|
198
228
|
autoload :Alias, "#{__dir__}/rdoc/code_object/alias"
|
|
199
229
|
autoload :AnyMethod, "#{__dir__}/rdoc/code_object/any_method"
|
|
200
230
|
autoload :MethodAttr, "#{__dir__}/rdoc/code_object/method_attr"
|
|
201
|
-
autoload :GhostMethod, "#{__dir__}/rdoc/code_object/ghost_method"
|
|
202
|
-
autoload :MetaMethod, "#{__dir__}/rdoc/code_object/meta_method"
|
|
203
231
|
autoload :Attr, "#{__dir__}/rdoc/code_object/attr"
|
|
204
232
|
|
|
205
233
|
autoload :Constant, "#{__dir__}/rdoc/code_object/constant"
|
data/lib/rubygems_plugin.rb
CHANGED
|
@@ -10,14 +10,5 @@
|
|
|
10
10
|
|
|
11
11
|
require_relative 'rdoc/rubygems_hook'
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# If generate and remove are executed at that time, an error will occur.
|
|
16
|
-
# So, we can't register generate and remove to Gem at that time.
|
|
17
|
-
begin
|
|
18
|
-
require_relative 'rdoc/markdown'
|
|
19
|
-
rescue LoadError
|
|
20
|
-
else
|
|
21
|
-
Gem.done_installing(&RDoc::RubyGemsHook.method(:generate))
|
|
22
|
-
Gem.pre_uninstall(&RDoc::RubyGemsHook.method(:remove))
|
|
23
|
-
end
|
|
13
|
+
Gem.done_installing(&RDoc::RubyGemsHook.method(:generate))
|
|
14
|
+
Gem.pre_uninstall(&RDoc::RubyGemsHook.method(:remove))
|
data/rdoc-logo.svg
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="168" height="198" viewBox="298 140 712 840" role="img" aria-labelledby="title desc">
|
|
2
|
+
<title id="title">RDoc</title>
|
|
3
|
+
<desc id="desc">A red document outline with a folded corner and a Ruby gem.</desc>
|
|
4
|
+
<style>
|
|
5
|
+
.surface {
|
|
6
|
+
fill: transparent;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.stroke {
|
|
10
|
+
stroke: url(#rdoc-red);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.solid {
|
|
14
|
+
fill: url(#rdoc-red);
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
<defs>
|
|
18
|
+
<linearGradient id="rdoc-red" x1="338" y1="178" x2="973" y2="938" gradientUnits="userSpaceOnUse">
|
|
19
|
+
<stop id="rdoc-red-start" offset="0" stop-color="#e62923"/>
|
|
20
|
+
<stop id="rdoc-red-mid" offset="0.56" stop-color="#e62923"/>
|
|
21
|
+
<stop id="rdoc-red-end" offset="1" stop-color="#e62923"/>
|
|
22
|
+
</linearGradient>
|
|
23
|
+
<filter id="soft-red-shadow" x="-10%" y="-10%" width="120%" height="120%">
|
|
24
|
+
<feDropShadow dx="0" dy="5" stdDeviation="5" flood-color="#e62923" flood-opacity="0.1"/>
|
|
25
|
+
</filter>
|
|
26
|
+
</defs>
|
|
27
|
+
|
|
28
|
+
<g filter="url(#soft-red-shadow)" fill="none" class="stroke" stroke-linecap="round" stroke-linejoin="round">
|
|
29
|
+
<path class="surface" d="M382 178h326l149 149v499c0 24-20 44-44 44H382c-24 0-44-20-44-44V222c0-24 20-44 44-44Z" stroke="none"/>
|
|
30
|
+
<path d="M685 870H382c-24 0-44-20-44-44V222c0-24 20-44 44-44h326l149 149v246" stroke-width="26"/>
|
|
31
|
+
<path class="solid" d="M708 178v126c0 24 19 43 43 43h106" stroke="none"/>
|
|
32
|
+
<path d="M708 178 857 327" stroke-width="26"/>
|
|
33
|
+
|
|
34
|
+
<path d="M440 411h216" stroke-width="26"/>
|
|
35
|
+
<path d="M440 506h216" stroke-width="26"/>
|
|
36
|
+
<path d="M440 605h145" stroke-width="26"/>
|
|
37
|
+
|
|
38
|
+
<path class="surface" d="M668 609h224l81 97-195 232-191-232 81-97Z" stroke-width="26"/>
|
|
39
|
+
<path d="M668 609 700 706 778 609 858 706 892 609" stroke-width="20"/>
|
|
40
|
+
<path d="M587 706h386" stroke-width="20"/>
|
|
41
|
+
<path d="M700 706 778 938 858 706" stroke-width="20"/>
|
|
42
|
+
</g>
|
|
43
|
+
</svg>
|
data/rdoc.gemspec
CHANGED
|
@@ -26,7 +26,7 @@ RDoc produces HTML and command-line documentation for Ruby projects.
|
|
|
26
26
|
RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentation from the command-line.
|
|
27
27
|
DESCRIPTION
|
|
28
28
|
s.homepage = "https://ruby.github.io/rdoc"
|
|
29
|
-
s.licenses = ["Ruby"]
|
|
29
|
+
s.licenses = ["Ruby", "GPL-2.0-only"]
|
|
30
30
|
|
|
31
31
|
s.metadata["homepage_uri"] = s.homepage
|
|
32
32
|
s.metadata["source_code_uri"] = "https://github.com/ruby/rdoc"
|
|
@@ -51,6 +51,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
|
|
|
51
51
|
"exe/rdoc",
|
|
52
52
|
"exe/ri",
|
|
53
53
|
"man/ri.1",
|
|
54
|
+
"rdoc-logo.svg",
|
|
54
55
|
"rdoc.gemspec",
|
|
55
56
|
]
|
|
56
57
|
base = __dir__
|
|
@@ -60,13 +61,14 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
|
|
|
60
61
|
|
|
61
62
|
s.files = (non_lib_files + template_files + lib_files).uniq
|
|
62
63
|
|
|
63
|
-
s.rdoc_options = ["--main", "README.md"]
|
|
64
|
+
s.rdoc_options = ["--main", "README.md", "--copy-files", "rdoc-logo.svg"]
|
|
64
65
|
s.extra_rdoc_files += s.files.grep(%r[\A[^\/]+\.(?:rdoc|md)\z])
|
|
65
66
|
|
|
66
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.
|
|
67
|
+
s.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
|
67
68
|
s.required_rubygems_version = Gem::Requirement.new(">= 2.2")
|
|
68
69
|
|
|
69
|
-
s.add_dependency 'psych', '>= 4.0.0'
|
|
70
70
|
s.add_dependency 'erb'
|
|
71
71
|
s.add_dependency 'tsort'
|
|
72
|
+
s.add_dependency 'prism', '>= 1.6.0'
|
|
73
|
+
s.add_dependency 'rbs', '>= 4.0.0'
|
|
72
74
|
end
|