gitlab-rdoc 6.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +133 -0
- data/RI.rdoc +57 -0
- data/Rakefile +101 -0
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/exe/rdoc +44 -0
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +112 -0
- data/lib/rdoc/anon_class.rb +11 -0
- data/lib/rdoc/any_method.rb +361 -0
- data/lib/rdoc/attr.rb +176 -0
- data/lib/rdoc/class_module.rb +802 -0
- data/lib/rdoc/code_object.rb +421 -0
- data/lib/rdoc/code_objects.rb +6 -0
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +187 -0
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +1266 -0
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +136 -0
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +42 -0
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +790 -0
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +160 -0
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +31 -0
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +51 -0
- data/lib/rdoc/ghost_method.rb +7 -0
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +10 -0
- data/lib/rdoc/known_classes.rb +73 -0
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +417 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16685 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +409 -0
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +28 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +165 -0
- data/lib/rdoc/markup/formatter.rb +266 -0
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +79 -0
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +102 -0
- data/lib/rdoc/markup/list_item.rb +100 -0
- data/lib/rdoc/markup/paragraph.rb +29 -0
- data/lib/rdoc/markup/parser.rb +575 -0
- data/lib/rdoc/markup/pre_process.rb +296 -0
- data/lib/rdoc/markup/raw.rb +70 -0
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +21 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +94 -0
- data/lib/rdoc/markup/to_bs.rb +77 -0
- data/lib/rdoc/markup/to_html.rb +444 -0
- data/lib/rdoc/markup/to_html_crossref.rb +176 -0
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +362 -0
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +70 -0
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +84 -0
- data/lib/rdoc/markup.rb +867 -0
- data/lib/rdoc/meta_method.rb +7 -0
- data/lib/rdoc/method_attr.rb +419 -0
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +93 -0
- data/lib/rdoc/normal_module.rb +74 -0
- data/lib/rdoc/options.rb +1285 -0
- data/lib/rdoc/parser/c.rb +1225 -0
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +2327 -0
- data/lib/rdoc/parser/ruby_tools.rb +167 -0
- data/lib/rdoc/parser/simple.rb +61 -0
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +277 -0
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +579 -0
- data/lib/rdoc/require.rb +52 -0
- data/lib/rdoc/ri/driver.rb +1572 -0
- data/lib/rdoc/ri/formatter.rb +6 -0
- data/lib/rdoc/ri/paths.rb +171 -0
- data/lib/rdoc/ri/store.rb +7 -0
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +21 -0
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +26 -0
- data/lib/rdoc/stats/normal.rb +58 -0
- data/lib/rdoc/stats/quiet.rb +60 -0
- data/lib/rdoc/stats/verbose.rb +46 -0
- data/lib/rdoc/stats.rb +462 -0
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +329 -0
- data/lib/rdoc/text.rb +304 -0
- data/lib/rdoc/token_stream.rb +119 -0
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +289 -0
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +201 -0
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +279 -0
@@ -0,0 +1,296 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# Handle common directives that can occur in a block of text:
|
4
|
+
#
|
5
|
+
# \:include: filename
|
6
|
+
#
|
7
|
+
# Directives can be escaped by preceding them with a backslash.
|
8
|
+
#
|
9
|
+
# RDoc plugin authors can register additional directives to be handled by
|
10
|
+
# using RDoc::Markup::PreProcess::register.
|
11
|
+
#
|
12
|
+
# Any directive that is not built-in to RDoc (including those registered via
|
13
|
+
# plugins) will be stored in the metadata hash on the CodeObject the comment
|
14
|
+
# is attached to. See RDoc::Markup@Directives for the list of built-in
|
15
|
+
# directives.
|
16
|
+
|
17
|
+
class RDoc::Markup::PreProcess
|
18
|
+
|
19
|
+
##
|
20
|
+
# An RDoc::Options instance that will be filled in with overrides from
|
21
|
+
# directives
|
22
|
+
|
23
|
+
attr_accessor :options
|
24
|
+
|
25
|
+
##
|
26
|
+
# Adds a post-process handler for directives. The handler will be called
|
27
|
+
# with the result RDoc::Comment (or text String) and the code object for the
|
28
|
+
# comment (if any).
|
29
|
+
|
30
|
+
def self.post_process &block
|
31
|
+
@post_processors << block
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Registered post-processors
|
36
|
+
|
37
|
+
def self.post_processors
|
38
|
+
@post_processors
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Registers +directive+ as one handled by RDoc. If a block is given the
|
43
|
+
# directive will be replaced by the result of the block, otherwise the
|
44
|
+
# directive will be removed from the processed text.
|
45
|
+
#
|
46
|
+
# The block will be called with the directive name and the directive
|
47
|
+
# parameter:
|
48
|
+
#
|
49
|
+
# RDoc::Markup::PreProcess.register 'my-directive' do |directive, param|
|
50
|
+
# # replace text, etc.
|
51
|
+
# end
|
52
|
+
|
53
|
+
def self.register directive, &block
|
54
|
+
@registered[directive] = block
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Registered directives
|
59
|
+
|
60
|
+
def self.registered
|
61
|
+
@registered
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Clears all registered directives and post-processors
|
66
|
+
|
67
|
+
def self.reset
|
68
|
+
@post_processors = []
|
69
|
+
@registered = {}
|
70
|
+
end
|
71
|
+
|
72
|
+
reset
|
73
|
+
|
74
|
+
##
|
75
|
+
# Creates a new pre-processor for +input_file_name+ that will look for
|
76
|
+
# included files in +include_path+
|
77
|
+
|
78
|
+
def initialize(input_file_name, include_path)
|
79
|
+
@input_file_name = input_file_name
|
80
|
+
@include_path = include_path
|
81
|
+
@options = nil
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Look for directives in the given +text+.
|
86
|
+
#
|
87
|
+
# Options that we don't handle are yielded. If the block returns false the
|
88
|
+
# directive is restored to the text. If the block returns nil or no block
|
89
|
+
# was given the directive is handled according to the registered directives.
|
90
|
+
# If a String was returned the directive is replaced with the string.
|
91
|
+
#
|
92
|
+
# If no matching directive was registered the directive is restored to the
|
93
|
+
# text.
|
94
|
+
#
|
95
|
+
# If +code_object+ is given and the directive is unknown then the
|
96
|
+
# directive's parameter is set as metadata on the +code_object+. See
|
97
|
+
# RDoc::CodeObject#metadata for details.
|
98
|
+
|
99
|
+
def handle text, code_object = nil, &block
|
100
|
+
if RDoc::Comment === text then
|
101
|
+
comment = text
|
102
|
+
text = text.text
|
103
|
+
end
|
104
|
+
|
105
|
+
# regexp helper (square brackets for optional)
|
106
|
+
# $1 $2 $3 $4 $5
|
107
|
+
# [prefix][\]:directive:[spaces][param]newline
|
108
|
+
text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
|
109
|
+
# skip something like ':toto::'
|
110
|
+
next $& if $4.empty? and $5 and $5[0, 1] == ':'
|
111
|
+
|
112
|
+
# skip if escaped
|
113
|
+
next "#$1:#$3:#$4#$5\n" unless $2.empty?
|
114
|
+
|
115
|
+
# This is not in handle_directive because I didn't want to pass another
|
116
|
+
# argument into it
|
117
|
+
if comment and $3 == 'markup' then
|
118
|
+
next "#{$1.strip}\n" unless $5
|
119
|
+
comment.format = $5.downcase
|
120
|
+
next "#{$1.strip}\n"
|
121
|
+
end
|
122
|
+
|
123
|
+
handle_directive $1, $3, $5, code_object, text.encoding, &block
|
124
|
+
end
|
125
|
+
|
126
|
+
if comment then
|
127
|
+
comment.text = text
|
128
|
+
else
|
129
|
+
comment = text
|
130
|
+
end
|
131
|
+
|
132
|
+
self.class.post_processors.each do |handler|
|
133
|
+
handler.call comment, code_object
|
134
|
+
end
|
135
|
+
|
136
|
+
text
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# Performs the actions described by +directive+ and its parameter +param+.
|
141
|
+
#
|
142
|
+
# +code_object+ is used for directives that operate on a class or module.
|
143
|
+
# +prefix+ is used to ensure the replacement for handled directives is
|
144
|
+
# correct. +encoding+ is used for the <tt>include</tt> directive.
|
145
|
+
#
|
146
|
+
# For a list of directives in RDoc see RDoc::Markup.
|
147
|
+
#--
|
148
|
+
# When 1.8.7 support is ditched prefix can be defaulted to ''
|
149
|
+
|
150
|
+
def handle_directive prefix, directive, param, code_object = nil,
|
151
|
+
encoding = nil
|
152
|
+
blankline = "#{prefix.strip}\n"
|
153
|
+
directive = directive.downcase
|
154
|
+
|
155
|
+
case directive
|
156
|
+
when 'arg', 'args' then
|
157
|
+
return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod)
|
158
|
+
|
159
|
+
code_object.params = param
|
160
|
+
|
161
|
+
blankline
|
162
|
+
when 'category' then
|
163
|
+
if RDoc::Context === code_object then
|
164
|
+
section = code_object.add_section param
|
165
|
+
code_object.temporary_section = section
|
166
|
+
end
|
167
|
+
|
168
|
+
blankline # ignore category if we're not on an RDoc::Context
|
169
|
+
when 'doc' then
|
170
|
+
return blankline unless code_object
|
171
|
+
code_object.document_self = true
|
172
|
+
code_object.force_documentation = true
|
173
|
+
|
174
|
+
blankline
|
175
|
+
when 'enddoc' then
|
176
|
+
return blankline unless code_object
|
177
|
+
code_object.done_documenting = true
|
178
|
+
|
179
|
+
blankline
|
180
|
+
when 'include' then
|
181
|
+
filename = param.split(' ', 2).first
|
182
|
+
include_file filename, prefix, encoding
|
183
|
+
when 'main' then
|
184
|
+
@options.main_page = param if @options.respond_to? :main_page
|
185
|
+
|
186
|
+
blankline
|
187
|
+
when 'nodoc' then
|
188
|
+
return blankline unless code_object
|
189
|
+
code_object.document_self = nil # notify nodoc
|
190
|
+
code_object.document_children = param !~ /all/i
|
191
|
+
|
192
|
+
blankline
|
193
|
+
when 'notnew', 'not_new', 'not-new' then
|
194
|
+
return blankline unless RDoc::AnyMethod === code_object
|
195
|
+
|
196
|
+
code_object.dont_rename_initialize = true
|
197
|
+
|
198
|
+
blankline
|
199
|
+
when 'startdoc' then
|
200
|
+
return blankline unless code_object
|
201
|
+
|
202
|
+
code_object.start_doc
|
203
|
+
code_object.force_documentation = true
|
204
|
+
|
205
|
+
blankline
|
206
|
+
when 'stopdoc' then
|
207
|
+
return blankline unless code_object
|
208
|
+
|
209
|
+
code_object.stop_doc
|
210
|
+
|
211
|
+
blankline
|
212
|
+
when 'title' then
|
213
|
+
@options.default_title = param if @options.respond_to? :default_title=
|
214
|
+
|
215
|
+
blankline
|
216
|
+
when 'yield', 'yields' then
|
217
|
+
return blankline unless code_object
|
218
|
+
# remove parameter &block
|
219
|
+
code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
|
220
|
+
|
221
|
+
code_object.block_params = param
|
222
|
+
|
223
|
+
blankline
|
224
|
+
else
|
225
|
+
result = yield directive, param if block_given?
|
226
|
+
|
227
|
+
case result
|
228
|
+
when nil then
|
229
|
+
code_object.metadata[directive] = param if code_object
|
230
|
+
|
231
|
+
if RDoc::Markup::PreProcess.registered.include? directive then
|
232
|
+
handler = RDoc::Markup::PreProcess.registered[directive]
|
233
|
+
result = handler.call directive, param if handler
|
234
|
+
else
|
235
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
236
|
+
end
|
237
|
+
when false then
|
238
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
239
|
+
end
|
240
|
+
|
241
|
+
result
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
##
|
246
|
+
# Handles the <tt>:include: _filename_</tt> directive.
|
247
|
+
#
|
248
|
+
# If the first line of the included file starts with '#', and contains
|
249
|
+
# an encoding information in the form 'coding:' or 'coding=', it is
|
250
|
+
# removed.
|
251
|
+
#
|
252
|
+
# If all lines in the included file start with a '#', this leading '#'
|
253
|
+
# is removed before inclusion. The included content is indented like
|
254
|
+
# the <tt>:include:</tt> directive.
|
255
|
+
#--
|
256
|
+
# so all content will be verbatim because of the likely space after '#'?
|
257
|
+
# TODO shift left the whole file content in that case
|
258
|
+
# TODO comment stop/start #-- and #++ in included file must be processed here
|
259
|
+
|
260
|
+
def include_file name, indent, encoding
|
261
|
+
full_name = find_include_file name
|
262
|
+
|
263
|
+
unless full_name then
|
264
|
+
warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
|
265
|
+
return ''
|
266
|
+
end
|
267
|
+
|
268
|
+
content = RDoc::Encoding.read_file full_name, encoding, true
|
269
|
+
content = RDoc::Encoding.remove_magic_comment content
|
270
|
+
|
271
|
+
# strip magic comment
|
272
|
+
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
|
273
|
+
|
274
|
+
# strip leading '#'s, but only if all lines start with them
|
275
|
+
if content =~ /^[^#]/ then
|
276
|
+
content.gsub(/^/, indent)
|
277
|
+
else
|
278
|
+
content.gsub(/^#?/, indent)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
##
|
283
|
+
# Look for the given file in the directory containing the current file,
|
284
|
+
# and then in each of the directories specified in the RDOC_INCLUDE path
|
285
|
+
|
286
|
+
def find_include_file(name)
|
287
|
+
to_search = [File.dirname(@input_file_name)].concat @include_path
|
288
|
+
to_search.each do |dir|
|
289
|
+
full_name = File.join(dir, name)
|
290
|
+
stat = File.stat(full_name) rescue next
|
291
|
+
return full_name if stat.readable?
|
292
|
+
end
|
293
|
+
nil
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# A section of text that is added to the output document as-is
|
4
|
+
|
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+
|
22
|
+
|
23
|
+
def << text
|
24
|
+
@parts << text
|
25
|
+
end
|
26
|
+
|
27
|
+
def == other # :nodoc:
|
28
|
+
self.class == other.class and @parts == other.parts
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Calls #accept_raw+ on +visitor+
|
33
|
+
|
34
|
+
def accept visitor
|
35
|
+
visitor.accept_raw self
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Appends +other+'s parts
|
40
|
+
|
41
|
+
def merge other
|
42
|
+
@parts.concat other.parts
|
43
|
+
end
|
44
|
+
|
45
|
+
def pretty_print q # :nodoc:
|
46
|
+
self.class.name =~ /.*::(\w{1,4})/i
|
47
|
+
|
48
|
+
q.group 2, "[#{$1.downcase}: ", ']' do
|
49
|
+
q.seplist @parts do |part|
|
50
|
+
q.pp part
|
51
|
+
end
|
52
|
+
end
|
53
|
+
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
|
+
end
|
70
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# Hold details of a regexp handling sequence
|
4
|
+
|
5
|
+
class RDoc::Markup::RegexpHandling
|
6
|
+
|
7
|
+
##
|
8
|
+
# Regexp handling type
|
9
|
+
|
10
|
+
attr_reader :type
|
11
|
+
|
12
|
+
##
|
13
|
+
# Regexp handling text
|
14
|
+
|
15
|
+
attr_accessor :text
|
16
|
+
|
17
|
+
##
|
18
|
+
# Creates a new regexp handling sequence of +type+ with +text+
|
19
|
+
|
20
|
+
def initialize(type, text)
|
21
|
+
@type, @text = type, text
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Regexp handlings are equal when the have the same text and type
|
26
|
+
|
27
|
+
def ==(o)
|
28
|
+
self.text == o.text && self.type == o.type
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect # :nodoc:
|
32
|
+
"#<RDoc::Markup::RegexpHandling:0x%x @type=%p, @text=%p>" % [
|
33
|
+
object_id, @type, text.dump]
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s # :nodoc:
|
37
|
+
"RegexpHandling: type=#{type} text=#{text.dump}"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# A horizontal rule with a weight
|
4
|
+
|
5
|
+
class RDoc::Markup::Rule < Struct.new :weight
|
6
|
+
|
7
|
+
##
|
8
|
+
# Calls #accept_rule on +visitor+
|
9
|
+
|
10
|
+
def accept visitor
|
11
|
+
visitor.accept_rule self
|
12
|
+
end
|
13
|
+
|
14
|
+
def pretty_print q # :nodoc:
|
15
|
+
q.group 2, '[rule:', ']' do
|
16
|
+
q.pp weight
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# A section of table
|
4
|
+
|
5
|
+
class RDoc::Markup::Table
|
6
|
+
attr_accessor :header, :align, :body
|
7
|
+
|
8
|
+
def initialize header, align, body
|
9
|
+
@header, @align, @body = header, align, body
|
10
|
+
end
|
11
|
+
|
12
|
+
def == other
|
13
|
+
self.class == other.class and
|
14
|
+
@header == other.header and
|
15
|
+
@align == other.align and
|
16
|
+
@body == other.body
|
17
|
+
end
|
18
|
+
|
19
|
+
def accept visitor
|
20
|
+
visitor.accept_table @header, @body, @align
|
21
|
+
end
|
22
|
+
|
23
|
+
def pretty_print q # :nodoc:
|
24
|
+
q.group 2, '[Table: ', ']' do
|
25
|
+
q.group 2, '[Head: ', ']' do
|
26
|
+
q.seplist @header.zip(@align) do |text, align|
|
27
|
+
q.pp text
|
28
|
+
if align
|
29
|
+
q.text ":"
|
30
|
+
q.breakable
|
31
|
+
q.text align.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
q.breakable
|
36
|
+
q.group 2, '[Body: ', ']' do
|
37
|
+
q.seplist @body do |body|
|
38
|
+
q.group 2, '[', ']' do
|
39
|
+
q.seplist body do |text|
|
40
|
+
q.pp text
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|