rdoc 6.13.0 → 6.17.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/History.rdoc +1 -1
- data/README.md +112 -0
- data/RI.md +1 -1
- data/lib/rdoc/code_object/any_method.rb +4 -4
- data/lib/rdoc/code_object/attr.rb +3 -3
- data/lib/rdoc/code_object/class_module.rb +18 -16
- data/lib/rdoc/code_object/constant.rb +5 -5
- data/lib/rdoc/code_object/context/section.rb +8 -7
- data/lib/rdoc/code_object/context.rb +19 -19
- data/lib/rdoc/code_object/method_attr.rb +7 -6
- data/lib/rdoc/code_object/mixin.rb +3 -3
- data/lib/rdoc/code_object/normal_class.rb +1 -1
- data/lib/rdoc/code_object/normal_module.rb +1 -1
- data/lib/rdoc/code_object/single_class.rb +1 -1
- data/lib/rdoc/code_object/top_level.rb +28 -33
- data/lib/rdoc/code_object.rb +3 -3
- data/lib/rdoc/comment.rb +196 -14
- data/lib/rdoc/cross_reference.rb +4 -4
- data/lib/rdoc/encoding.rb +4 -4
- data/lib/rdoc/erb_partial.rb +1 -1
- data/lib/rdoc/erbio.rb +2 -2
- data/lib/rdoc/generator/aliki.rb +42 -0
- data/lib/rdoc/generator/darkfish.rb +20 -16
- data/lib/rdoc/generator/json_index.rb +3 -3
- data/lib/rdoc/generator/markup.rb +12 -0
- data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
- data/lib/rdoc/generator/pot/po.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +7 -7
- data/lib/rdoc/generator/pot.rb +1 -1
- data/lib/rdoc/generator/ri.rb +1 -1
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
- data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +220 -0
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +1737 -0
- data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/lib/rdoc/generator/template/aliki/js/aliki.js +483 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/lib/rdoc/generator/template/aliki/js/search.js +120 -0
- data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -16
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
- data/lib/rdoc/generator/template/darkfish/class.rhtml +62 -60
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +2 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +21 -1
- data/lib/rdoc/generator/template/darkfish/js/search.js +11 -1
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
- data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
- data/lib/rdoc/generator.rb +1 -0
- data/lib/rdoc/markdown.kpeg +72 -18
- data/lib/rdoc/markdown.rb +411 -547
- data/lib/rdoc/markup/attribute_manager.rb +5 -5
- data/lib/rdoc/markup/attributes.rb +3 -3
- data/lib/rdoc/markup/blank_line.rb +2 -2
- data/lib/rdoc/markup/block_quote.rb +1 -1
- data/lib/rdoc/markup/document.rb +8 -8
- data/lib/rdoc/markup/formatter.rb +12 -12
- data/lib/rdoc/markup/hard_break.rb +3 -3
- data/lib/rdoc/markup/heading.rb +4 -4
- data/lib/rdoc/markup/include.rb +3 -3
- data/lib/rdoc/markup/indented_paragraph.rb +3 -3
- data/lib/rdoc/markup/list.rb +4 -4
- data/lib/rdoc/markup/list_item.rb +4 -4
- data/lib/rdoc/markup/paragraph.rb +2 -2
- data/lib/rdoc/markup/parser.rb +11 -11
- data/lib/rdoc/markup/pre_process.rb +39 -15
- data/lib/rdoc/markup/raw.rb +5 -5
- data/lib/rdoc/markup/rule.rb +2 -2
- data/lib/rdoc/markup/table.rb +4 -4
- data/lib/rdoc/markup/to_ansi.rb +7 -3
- data/lib/rdoc/markup/to_bs.rb +10 -6
- data/lib/rdoc/markup/to_html.rb +182 -30
- data/lib/rdoc/markup/to_html_crossref.rb +58 -28
- data/lib/rdoc/markup/to_html_snippet.rb +17 -17
- data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
- data/lib/rdoc/markup/to_label.rb +6 -5
- data/lib/rdoc/markup/to_markdown.rb +12 -12
- data/lib/rdoc/markup/to_rdoc.rb +40 -31
- data/lib/rdoc/markup/to_table_of_contents.rb +3 -3
- data/lib/rdoc/markup/to_test.rb +1 -1
- data/lib/rdoc/markup/to_tt_only.rb +8 -8
- data/lib/rdoc/markup/verbatim.rb +3 -3
- data/lib/rdoc/markup.rb +3 -3
- data/lib/rdoc/options.rb +53 -23
- data/lib/rdoc/parser/c.rb +31 -62
- data/lib/rdoc/parser/changelog.rb +9 -9
- data/lib/rdoc/parser/prism_ruby.rb +122 -114
- data/lib/rdoc/parser/ruby.rb +51 -51
- data/lib/rdoc/parser/ruby_tools.rb +5 -7
- data/lib/rdoc/parser/simple.rb +5 -22
- data/lib/rdoc/parser.rb +8 -8
- data/lib/rdoc/rd/inline.rb +4 -4
- data/lib/rdoc/rd.rb +1 -1
- data/lib/rdoc/rdoc.rb +9 -8
- data/lib/rdoc/ri/driver.rb +49 -49
- data/lib/rdoc/ri/paths.rb +2 -2
- data/lib/rdoc/ri/task.rb +3 -3
- data/lib/rdoc/rubygems_hook.rb +14 -11
- data/lib/rdoc/servlet.rb +15 -15
- data/lib/rdoc/stats/normal.rb +1 -1
- data/lib/rdoc/stats/quiet.rb +1 -1
- data/lib/rdoc/stats/verbose.rb +3 -3
- data/lib/rdoc/stats.rb +12 -12
- data/lib/rdoc/store.rb +32 -32
- data/lib/rdoc/task.rb +6 -6
- data/lib/rdoc/text.rb +11 -11
- data/lib/rdoc/token_stream.rb +14 -2
- data/lib/rdoc/tom_doc.rb +8 -8
- data/lib/rdoc/version.rb +1 -1
- data/man/ri.1 +2 -0
- data/rdoc.gemspec +72 -0
- metadata +61 -6
- data/README.rdoc +0 -142
|
@@ -23,13 +23,13 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
|
23
23
|
##
|
|
24
24
|
# Mixins are sorted by name
|
|
25
25
|
|
|
26
|
-
def <=>
|
|
26
|
+
def <=>(other)
|
|
27
27
|
return unless self.class === other
|
|
28
28
|
|
|
29
29
|
name <=> other.name
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def ==
|
|
32
|
+
def ==(other) # :nodoc:
|
|
33
33
|
self.class === other and @name == other.name
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -107,7 +107,7 @@ class RDoc::Mixin < RDoc::CodeObject
|
|
|
107
107
|
##
|
|
108
108
|
# Sets the store for this class or module and its contained code objects.
|
|
109
109
|
|
|
110
|
-
def store=
|
|
110
|
+
def store=(store)
|
|
111
111
|
super
|
|
112
112
|
|
|
113
113
|
@file = @store.add_file @file.full_name if @file
|
|
@@ -16,6 +16,16 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
16
16
|
|
|
17
17
|
attr_accessor :absolute_name
|
|
18
18
|
|
|
19
|
+
##
|
|
20
|
+
# Base name of this file
|
|
21
|
+
|
|
22
|
+
attr_reader :base_name
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Base name of this file without the extension
|
|
26
|
+
|
|
27
|
+
attr_reader :page_name
|
|
28
|
+
|
|
19
29
|
##
|
|
20
30
|
# All the classes or modules that were declared in
|
|
21
31
|
# this file. These are assigned to either +#classes_hash+
|
|
@@ -33,13 +43,21 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
33
43
|
# is being generated outside the source dir +relative_name+ is relative to
|
|
34
44
|
# the source directory.
|
|
35
45
|
|
|
36
|
-
def initialize
|
|
46
|
+
def initialize(absolute_name, relative_name = absolute_name)
|
|
37
47
|
super()
|
|
38
48
|
@name = nil
|
|
39
49
|
@absolute_name = absolute_name
|
|
40
50
|
@relative_name = relative_name
|
|
41
51
|
@parser = nil
|
|
42
52
|
|
|
53
|
+
if relative_name
|
|
54
|
+
@base_name = File.basename(relative_name)
|
|
55
|
+
@page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '')
|
|
56
|
+
else
|
|
57
|
+
@base_name = nil
|
|
58
|
+
@page_name = nil
|
|
59
|
+
end
|
|
60
|
+
|
|
43
61
|
@classes_or_modules = []
|
|
44
62
|
end
|
|
45
63
|
|
|
@@ -55,7 +73,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
55
73
|
##
|
|
56
74
|
# An RDoc::TopLevel is equal to another with the same relative_name
|
|
57
75
|
|
|
58
|
-
def ==
|
|
76
|
+
def ==(other)
|
|
59
77
|
self.class === other and @relative_name == other.relative_name
|
|
60
78
|
end
|
|
61
79
|
|
|
@@ -73,7 +91,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
73
91
|
##
|
|
74
92
|
# Adds +constant+ to +Object+ instead of +self+.
|
|
75
93
|
|
|
76
|
-
def add_constant
|
|
94
|
+
def add_constant(constant)
|
|
77
95
|
object_class.record_location self
|
|
78
96
|
return constant unless @document_self
|
|
79
97
|
object_class.add_constant constant
|
|
@@ -101,34 +119,19 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
101
119
|
# Adds class or module +mod+. Used in the building phase
|
|
102
120
|
# by the Ruby parser.
|
|
103
121
|
|
|
104
|
-
def add_to_classes_or_modules
|
|
122
|
+
def add_to_classes_or_modules(mod)
|
|
105
123
|
@classes_or_modules << mod
|
|
106
124
|
end
|
|
107
125
|
|
|
108
|
-
##
|
|
109
|
-
# Base name of this file
|
|
110
|
-
|
|
111
|
-
def base_name
|
|
112
|
-
File.basename @relative_name
|
|
113
|
-
end
|
|
114
|
-
|
|
115
126
|
alias name base_name
|
|
116
127
|
|
|
117
|
-
##
|
|
118
|
-
# Only a TopLevel that contains text file) will be displayed. See also
|
|
119
|
-
# RDoc::CodeObject#display?
|
|
120
|
-
|
|
121
|
-
def display?
|
|
122
|
-
text? and super
|
|
123
|
-
end
|
|
124
|
-
|
|
125
128
|
##
|
|
126
129
|
# See RDoc::TopLevel::find_class_or_module
|
|
127
130
|
#--
|
|
128
131
|
# TODO Why do we search through all classes/modules found, not just the
|
|
129
132
|
# ones of this instance?
|
|
130
133
|
|
|
131
|
-
def find_class_or_module
|
|
134
|
+
def find_class_or_module(name)
|
|
132
135
|
@store.find_class_or_module name
|
|
133
136
|
end
|
|
134
137
|
|
|
@@ -192,7 +195,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
192
195
|
##
|
|
193
196
|
# Loads this TopLevel from +array+.
|
|
194
197
|
|
|
195
|
-
def marshal_load
|
|
198
|
+
def marshal_load(array) # :nodoc:
|
|
196
199
|
initialize array[1]
|
|
197
200
|
|
|
198
201
|
@parser = array[2]
|
|
@@ -212,24 +215,16 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
212
215
|
end
|
|
213
216
|
end
|
|
214
217
|
|
|
215
|
-
##
|
|
216
|
-
# Base name of this file without the extension
|
|
217
|
-
|
|
218
|
-
def page_name
|
|
219
|
-
basename = File.basename @relative_name
|
|
220
|
-
basename =~ /\.(rb|rdoc|txt|md)$/i
|
|
221
|
-
|
|
222
|
-
$` || basename
|
|
223
|
-
end
|
|
224
|
-
|
|
225
218
|
##
|
|
226
219
|
# Path to this file for use with HTML generator output.
|
|
227
220
|
|
|
228
221
|
def path
|
|
229
|
-
|
|
222
|
+
prefix = options.file_path_prefix
|
|
223
|
+
return http_url unless prefix
|
|
224
|
+
File.join(prefix, http_url)
|
|
230
225
|
end
|
|
231
226
|
|
|
232
|
-
def pretty_print
|
|
227
|
+
def pretty_print(q) # :nodoc:
|
|
233
228
|
q.group 2, "[#{self.class}: ", "]" do
|
|
234
229
|
q.text "base name: #{base_name.inspect}"
|
|
235
230
|
q.breakable
|
data/lib/rdoc/code_object.rb
CHANGED
|
@@ -236,7 +236,7 @@ class RDoc::CodeObject
|
|
|
236
236
|
#
|
|
237
237
|
# Set to +nil+ to clear RDoc's cached value
|
|
238
238
|
|
|
239
|
-
def full_name=
|
|
239
|
+
def full_name=(full_name)
|
|
240
240
|
@full_name = full_name
|
|
241
241
|
end
|
|
242
242
|
|
|
@@ -316,7 +316,7 @@ class RDoc::CodeObject
|
|
|
316
316
|
##
|
|
317
317
|
# Records the RDoc::TopLevel (file) where this code object was defined
|
|
318
318
|
|
|
319
|
-
def record_location
|
|
319
|
+
def record_location(top_level)
|
|
320
320
|
@ignored = false
|
|
321
321
|
@suppressed = false
|
|
322
322
|
@file = top_level
|
|
@@ -358,7 +358,7 @@ class RDoc::CodeObject
|
|
|
358
358
|
##
|
|
359
359
|
# Sets the +store+ that contains this CodeObject
|
|
360
360
|
|
|
361
|
-
def store=
|
|
361
|
+
def store=(store)
|
|
362
362
|
@store = store
|
|
363
363
|
|
|
364
364
|
return unless @track_visibility
|
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
|
|
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
|
|
70
|
+
def initialize_copy(copy) # :nodoc:
|
|
71
71
|
@text = copy.text.dup
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
def ==
|
|
74
|
+
def ==(other) # :nodoc:
|
|
75
75
|
self.class === other and
|
|
76
76
|
other.text == @text and other.location == @location
|
|
77
77
|
end
|
|
@@ -129,7 +129,7 @@ class RDoc::Comment
|
|
|
129
129
|
##
|
|
130
130
|
# HACK dubious
|
|
131
131
|
|
|
132
|
-
def encode!
|
|
132
|
+
def encode!(encoding)
|
|
133
133
|
@text = String.new @text, encoding: encoding
|
|
134
134
|
self
|
|
135
135
|
end
|
|
@@ -137,7 +137,7 @@ class RDoc::Comment
|
|
|
137
137
|
##
|
|
138
138
|
# Sets the format of this comment and resets any parsed document
|
|
139
139
|
|
|
140
|
-
def format=
|
|
140
|
+
def format=(format)
|
|
141
141
|
@format = format
|
|
142
142
|
@document = nil
|
|
143
143
|
end
|
|
@@ -162,6 +162,12 @@ class RDoc::Comment
|
|
|
162
162
|
self
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
+
# Change normalized, when creating already normalized comment.
|
|
166
|
+
|
|
167
|
+
def normalized=(value)
|
|
168
|
+
@normalized = value
|
|
169
|
+
end
|
|
170
|
+
|
|
165
171
|
##
|
|
166
172
|
# Was this text normalized?
|
|
167
173
|
|
|
@@ -208,7 +214,7 @@ class RDoc::Comment
|
|
|
208
214
|
#
|
|
209
215
|
# An error is raised if the comment contains a document but no text.
|
|
210
216
|
|
|
211
|
-
def text=
|
|
217
|
+
def text=(text)
|
|
212
218
|
raise RDoc::Error, 'replacing document-only comment is not allowed' if
|
|
213
219
|
@text.nil? and @document
|
|
214
220
|
|
|
@@ -223,14 +229,190 @@ class RDoc::Comment
|
|
|
223
229
|
@format == 'tomdoc'
|
|
224
230
|
end
|
|
225
231
|
|
|
226
|
-
|
|
227
|
-
# Create a new parsed comment from a document
|
|
232
|
+
MULTILINE_DIRECTIVES = %w[call-seq].freeze # :nodoc:
|
|
228
233
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
# There are more, but already handled by RDoc::Parser::C
|
|
235
|
+
COLON_LESS_DIRECTIVES = %w[call-seq Document-method].freeze # :nodoc:
|
|
236
|
+
|
|
237
|
+
DIRECTIVE_OR_ESCAPED_DIRECTIV_REGEXP = /\A(?<colon>\\?:|:?)(?<directive>[\w-]+):(?<param>.*)/
|
|
238
|
+
|
|
239
|
+
private_constant :MULTILINE_DIRECTIVES, :COLON_LESS_DIRECTIVES, :DIRECTIVE_OR_ESCAPED_DIRECTIV_REGEXP
|
|
240
|
+
|
|
241
|
+
class << self
|
|
242
|
+
|
|
243
|
+
##
|
|
244
|
+
# Create a new parsed comment from a document
|
|
235
245
|
|
|
246
|
+
def from_document(document) # :nodoc:
|
|
247
|
+
comment = RDoc::Comment.new('')
|
|
248
|
+
comment.document = document
|
|
249
|
+
comment.location = RDoc::TopLevel.new(document.file) if document.file
|
|
250
|
+
comment
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Parse comment, collect directives as an attribute and return [normalized_comment_text, directives_hash]
|
|
254
|
+
# This method expands include and removes everything not needed in the document text, such as
|
|
255
|
+
# private section, directive line, comment characters `# /* * */` and indent spaces.
|
|
256
|
+
#
|
|
257
|
+
# RDoc comment consists of include, directive, multiline directive, private section and comment text.
|
|
258
|
+
#
|
|
259
|
+
# Include
|
|
260
|
+
# # :include: filename
|
|
261
|
+
#
|
|
262
|
+
# Directive
|
|
263
|
+
# # :directive-without-value:
|
|
264
|
+
# # :directive-with-value: value
|
|
265
|
+
#
|
|
266
|
+
# Multiline directive (only :call-seq:)
|
|
267
|
+
# # :multiline-directive:
|
|
268
|
+
# # value1
|
|
269
|
+
# # value2
|
|
270
|
+
#
|
|
271
|
+
# Private section
|
|
272
|
+
# #--
|
|
273
|
+
# # private comment
|
|
274
|
+
# #++
|
|
275
|
+
|
|
276
|
+
def parse(text, filename, line_no, type, &include_callback)
|
|
277
|
+
case type
|
|
278
|
+
when :ruby
|
|
279
|
+
text = text.gsub(/^#+/, '') if text.start_with?('#')
|
|
280
|
+
private_start_regexp = /^-{2,}$/
|
|
281
|
+
private_end_regexp = /^\+{2}$/
|
|
282
|
+
indent_regexp = /^\s*/
|
|
283
|
+
when :c
|
|
284
|
+
private_start_regexp = /^(\s*\*)?-{2,}$/
|
|
285
|
+
private_end_regexp = /^(\s*\*)?\+{2}$/
|
|
286
|
+
indent_regexp = /^\s*(\/\*+|\*)?\s*/
|
|
287
|
+
text = text.gsub(/\s*\*+\/\s*\z/, '')
|
|
288
|
+
when :simple
|
|
289
|
+
# Unlike other types, this implementation only looks for two dashes at
|
|
290
|
+
# the beginning of the line. Three or more dashes are considered to be
|
|
291
|
+
# a rule and ignored.
|
|
292
|
+
private_start_regexp = /^-{2}$/
|
|
293
|
+
private_end_regexp = /^\+{2}$/
|
|
294
|
+
indent_regexp = /^\s*/
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
directives = {}
|
|
298
|
+
lines = text.split("\n")
|
|
299
|
+
in_private = false
|
|
300
|
+
comment_lines = []
|
|
301
|
+
until lines.empty?
|
|
302
|
+
line = lines.shift
|
|
303
|
+
read_lines = 1
|
|
304
|
+
if in_private
|
|
305
|
+
# If `++` appears in a private section that starts with `--`, private section ends.
|
|
306
|
+
in_private = false if line.match?(private_end_regexp)
|
|
307
|
+
line_no += read_lines
|
|
308
|
+
next
|
|
309
|
+
elsif line.match?(private_start_regexp)
|
|
310
|
+
# If `--` appears in a line, private section starts.
|
|
311
|
+
in_private = true
|
|
312
|
+
line_no += read_lines
|
|
313
|
+
next
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
prefix = line[indent_regexp]
|
|
317
|
+
prefix_indent = ' ' * prefix.size
|
|
318
|
+
line = line.byteslice(prefix.bytesize..)
|
|
319
|
+
|
|
320
|
+
if (directive_match = DIRECTIVE_OR_ESCAPED_DIRECTIV_REGEXP.match(line))
|
|
321
|
+
colon = directive_match[:colon]
|
|
322
|
+
directive = directive_match[:directive]
|
|
323
|
+
raw_param = directive_match[:param]
|
|
324
|
+
param = raw_param.strip
|
|
325
|
+
else
|
|
326
|
+
colon = directive = raw_param = param = nil
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
if !directive
|
|
330
|
+
comment_lines << prefix_indent + line
|
|
331
|
+
elsif colon == '\\:'
|
|
332
|
+
# If directive is escaped, unescape it
|
|
333
|
+
comment_lines << prefix_indent + line.sub('\\:', ':')
|
|
334
|
+
elsif raw_param.start_with?(':') || (colon.empty? && !COLON_LESS_DIRECTIVES.include?(directive))
|
|
335
|
+
# Something like `:toto::` is not a directive
|
|
336
|
+
# Only few directives allows to start without a colon
|
|
337
|
+
comment_lines << prefix_indent + line
|
|
338
|
+
elsif directive == 'include'
|
|
339
|
+
filename_to_include = param
|
|
340
|
+
include_callback.call(filename_to_include, prefix_indent).lines.each { |l| comment_lines << l.chomp }
|
|
341
|
+
elsif MULTILINE_DIRECTIVES.include?(directive)
|
|
342
|
+
value_lines = take_multiline_directive_value_lines(directive, filename, line_no, lines, prefix_indent.size, indent_regexp, !param.empty?)
|
|
343
|
+
read_lines += value_lines.size
|
|
344
|
+
lines.shift(value_lines.size)
|
|
345
|
+
unless param.empty?
|
|
346
|
+
# Accept `:call-seq: first-line\n second-line` for now
|
|
347
|
+
value_lines.unshift(param)
|
|
348
|
+
end
|
|
349
|
+
value = value_lines.join("\n")
|
|
350
|
+
directives[directive] = [value.empty? ? nil : value, line_no]
|
|
351
|
+
else
|
|
352
|
+
directives[directive] = [param.empty? ? nil : param, line_no]
|
|
353
|
+
end
|
|
354
|
+
line_no += read_lines
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
normalized_comment = String.new(encoding: text.encoding) << normalize_comment_lines(comment_lines).join("\n")
|
|
358
|
+
[normalized_comment, directives]
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# Remove preceding indent spaces and blank lines from the comment lines
|
|
362
|
+
|
|
363
|
+
private def normalize_comment_lines(lines)
|
|
364
|
+
blank_line_regexp = /\A\s*\z/
|
|
365
|
+
lines = lines.dup
|
|
366
|
+
lines.shift while lines.first&.match?(blank_line_regexp)
|
|
367
|
+
lines.pop while lines.last&.match?(blank_line_regexp)
|
|
368
|
+
|
|
369
|
+
min_spaces = lines.map do |l|
|
|
370
|
+
l.match(/\A *(?=\S)/)&.end(0)
|
|
371
|
+
end.compact.min
|
|
372
|
+
if min_spaces && min_spaces > 0
|
|
373
|
+
lines.map { |l| l[min_spaces..] || '' }
|
|
374
|
+
else
|
|
375
|
+
lines
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Take value lines of multiline directive
|
|
380
|
+
|
|
381
|
+
private def take_multiline_directive_value_lines(directive, filename, line_no, lines, base_indent_size, indent_regexp, has_param)
|
|
382
|
+
return [] if lines.empty?
|
|
383
|
+
|
|
384
|
+
first_indent_size = lines.first.match(indent_regexp).end(0)
|
|
385
|
+
|
|
386
|
+
# Blank line or unindented line is not part of multiline-directive value
|
|
387
|
+
return [] if first_indent_size <= base_indent_size
|
|
388
|
+
|
|
389
|
+
if has_param
|
|
390
|
+
# :multiline-directive: line1
|
|
391
|
+
# line2
|
|
392
|
+
# line3
|
|
393
|
+
#
|
|
394
|
+
value_lines = lines.take_while do |l|
|
|
395
|
+
l.rstrip.match(indent_regexp).end(0) > base_indent_size
|
|
396
|
+
end
|
|
397
|
+
min_indent = value_lines.map { |l| l.match(indent_regexp).end(0) }.min
|
|
398
|
+
value_lines.map { |l| l[min_indent..] }
|
|
399
|
+
else
|
|
400
|
+
# Take indented lines accepting blank lines between them
|
|
401
|
+
value_lines = lines.take_while do |l|
|
|
402
|
+
l = l.rstrip
|
|
403
|
+
indent = l[indent_regexp]
|
|
404
|
+
if indent == l || indent.size >= first_indent_size
|
|
405
|
+
true
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
value_lines.map! { |l| (l[first_indent_size..] || '').chomp }
|
|
409
|
+
|
|
410
|
+
if value_lines.size != lines.size && !value_lines.last.empty?
|
|
411
|
+
warn "#{filename}:#{line_no} Multiline directive :#{directive}: should end with a blank line."
|
|
412
|
+
end
|
|
413
|
+
value_lines.pop while value_lines.last&.empty?
|
|
414
|
+
value_lines
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
end
|
|
236
418
|
end
|
data/lib/rdoc/cross_reference.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
190
|
+
def resolve(name, text)
|
|
191
191
|
return @seen[name] if @seen.include? name
|
|
192
192
|
|
|
193
193
|
ref = case name
|
|
@@ -200,7 +200,7 @@ class RDoc::CrossReference
|
|
|
200
200
|
ref = resolve_method name unless ref
|
|
201
201
|
|
|
202
202
|
# Try a page name
|
|
203
|
-
ref = @store.page name if not ref and name =~ /^[\w
|
|
203
|
+
ref = @store.page name if not ref and name =~ /^[\w.\/]+$/
|
|
204
204
|
|
|
205
205
|
ref = nil if RDoc::Alias === ref # external alias, can't link to it
|
|
206
206
|
|
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
|
|
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
|
|
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
|
|
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
|
|
112
|
+
def self.change_encoding(text, encoding)
|
|
113
113
|
if text.kind_of? RDoc::Comment
|
|
114
114
|
text.encode! encoding
|
|
115
115
|
else
|
data/lib/rdoc/erb_partial.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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 = []
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Aliki theme for RDoc documentation
|
|
5
|
+
#
|
|
6
|
+
# Author: Stan Lo
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
|
|
10
|
+
RDoc::RDoc.add_generator self
|
|
11
|
+
|
|
12
|
+
def initialize(store, options)
|
|
13
|
+
super
|
|
14
|
+
aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki'))
|
|
15
|
+
@template_dir = Pathname.new(aliki_template_dir)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Copy only the static assets required by the Aliki theme. Unlike Darkfish we
|
|
20
|
+
# don't ship embedded fonts or image sprites, so limit the asset list to keep
|
|
21
|
+
# generated documentation lightweight.
|
|
22
|
+
|
|
23
|
+
def write_style_sheet
|
|
24
|
+
debug_msg "Copying Aliki static files"
|
|
25
|
+
options = { verbose: $DEBUG_RDOC, noop: @dry_run }
|
|
26
|
+
|
|
27
|
+
install_rdoc_static_file @template_dir + 'css/rdoc.css', "./css/rdoc.css", options
|
|
28
|
+
|
|
29
|
+
unless @options.template_stylesheets.empty?
|
|
30
|
+
FileUtils.cp @options.template_stylesheets, '.', **options
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Dir[(@template_dir + 'js/**/*').to_s].each do |path|
|
|
34
|
+
next if File.directory?(path)
|
|
35
|
+
next if File.basename(path).start_with?('.')
|
|
36
|
+
|
|
37
|
+
dst = Pathname.new(path).relative_path_from(@template_dir)
|
|
38
|
+
|
|
39
|
+
install_rdoc_static_file @template_dir + path, dst, options
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|