gitlab-rdoc 6.3.2
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 +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,300 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'json'
|
|
3
|
+
begin
|
|
4
|
+
require 'zlib'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# The JsonIndex generator is designed to complement an HTML generator and
|
|
10
|
+
# produces a JSON search index. This generator is derived from sdoc by
|
|
11
|
+
# Vladimir Kolesnikov and contains verbatim code written by him.
|
|
12
|
+
#
|
|
13
|
+
# This generator is designed to be used with a regular HTML generator:
|
|
14
|
+
#
|
|
15
|
+
# class RDoc::Generator::Darkfish
|
|
16
|
+
# def initialize options
|
|
17
|
+
# # ...
|
|
18
|
+
# @base_dir = Pathname.pwd.expand_path
|
|
19
|
+
#
|
|
20
|
+
# @json_index = RDoc::Generator::JsonIndex.new self, options
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# def generate
|
|
24
|
+
# # ...
|
|
25
|
+
# @json_index.generate
|
|
26
|
+
# end
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# == Index Format
|
|
30
|
+
#
|
|
31
|
+
# The index is output as a JSON file assigned to the global variable
|
|
32
|
+
# +search_data+. The structure is:
|
|
33
|
+
#
|
|
34
|
+
# var search_data = {
|
|
35
|
+
# "index": {
|
|
36
|
+
# "searchIndex":
|
|
37
|
+
# ["a", "b", ...],
|
|
38
|
+
# "longSearchIndex":
|
|
39
|
+
# ["a", "a::b", ...],
|
|
40
|
+
# "info": [
|
|
41
|
+
# ["A", "A", "A.html", "", ""],
|
|
42
|
+
# ["B", "A::B", "A::B.html", "", ""],
|
|
43
|
+
# ...
|
|
44
|
+
# ]
|
|
45
|
+
# }
|
|
46
|
+
# }
|
|
47
|
+
#
|
|
48
|
+
# The same item is described across the +searchIndex+, +longSearchIndex+ and
|
|
49
|
+
# +info+ fields. The +searchIndex+ field contains the item's short name, the
|
|
50
|
+
# +longSearchIndex+ field contains the full_name (when appropriate) and the
|
|
51
|
+
# +info+ field contains the item's name, full_name, path, parameters and a
|
|
52
|
+
# snippet of the item's comment.
|
|
53
|
+
#
|
|
54
|
+
# == LICENSE
|
|
55
|
+
#
|
|
56
|
+
# Copyright (c) 2009 Vladimir Kolesnikov
|
|
57
|
+
#
|
|
58
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
59
|
+
# a copy of this software and associated documentation files (the
|
|
60
|
+
# "Software"), to deal in the Software without restriction, including
|
|
61
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
62
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
63
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
64
|
+
# the following conditions:
|
|
65
|
+
#
|
|
66
|
+
# The above copyright notice and this permission notice shall be
|
|
67
|
+
# included in all copies or substantial portions of the Software.
|
|
68
|
+
#
|
|
69
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
70
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
71
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
72
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
73
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
74
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
75
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
76
|
+
|
|
77
|
+
class RDoc::Generator::JsonIndex
|
|
78
|
+
|
|
79
|
+
include RDoc::Text
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
# Where the search index lives in the generated output
|
|
83
|
+
|
|
84
|
+
SEARCH_INDEX_FILE = File.join 'js', 'search_index.js'
|
|
85
|
+
|
|
86
|
+
attr_reader :index # :nodoc:
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# Creates a new generator. +parent_generator+ is used to determine the
|
|
90
|
+
# class_dir and file_dir of links in the output index.
|
|
91
|
+
#
|
|
92
|
+
# +options+ are the same options passed to the parent generator.
|
|
93
|
+
|
|
94
|
+
def initialize parent_generator, options
|
|
95
|
+
@parent_generator = parent_generator
|
|
96
|
+
@store = parent_generator.store
|
|
97
|
+
@options = options
|
|
98
|
+
|
|
99
|
+
@template_dir = File.expand_path '../template/json_index', __FILE__
|
|
100
|
+
@base_dir = @parent_generator.base_dir
|
|
101
|
+
|
|
102
|
+
@classes = nil
|
|
103
|
+
@files = nil
|
|
104
|
+
@index = nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# Builds the JSON index as a Hash.
|
|
109
|
+
|
|
110
|
+
def build_index
|
|
111
|
+
reset @store.all_files.sort, @store.all_classes_and_modules.sort
|
|
112
|
+
|
|
113
|
+
index_classes
|
|
114
|
+
index_methods
|
|
115
|
+
index_pages
|
|
116
|
+
|
|
117
|
+
{ :index => @index }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
##
|
|
121
|
+
# Output progress information if debugging is enabled
|
|
122
|
+
|
|
123
|
+
def debug_msg *msg
|
|
124
|
+
return unless $DEBUG_RDOC
|
|
125
|
+
$stderr.puts(*msg)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
##
|
|
129
|
+
# Writes the JSON index to disk
|
|
130
|
+
|
|
131
|
+
def generate
|
|
132
|
+
debug_msg "Generating JSON index"
|
|
133
|
+
|
|
134
|
+
debug_msg " writing search index to %s" % SEARCH_INDEX_FILE
|
|
135
|
+
data = build_index
|
|
136
|
+
|
|
137
|
+
return if @options.dry_run
|
|
138
|
+
|
|
139
|
+
out_dir = @base_dir + @options.op_dir
|
|
140
|
+
index_file = out_dir + SEARCH_INDEX_FILE
|
|
141
|
+
|
|
142
|
+
FileUtils.mkdir_p index_file.dirname, :verbose => $DEBUG_RDOC
|
|
143
|
+
|
|
144
|
+
index_file.open 'w', 0644 do |io|
|
|
145
|
+
io.set_encoding Encoding::UTF_8
|
|
146
|
+
io.write 'var search_data = '
|
|
147
|
+
|
|
148
|
+
JSON.dump data, io, 0
|
|
149
|
+
end
|
|
150
|
+
unless ENV['SOURCE_DATE_EPOCH'].nil?
|
|
151
|
+
index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
Dir.chdir @template_dir do
|
|
155
|
+
Dir['**/*.js'].each do |source|
|
|
156
|
+
dest = File.join out_dir, source
|
|
157
|
+
|
|
158
|
+
FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
##
|
|
164
|
+
# Compress the search_index.js file using gzip
|
|
165
|
+
|
|
166
|
+
def generate_gzipped
|
|
167
|
+
return if @options.dry_run or not defined?(Zlib)
|
|
168
|
+
|
|
169
|
+
debug_msg "Compressing generated JSON index"
|
|
170
|
+
out_dir = @base_dir + @options.op_dir
|
|
171
|
+
|
|
172
|
+
search_index_file = out_dir + SEARCH_INDEX_FILE
|
|
173
|
+
outfile = out_dir + "#{search_index_file}.gz"
|
|
174
|
+
|
|
175
|
+
debug_msg "Reading the JSON index file from %s" % search_index_file
|
|
176
|
+
search_index = search_index_file.read(mode: 'r:utf-8')
|
|
177
|
+
|
|
178
|
+
debug_msg "Writing gzipped search index to %s" % outfile
|
|
179
|
+
|
|
180
|
+
Zlib::GzipWriter.open(outfile) do |gz|
|
|
181
|
+
gz.mtime = File.mtime(search_index_file)
|
|
182
|
+
gz.orig_name = search_index_file.basename.to_s
|
|
183
|
+
gz.write search_index
|
|
184
|
+
gz.close
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# GZip the rest of the js files
|
|
188
|
+
Dir.chdir @template_dir do
|
|
189
|
+
Dir['**/*.js'].each do |source|
|
|
190
|
+
dest = out_dir + source
|
|
191
|
+
outfile = out_dir + "#{dest}.gz"
|
|
192
|
+
|
|
193
|
+
debug_msg "Reading the original js file from %s" % dest
|
|
194
|
+
data = dest.read
|
|
195
|
+
|
|
196
|
+
debug_msg "Writing gzipped file to %s" % outfile
|
|
197
|
+
|
|
198
|
+
Zlib::GzipWriter.open(outfile) do |gz|
|
|
199
|
+
gz.mtime = File.mtime(dest)
|
|
200
|
+
gz.orig_name = dest.basename.to_s
|
|
201
|
+
gz.write data
|
|
202
|
+
gz.close
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
##
|
|
209
|
+
# Adds classes and modules to the index
|
|
210
|
+
|
|
211
|
+
def index_classes
|
|
212
|
+
debug_msg " generating class search index"
|
|
213
|
+
|
|
214
|
+
documented = @classes.uniq.select do |klass|
|
|
215
|
+
klass.document_self_or_methods
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
documented.each do |klass|
|
|
219
|
+
debug_msg " #{klass.full_name}"
|
|
220
|
+
record = klass.search_record
|
|
221
|
+
@index[:searchIndex] << search_string(record.shift)
|
|
222
|
+
@index[:longSearchIndex] << search_string(record.shift)
|
|
223
|
+
@index[:info] << record
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
##
|
|
228
|
+
# Adds methods to the index
|
|
229
|
+
|
|
230
|
+
def index_methods
|
|
231
|
+
debug_msg " generating method search index"
|
|
232
|
+
|
|
233
|
+
list = @classes.uniq.map do |klass|
|
|
234
|
+
klass.method_list
|
|
235
|
+
end.flatten.sort_by do |method|
|
|
236
|
+
[method.name, method.parent.full_name]
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
list.each do |method|
|
|
240
|
+
debug_msg " #{method.full_name}"
|
|
241
|
+
record = method.search_record
|
|
242
|
+
@index[:searchIndex] << "#{search_string record.shift}()"
|
|
243
|
+
@index[:longSearchIndex] << "#{search_string record.shift}()"
|
|
244
|
+
@index[:info] << record
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
##
|
|
249
|
+
# Adds pages to the index
|
|
250
|
+
|
|
251
|
+
def index_pages
|
|
252
|
+
debug_msg " generating pages search index"
|
|
253
|
+
|
|
254
|
+
pages = @files.select do |file|
|
|
255
|
+
file.text?
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
pages.each do |page|
|
|
259
|
+
debug_msg " #{page.page_name}"
|
|
260
|
+
record = page.search_record
|
|
261
|
+
@index[:searchIndex] << search_string(record.shift)
|
|
262
|
+
@index[:longSearchIndex] << ''
|
|
263
|
+
record.shift
|
|
264
|
+
@index[:info] << record
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
##
|
|
269
|
+
# The directory classes are written to
|
|
270
|
+
|
|
271
|
+
def class_dir
|
|
272
|
+
@parent_generator.class_dir
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
##
|
|
276
|
+
# The directory files are written to
|
|
277
|
+
|
|
278
|
+
def file_dir
|
|
279
|
+
@parent_generator.file_dir
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def reset files, classes # :nodoc:
|
|
283
|
+
@files = files
|
|
284
|
+
@classes = classes
|
|
285
|
+
|
|
286
|
+
@index = {
|
|
287
|
+
:searchIndex => [],
|
|
288
|
+
:longSearchIndex => [],
|
|
289
|
+
:info => []
|
|
290
|
+
}
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
##
|
|
294
|
+
# Removes whitespace and downcases +string+
|
|
295
|
+
|
|
296
|
+
def search_string string
|
|
297
|
+
string.downcase.gsub(/\s/, '')
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# Handle common RDoc::Markup tasks for various CodeObjects
|
|
4
|
+
#
|
|
5
|
+
# This module is loaded by generators. It allows RDoc's CodeObject tree to
|
|
6
|
+
# avoid loading generator code to improve startup time for +ri+.
|
|
7
|
+
|
|
8
|
+
module RDoc::Generator::Markup
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
# Generates a relative URL from this object's path to +target_path+
|
|
12
|
+
|
|
13
|
+
def aref_to(target_path)
|
|
14
|
+
RDoc::Markup::ToHtml.gen_relative_url path, target_path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
##
|
|
18
|
+
# Generates a relative URL from +from_path+ to this object's path
|
|
19
|
+
|
|
20
|
+
def as_href(from_path)
|
|
21
|
+
RDoc::Markup::ToHtml.gen_relative_url from_path, path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Handy wrapper for marking up this object's comment
|
|
26
|
+
|
|
27
|
+
def description
|
|
28
|
+
markup @comment
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Creates an RDoc::Markup::ToHtmlCrossref formatter
|
|
33
|
+
|
|
34
|
+
def formatter
|
|
35
|
+
return @formatter if defined? @formatter
|
|
36
|
+
|
|
37
|
+
options = @store.rdoc.options
|
|
38
|
+
this = RDoc::Context === self ? self : @parent
|
|
39
|
+
|
|
40
|
+
@formatter = RDoc::Markup::ToHtmlCrossref.new options, this.path, this
|
|
41
|
+
@formatter.code_object = self
|
|
42
|
+
@formatter
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Build a webcvs URL starting for the given +url+ with +full_path+ appended
|
|
47
|
+
# as the destination path. If +url+ contains '%s' +full_path+ will be
|
|
48
|
+
# will replace the %s using sprintf on the +url+.
|
|
49
|
+
|
|
50
|
+
def cvs_url(url, full_path)
|
|
51
|
+
if /%s/ =~ url then
|
|
52
|
+
sprintf url, full_path
|
|
53
|
+
else
|
|
54
|
+
url + full_path
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class RDoc::CodeObject
|
|
61
|
+
|
|
62
|
+
include RDoc::Generator::Markup
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class RDoc::MethodAttr
|
|
67
|
+
|
|
68
|
+
##
|
|
69
|
+
# Prepend +src+ with line numbers. Relies on the first line of a source
|
|
70
|
+
# code listing having:
|
|
71
|
+
#
|
|
72
|
+
# # File xxxxx, line dddd
|
|
73
|
+
#
|
|
74
|
+
# If it has this comment then line numbers are added to +src+ and the <tt>,
|
|
75
|
+
# line dddd</tt> portion of the comment is removed.
|
|
76
|
+
|
|
77
|
+
def add_line_numbers(src)
|
|
78
|
+
return unless src.sub!(/\A(.*)(, line (\d+))/, '\1')
|
|
79
|
+
first = $3.to_i - 1
|
|
80
|
+
last = first + src.count("\n")
|
|
81
|
+
size = last.to_s.length
|
|
82
|
+
|
|
83
|
+
line = first
|
|
84
|
+
src.gsub!(/^/) do
|
|
85
|
+
res = if line == first then
|
|
86
|
+
" " * (size + 1)
|
|
87
|
+
else
|
|
88
|
+
"<span class=\"line-num\">%2$*1$d</span> " % [size, line]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
line += 1
|
|
92
|
+
res
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
##
|
|
97
|
+
# Turns the method's token stream into HTML.
|
|
98
|
+
#
|
|
99
|
+
# Prepends line numbers if +options.line_numbers+ is true.
|
|
100
|
+
|
|
101
|
+
def markup_code
|
|
102
|
+
return '' unless @token_stream
|
|
103
|
+
|
|
104
|
+
src = RDoc::TokenStream.to_html @token_stream
|
|
105
|
+
|
|
106
|
+
# dedent the source
|
|
107
|
+
indent = src.length
|
|
108
|
+
lines = src.lines.to_a
|
|
109
|
+
lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment
|
|
110
|
+
lines.each do |line|
|
|
111
|
+
if line =~ /^ *(?=\S)/
|
|
112
|
+
n = $&.length
|
|
113
|
+
indent = n if n < indent
|
|
114
|
+
break if n == 0
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
src.gsub!(/^#{' ' * indent}/, '') if indent > 0
|
|
118
|
+
|
|
119
|
+
add_line_numbers(src) if options.line_numbers
|
|
120
|
+
|
|
121
|
+
src
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
class RDoc::ClassModule
|
|
127
|
+
|
|
128
|
+
##
|
|
129
|
+
# Handy wrapper for marking up this class or module's comment
|
|
130
|
+
|
|
131
|
+
def description
|
|
132
|
+
markup @comment_location
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
class RDoc::Context::Section
|
|
138
|
+
|
|
139
|
+
include RDoc::Generator::Markup
|
|
140
|
+
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
class RDoc::TopLevel
|
|
144
|
+
|
|
145
|
+
##
|
|
146
|
+
# Returns a URL for this source file on some web repository. Use the -W
|
|
147
|
+
# command line option to set.
|
|
148
|
+
|
|
149
|
+
def cvs_url
|
|
150
|
+
url = @store.rdoc.options.webcvs
|
|
151
|
+
|
|
152
|
+
if /%s/ =~ url then
|
|
153
|
+
url % @relative_name
|
|
154
|
+
else
|
|
155
|
+
url + @relative_name
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
160
|
+
|