rdoc 6.16.1 → 7.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 +196 -0
- data/LEGAL.rdoc +6 -0
- data/README.md +90 -7
- data/doc/markup_reference/markdown.md +558 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/lib/rdoc/code_object/any_method.rb +15 -7
- data/lib/rdoc/code_object/class_module.rb +62 -11
- data/lib/rdoc/code_object/constant.rb +9 -0
- data/lib/rdoc/code_object/context/section.rb +20 -1
- data/lib/rdoc/code_object/method_attr.rb +13 -1
- data/lib/rdoc/code_object/top_level.rb +13 -1
- data/lib/rdoc/cross_reference.rb +30 -21
- data/lib/rdoc/generator/aliki.rb +141 -0
- data/lib/rdoc/generator/darkfish.rb +8 -2
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/_header.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +12 -2
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +12 -2
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +20 -10
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +20 -10
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +32 -12
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +58 -28
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +3 -3
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +16 -6
- data/lib/rdoc/generator/template/aliki/class.rhtml +13 -12
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +401 -50
- data/lib/rdoc/generator/template/aliki/index.rhtml +2 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +43 -21
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +1 -1
- data/lib/rdoc/generator/template/aliki/js/{search.js → search_controller.js} +15 -6
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +2 -1
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/class.rhtml +11 -11
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -0
- data/lib/rdoc/markdown.kpeg +1 -5
- data/lib/rdoc/markdown.rb +1 -5
- data/lib/rdoc/markup/attribute_manager.rb +28 -1
- data/lib/rdoc/markup/blank_line.rb +25 -23
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/hard_break.rb +30 -27
- data/lib/rdoc/markup/heading.rb +166 -77
- data/lib/rdoc/markup/raw.rb +52 -55
- data/lib/rdoc/markup/table.rb +48 -40
- data/lib/rdoc/markup/to_ansi.rb +4 -0
- data/lib/rdoc/markup/to_bs.rb +4 -0
- data/lib/rdoc/markup/to_html.rb +31 -11
- data/lib/rdoc/markup/to_html_crossref.rb +24 -5
- data/lib/rdoc/markup/to_label.rb +11 -1
- data/lib/rdoc/markup/to_rdoc.rb +11 -3
- data/lib/rdoc/markup/verbatim.rb +1 -1
- data/lib/rdoc/markup.rb +3 -2
- data/lib/rdoc/options.rb +1 -1
- data/lib/rdoc/parser/changelog.rb +8 -0
- data/lib/rdoc/rubygems_hook.rb +3 -3
- data/lib/rdoc/text.rb +15 -0
- data/lib/rdoc/token_stream.rb +4 -8
- data/lib/rdoc/version.rb +1 -1
- data/rdoc.gemspec +3 -3
- metadata +12 -10
- data/CONTRIBUTING.rdoc +0 -219
- data/ExampleMarkdown.md +0 -39
- data/ExampleRDoc.rdoc +0 -210
|
@@ -351,7 +351,6 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
|
351
351
|
return call_seq unless is_alias_for || !aliases.empty?
|
|
352
352
|
|
|
353
353
|
method_name = self.name
|
|
354
|
-
method_name = method_name[0, 1] if method_name =~ /\A\[/
|
|
355
354
|
|
|
356
355
|
entries = call_seq.split "\n"
|
|
357
356
|
|
|
@@ -360,15 +359,24 @@ class RDoc::AnyMethod < RDoc::MethodAttr
|
|
|
360
359
|
ignore << is_alias_for.name
|
|
361
360
|
ignore.concat is_alias_for.aliases.map(&:name)
|
|
362
361
|
end
|
|
363
|
-
|
|
362
|
+
|
|
364
363
|
ignore.delete(method_name)
|
|
365
|
-
|
|
364
|
+
ignore_bracket_methods, ignore_other_methods = ignore.partition {|i| i.start_with?('[') }
|
|
366
365
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
if ignore_other_methods.any?
|
|
367
|
+
ignore_union = Regexp.union(ignore_other_methods)
|
|
368
|
+
entries.reject! do |entry|
|
|
369
|
+
/\A(?:\w*\.)?#{ignore_union}(?:[(\s]|\z)/.match?(entry) ||
|
|
370
|
+
/\s#{ignore_union}\s/.match?(entry)
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
if ignore_bracket_methods.any?
|
|
374
|
+
entries.reject! do |entry|
|
|
375
|
+
# Ignore `receiver[arg] -> return_type` `[](arg)` `[]`
|
|
376
|
+
/\A\w*\[.*?\](?:[(\s]|\z)/.match?(entry)
|
|
377
|
+
end
|
|
370
378
|
end
|
|
371
379
|
|
|
372
|
-
|
|
380
|
+
entries.empty? ? nil : entries.join("\n")
|
|
373
381
|
end
|
|
374
382
|
end
|
|
@@ -30,7 +30,22 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
30
30
|
attr_accessor :constant_aliases
|
|
31
31
|
|
|
32
32
|
##
|
|
33
|
-
#
|
|
33
|
+
# An array of `[comment, location]` pairs documenting this class/module.
|
|
34
|
+
# Use #add_comment to add comments.
|
|
35
|
+
#
|
|
36
|
+
# Before marshalling:
|
|
37
|
+
# - +comment+ is a String
|
|
38
|
+
# - +location+ is an RDoc::TopLevel
|
|
39
|
+
#
|
|
40
|
+
# After unmarshalling:
|
|
41
|
+
# - +comment+ is an RDoc::Markup::Document
|
|
42
|
+
# - +location+ is a filename String
|
|
43
|
+
#
|
|
44
|
+
# These type changes are acceptable (for now) because:
|
|
45
|
+
# - +comment+: Both String and Document respond to #empty?, and #parse
|
|
46
|
+
# returns Document as-is (see RDoc::Text#parse)
|
|
47
|
+
# - +location+: Only used by #parse to set Document#file, which accepts
|
|
48
|
+
# both TopLevel (extracts relative_name) and String
|
|
34
49
|
|
|
35
50
|
attr_accessor :comment_location
|
|
36
51
|
|
|
@@ -110,7 +125,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
110
125
|
@is_alias_for = nil
|
|
111
126
|
@name = name
|
|
112
127
|
@superclass = superclass
|
|
113
|
-
@comment_location = [] # [
|
|
128
|
+
@comment_location = [] # Array of [comment, location] pairs
|
|
114
129
|
|
|
115
130
|
super()
|
|
116
131
|
end
|
|
@@ -173,10 +188,26 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
173
188
|
end
|
|
174
189
|
|
|
175
190
|
##
|
|
176
|
-
# HTML fragment reference for this module or class
|
|
177
|
-
#
|
|
191
|
+
# HTML fragment reference for this module or class using GitHub-style
|
|
192
|
+
# anchor format (lowercase, :: replaced with -).
|
|
193
|
+
#
|
|
194
|
+
# Examples:
|
|
195
|
+
# Foo -> class-foo
|
|
196
|
+
# Foo::Bar -> class-foo-bar
|
|
178
197
|
|
|
179
198
|
def aref
|
|
199
|
+
"#{aref_prefix}-#{full_name.downcase.gsub('::', '-')}"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
##
|
|
203
|
+
# Legacy HTML fragment reference for backward compatibility.
|
|
204
|
+
# Returns the old RDoc-style anchor format.
|
|
205
|
+
#
|
|
206
|
+
# Examples:
|
|
207
|
+
# Foo -> class-Foo
|
|
208
|
+
# Foo::Bar -> class-Foo::Bar
|
|
209
|
+
|
|
210
|
+
def legacy_aref
|
|
180
211
|
"#{aref_prefix}-#{full_name}"
|
|
181
212
|
end
|
|
182
213
|
|
|
@@ -379,10 +410,10 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
379
410
|
|
|
380
411
|
@comment = RDoc::Comment.from_document document
|
|
381
412
|
|
|
382
|
-
@comment_location = if RDoc::Markup::Document
|
|
383
|
-
document
|
|
413
|
+
@comment_location = if document.parts.first.is_a?(RDoc::Markup::Document)
|
|
414
|
+
document.parts.map { |doc| [doc, doc.file] }
|
|
384
415
|
else
|
|
385
|
-
|
|
416
|
+
[[document, document.file]]
|
|
386
417
|
end
|
|
387
418
|
|
|
388
419
|
array[5].each do |name, rw, visibility, singleton, file|
|
|
@@ -462,7 +493,12 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
462
493
|
document = document.merge other_document
|
|
463
494
|
|
|
464
495
|
@comment = RDoc::Comment.from_document(document)
|
|
465
|
-
|
|
496
|
+
|
|
497
|
+
@comment_location = if document.parts.first.is_a?(RDoc::Markup::Document)
|
|
498
|
+
document.parts.map { |doc| [doc, doc.file] }
|
|
499
|
+
else
|
|
500
|
+
[[document, document.file]]
|
|
501
|
+
end
|
|
466
502
|
end
|
|
467
503
|
|
|
468
504
|
cm = class_module
|
|
@@ -689,6 +725,9 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
689
725
|
|
|
690
726
|
##
|
|
691
727
|
# Search record used by RDoc::Generator::JsonIndex
|
|
728
|
+
#
|
|
729
|
+
# TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
|
|
730
|
+
# Use #search_snippet instead for getting documentation snippets.
|
|
692
731
|
|
|
693
732
|
def search_record
|
|
694
733
|
[
|
|
@@ -702,6 +741,16 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
702
741
|
]
|
|
703
742
|
end
|
|
704
743
|
|
|
744
|
+
##
|
|
745
|
+
# Returns an HTML snippet of the first comment for search results.
|
|
746
|
+
|
|
747
|
+
def search_snippet
|
|
748
|
+
first_comment = @comment_location.first&.first
|
|
749
|
+
return '' unless first_comment && !first_comment.empty?
|
|
750
|
+
|
|
751
|
+
snippet(first_comment)
|
|
752
|
+
end
|
|
753
|
+
|
|
705
754
|
##
|
|
706
755
|
# Sets the store for this class or module and its contained code objects.
|
|
707
756
|
|
|
@@ -794,11 +843,13 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
794
843
|
cm_alias = cm.dup
|
|
795
844
|
cm_alias.name = const.name
|
|
796
845
|
|
|
797
|
-
|
|
798
|
-
|
|
846
|
+
if full_name == 'Object'
|
|
847
|
+
# Don't move top-level aliases under Object, they look ugly there
|
|
848
|
+
cm_alias.parent = top_level
|
|
849
|
+
else
|
|
799
850
|
cm_alias.parent = self
|
|
800
|
-
cm_alias.full_name = nil # force update for new parent
|
|
801
851
|
end
|
|
852
|
+
cm_alias.full_name = nil # force update for new parent
|
|
802
853
|
|
|
803
854
|
cm_alias.aliases.clear
|
|
804
855
|
cm_alias.is_alias_for = cm
|
|
@@ -154,6 +154,15 @@ class RDoc::Constant < RDoc::CodeObject
|
|
|
154
154
|
"#{@parent.path}##{@name}"
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
+
##
|
|
158
|
+
# Returns an HTML snippet of the comment for search results.
|
|
159
|
+
|
|
160
|
+
def search_snippet
|
|
161
|
+
return '' if comment.empty?
|
|
162
|
+
|
|
163
|
+
snippet(comment)
|
|
164
|
+
end
|
|
165
|
+
|
|
157
166
|
def pretty_print(q) # :nodoc:
|
|
158
167
|
q.group 2, "[#{self.class.name} #{full_name}", "]" do
|
|
159
168
|
unless comment.empty? then
|
|
@@ -70,11 +70,30 @@ class RDoc::Context::Section
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
##
|
|
73
|
-
# Anchor reference for linking to this section
|
|
73
|
+
# Anchor reference for linking to this section using GitHub-style format.
|
|
74
|
+
#
|
|
75
|
+
# Examples:
|
|
76
|
+
# "Section" -> "section"
|
|
77
|
+
# "One Two" -> "one-two"
|
|
78
|
+
# "[untitled]" -> "untitled"
|
|
74
79
|
|
|
75
80
|
def aref
|
|
76
81
|
title = @title || '[untitled]'
|
|
77
82
|
|
|
83
|
+
RDoc::Text.to_anchor(title)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# Legacy anchor reference for backward compatibility.
|
|
88
|
+
#
|
|
89
|
+
# Examples:
|
|
90
|
+
# "Section" -> "section"
|
|
91
|
+
# "One Two" -> "one+two"
|
|
92
|
+
# "[untitled]" -> "5Buntitled-5D"
|
|
93
|
+
|
|
94
|
+
def legacy_aref
|
|
95
|
+
title = @title || '[untitled]'
|
|
96
|
+
|
|
78
97
|
CGI.escape(title).gsub('%', '-').sub(/^-/, '')
|
|
79
98
|
end
|
|
80
99
|
|
|
@@ -375,6 +375,9 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
375
375
|
##
|
|
376
376
|
# Used by RDoc::Generator::JsonIndex to create a record for the search
|
|
377
377
|
# engine.
|
|
378
|
+
#
|
|
379
|
+
# TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
|
|
380
|
+
# Use #search_snippet instead for getting documentation snippets.
|
|
378
381
|
|
|
379
382
|
def search_record
|
|
380
383
|
[
|
|
@@ -384,10 +387,19 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
|
384
387
|
@parent.full_name,
|
|
385
388
|
path,
|
|
386
389
|
params,
|
|
387
|
-
|
|
390
|
+
search_snippet,
|
|
388
391
|
]
|
|
389
392
|
end
|
|
390
393
|
|
|
394
|
+
##
|
|
395
|
+
# Returns an HTML snippet of the comment for search results.
|
|
396
|
+
|
|
397
|
+
def search_snippet
|
|
398
|
+
return '' if @comment.empty?
|
|
399
|
+
|
|
400
|
+
snippet(@comment)
|
|
401
|
+
end
|
|
402
|
+
|
|
391
403
|
def to_s # :nodoc:
|
|
392
404
|
if @is_alias_for
|
|
393
405
|
"#{self.class.name}: #{full_name} -> #{is_alias_for}"
|
|
@@ -237,6 +237,9 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
237
237
|
|
|
238
238
|
##
|
|
239
239
|
# Search record used by RDoc::Generator::JsonIndex
|
|
240
|
+
#
|
|
241
|
+
# TODO: Remove this method after dropping the darkfish theme and JsonIndex generator.
|
|
242
|
+
# Use #search_snippet instead for getting documentation snippets.
|
|
240
243
|
|
|
241
244
|
def search_record
|
|
242
245
|
return unless @parser < RDoc::Parser::Text
|
|
@@ -248,10 +251,19 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
248
251
|
'',
|
|
249
252
|
path,
|
|
250
253
|
'',
|
|
251
|
-
|
|
254
|
+
search_snippet,
|
|
252
255
|
]
|
|
253
256
|
end
|
|
254
257
|
|
|
258
|
+
##
|
|
259
|
+
# Returns an HTML snippet of the comment for search results.
|
|
260
|
+
|
|
261
|
+
def search_snippet
|
|
262
|
+
return '' if @comment.empty?
|
|
263
|
+
|
|
264
|
+
snippet(@comment)
|
|
265
|
+
end
|
|
266
|
+
|
|
255
267
|
##
|
|
256
268
|
# Is this TopLevel from a text file instead of a source code file?
|
|
257
269
|
|
data/lib/rdoc/cross_reference.rb
CHANGED
|
@@ -132,47 +132,56 @@ class RDoc::CrossReference
|
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
##
|
|
135
|
-
# Returns a method reference to +name
|
|
135
|
+
# Returns a method, attribute or constant reference to +name+
|
|
136
|
+
# if it exists in the containing context object. It returns
|
|
137
|
+
# nil otherwise.
|
|
138
|
+
#
|
|
139
|
+
# For example, this method would decompose name = 'A::CONSTANT' into a
|
|
140
|
+
# container object A and a symbol 'CONSTANT', and it would try to find
|
|
141
|
+
# 'CONSTANT' in A.
|
|
136
142
|
|
|
137
|
-
def
|
|
143
|
+
def resolve_local_symbol(name)
|
|
138
144
|
ref = nil
|
|
145
|
+
type = nil
|
|
146
|
+
container = nil
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
case name
|
|
149
|
+
when /#{CLASS_REGEXP_STR}::([A-Z]\w*)\z/o then
|
|
150
|
+
symbol = $2
|
|
151
|
+
container = @context.find_symbol_module($1)
|
|
152
|
+
when /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o then
|
|
141
153
|
type = $2
|
|
142
154
|
if '.' == type # will find either #method or ::method
|
|
143
|
-
|
|
155
|
+
symbol = $3
|
|
144
156
|
else
|
|
145
|
-
|
|
157
|
+
symbol = "#{type}#{$3}"
|
|
146
158
|
end
|
|
147
159
|
container = @context.find_symbol_module($1)
|
|
148
|
-
|
|
160
|
+
when /^([.#]|::)#{METHOD_REGEXP_STR}/o then
|
|
149
161
|
type = $1
|
|
150
162
|
if '.' == type
|
|
151
|
-
|
|
163
|
+
symbol = $2
|
|
152
164
|
else
|
|
153
|
-
|
|
165
|
+
symbol = "#{type}#{$2}"
|
|
154
166
|
end
|
|
155
167
|
container = @context
|
|
156
|
-
else
|
|
157
|
-
type = nil
|
|
158
|
-
container = nil
|
|
159
168
|
end
|
|
160
169
|
|
|
161
170
|
if container then
|
|
162
171
|
unless RDoc::TopLevel === container then
|
|
163
172
|
if '.' == type then
|
|
164
|
-
if 'new' ==
|
|
165
|
-
ref = container.find_local_symbol
|
|
166
|
-
ref = container.find_ancestor_local_symbol
|
|
173
|
+
if 'new' == symbol then # AnyClassName.new will be class method
|
|
174
|
+
ref = container.find_local_symbol symbol
|
|
175
|
+
ref = container.find_ancestor_local_symbol symbol unless ref
|
|
167
176
|
else
|
|
168
|
-
ref = container.find_local_symbol "::#{
|
|
169
|
-
ref = container.find_ancestor_local_symbol "::#{
|
|
170
|
-
ref = container.find_local_symbol "##{
|
|
171
|
-
ref = container.find_ancestor_local_symbol "##{
|
|
177
|
+
ref = container.find_local_symbol "::#{symbol}"
|
|
178
|
+
ref = container.find_ancestor_local_symbol "::#{symbol}" unless ref
|
|
179
|
+
ref = container.find_local_symbol "##{symbol}" unless ref
|
|
180
|
+
ref = container.find_ancestor_local_symbol "##{symbol}" unless ref
|
|
172
181
|
end
|
|
173
182
|
else
|
|
174
|
-
ref = container.find_local_symbol
|
|
175
|
-
ref = container.find_ancestor_local_symbol
|
|
183
|
+
ref = container.find_local_symbol symbol
|
|
184
|
+
ref = container.find_ancestor_local_symbol symbol unless ref
|
|
176
185
|
end
|
|
177
186
|
end
|
|
178
187
|
end
|
|
@@ -197,7 +206,7 @@ class RDoc::CrossReference
|
|
|
197
206
|
@context.find_symbol name
|
|
198
207
|
end
|
|
199
208
|
|
|
200
|
-
ref =
|
|
209
|
+
ref = resolve_local_symbol name unless ref
|
|
201
210
|
|
|
202
211
|
# Try a page name
|
|
203
212
|
ref = @store.page name if not ref and name =~ /^[\w.\/]+$/
|
data/lib/rdoc/generator/aliki.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
3
5
|
##
|
|
4
6
|
# Aliki theme for RDoc documentation
|
|
5
7
|
#
|
|
@@ -15,6 +17,30 @@ class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
|
|
|
15
17
|
@template_dir = Pathname.new(aliki_template_dir)
|
|
16
18
|
end
|
|
17
19
|
|
|
20
|
+
##
|
|
21
|
+
# Generate documentation. Overrides Darkfish to use Aliki's own search index
|
|
22
|
+
# instead of the JsonIndex generator.
|
|
23
|
+
|
|
24
|
+
def generate
|
|
25
|
+
setup
|
|
26
|
+
|
|
27
|
+
write_style_sheet
|
|
28
|
+
generate_index
|
|
29
|
+
generate_class_files
|
|
30
|
+
generate_file_files
|
|
31
|
+
generate_table_of_contents
|
|
32
|
+
write_search_index
|
|
33
|
+
|
|
34
|
+
copy_static
|
|
35
|
+
|
|
36
|
+
rescue => e
|
|
37
|
+
debug_msg "%s: %s\n %s" % [
|
|
38
|
+
e.class.name, e.message, e.backtrace.join("\n ")
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
raise
|
|
42
|
+
end
|
|
43
|
+
|
|
18
44
|
##
|
|
19
45
|
# Copy only the static assets required by the Aliki theme. Unlike Darkfish we
|
|
20
46
|
# don't ship embedded fonts or image sprites, so limit the asset list to keep
|
|
@@ -39,4 +65,119 @@ class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
|
|
|
39
65
|
install_rdoc_static_file @template_dir + path, dst, options
|
|
40
66
|
end
|
|
41
67
|
end
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
# Build a search index array for Aliki's searcher.
|
|
71
|
+
|
|
72
|
+
def build_search_index
|
|
73
|
+
setup
|
|
74
|
+
|
|
75
|
+
index = []
|
|
76
|
+
|
|
77
|
+
@classes.each do |klass|
|
|
78
|
+
next unless klass.display?
|
|
79
|
+
|
|
80
|
+
index << build_class_module_entry(klass)
|
|
81
|
+
|
|
82
|
+
klass.constants.each do |const|
|
|
83
|
+
next unless const.display?
|
|
84
|
+
|
|
85
|
+
index << build_constant_entry(const, klass)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
@methods.each do |method|
|
|
90
|
+
next unless method.display?
|
|
91
|
+
|
|
92
|
+
index << build_method_entry(method)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
index
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Write the search index as a JavaScript file
|
|
100
|
+
# Format: var search_data = { index: [...] }
|
|
101
|
+
#
|
|
102
|
+
# We still write to a .js instead of a .json because loading a JSON file triggers CORS check in browsers.
|
|
103
|
+
# And if we simply inspect the generated pages using file://, which is often the case due to lack of the server mode,
|
|
104
|
+
# the JSON file will be blocked by the browser.
|
|
105
|
+
|
|
106
|
+
def write_search_index
|
|
107
|
+
debug_msg "Writing Aliki search index"
|
|
108
|
+
|
|
109
|
+
index = build_search_index
|
|
110
|
+
|
|
111
|
+
FileUtils.mkdir_p 'js' unless @dry_run
|
|
112
|
+
|
|
113
|
+
search_index_path = 'js/search_data.js'
|
|
114
|
+
return if @dry_run
|
|
115
|
+
|
|
116
|
+
data = { index: index }
|
|
117
|
+
File.write search_index_path, "var search_data = #{JSON.generate(data)};"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
##
|
|
121
|
+
# Resolves a URL for use in templates. Absolute URLs are returned unchanged.
|
|
122
|
+
# Relative URLs are prefixed with rel_prefix to ensure they resolve correctly from any page.
|
|
123
|
+
|
|
124
|
+
def resolve_url(rel_prefix, url)
|
|
125
|
+
uri = URI.parse(url)
|
|
126
|
+
if uri.absolute?
|
|
127
|
+
url
|
|
128
|
+
else
|
|
129
|
+
"#{rel_prefix}/#{url}"
|
|
130
|
+
end
|
|
131
|
+
rescue URI::InvalidURIError
|
|
132
|
+
"#{rel_prefix}/#{url}"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
private
|
|
136
|
+
|
|
137
|
+
def build_class_module_entry(klass)
|
|
138
|
+
type = case klass
|
|
139
|
+
when RDoc::NormalClass then 'class'
|
|
140
|
+
when RDoc::NormalModule then 'module'
|
|
141
|
+
else 'class'
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
entry = {
|
|
145
|
+
name: klass.name,
|
|
146
|
+
full_name: klass.full_name,
|
|
147
|
+
type: type,
|
|
148
|
+
path: klass.path
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
snippet = klass.search_snippet
|
|
152
|
+
entry[:snippet] = snippet unless snippet.empty?
|
|
153
|
+
entry
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def build_method_entry(method)
|
|
157
|
+
type = method.singleton ? 'class_method' : 'instance_method'
|
|
158
|
+
|
|
159
|
+
entry = {
|
|
160
|
+
name: method.name,
|
|
161
|
+
full_name: method.full_name,
|
|
162
|
+
type: type,
|
|
163
|
+
path: method.path
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
snippet = method.search_snippet
|
|
167
|
+
entry[:snippet] = snippet unless snippet.empty?
|
|
168
|
+
entry
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def build_constant_entry(const, parent)
|
|
172
|
+
entry = {
|
|
173
|
+
name: const.name,
|
|
174
|
+
full_name: "#{parent.full_name}::#{const.name}",
|
|
175
|
+
type: 'constant',
|
|
176
|
+
path: parent.path
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
snippet = const.search_snippet
|
|
180
|
+
entry[:snippet] = snippet unless snippet.empty?
|
|
181
|
+
entry
|
|
182
|
+
end
|
|
42
183
|
end
|
|
@@ -314,6 +314,8 @@ class RDoc::Generator::Darkfish
|
|
|
314
314
|
# Generates a class file for +klass+
|
|
315
315
|
|
|
316
316
|
def generate_class(klass, template_file = nil)
|
|
317
|
+
# This is used to auto-collapse Pages section on class/module pages
|
|
318
|
+
@inside_class_file = true
|
|
317
319
|
current = klass
|
|
318
320
|
|
|
319
321
|
template_file ||= @template_dir + 'class.rhtml'
|
|
@@ -338,6 +340,8 @@ class RDoc::Generator::Darkfish
|
|
|
338
340
|
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
339
341
|
here
|
|
340
342
|
end
|
|
343
|
+
ensure
|
|
344
|
+
@inside_class_file = false
|
|
341
345
|
end
|
|
342
346
|
|
|
343
347
|
##
|
|
@@ -352,7 +356,9 @@ class RDoc::Generator::Darkfish
|
|
|
352
356
|
|
|
353
357
|
current = nil
|
|
354
358
|
|
|
355
|
-
|
|
359
|
+
# Document files are generated only for non-alias classes/modules
|
|
360
|
+
@classes.reject(&:is_alias_for).each do |klass|
|
|
361
|
+
|
|
356
362
|
current = klass
|
|
357
363
|
|
|
358
364
|
generate_class klass, template_file
|
|
@@ -764,7 +770,7 @@ class RDoc::Generator::Darkfish
|
|
|
764
770
|
end
|
|
765
771
|
|
|
766
772
|
def traverse_classes(klasses, grouped_classes, rel_prefix, solo = false)
|
|
767
|
-
content = +'<ul class="link-list">'
|
|
773
|
+
content = +'<ul class="link-list nav-list">'
|
|
768
774
|
|
|
769
775
|
klasses.each do |index_klass|
|
|
770
776
|
if children = grouped_classes[index_klass.full_name]
|
|
@@ -116,22 +116,22 @@
|
|
|
116
116
|
></script>
|
|
117
117
|
|
|
118
118
|
<script
|
|
119
|
-
src="<%= h asset_rel_prefix %>/js/
|
|
119
|
+
src="<%= h asset_rel_prefix %>/js/search_navigation.js?v=<%= h RDoc::VERSION %>"
|
|
120
120
|
defer
|
|
121
121
|
></script>
|
|
122
122
|
|
|
123
123
|
<script
|
|
124
|
-
src="<%= h asset_rel_prefix %>/js/
|
|
124
|
+
src="<%= h asset_rel_prefix %>/js/search_data.js?v=<%= h RDoc::VERSION %>"
|
|
125
125
|
defer
|
|
126
126
|
></script>
|
|
127
127
|
|
|
128
128
|
<script
|
|
129
|
-
src="<%= h asset_rel_prefix %>/js/
|
|
129
|
+
src="<%= h asset_rel_prefix %>/js/search_ranker.js?v=<%= h RDoc::VERSION %>"
|
|
130
130
|
defer
|
|
131
131
|
></script>
|
|
132
132
|
|
|
133
133
|
<script
|
|
134
|
-
src="<%= h asset_rel_prefix %>/js/
|
|
134
|
+
src="<%= h asset_rel_prefix %>/js/search_controller.js?v=<%= h RDoc::VERSION %>"
|
|
135
135
|
defer
|
|
136
136
|
></script>
|
|
137
137
|
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
<div class="navbar-search navbar-search-desktop" role="search">
|
|
8
8
|
<form action="#" method="get" accept-charset="utf-8">
|
|
9
9
|
<input id="search-field" role="combobox" aria-label="Search"
|
|
10
|
-
aria-autocomplete="list" aria-controls="search-results"
|
|
10
|
+
aria-autocomplete="list" aria-controls="search-results-desktop"
|
|
11
11
|
type="text" name="search" placeholder="Search (/) for a class, method..."
|
|
12
12
|
spellcheck="false" autocomplete="off"
|
|
13
13
|
title="Type to search, Up and Down to navigate, Enter to load">
|
|
14
|
-
<ul id="search-results" aria-label="Search Results"
|
|
14
|
+
<ul id="search-results-desktop" aria-label="Search Results"
|
|
15
15
|
aria-busy="false" aria-expanded="false"
|
|
16
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
|
16
|
+
aria-atomic="false" class="initially-hidden search-results"></ul>
|
|
17
17
|
</form>
|
|
18
18
|
</div>
|
|
19
19
|
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<div class="search-modal-body">
|
|
48
48
|
<ul id="search-results-mobile" aria-label="Search Results"
|
|
49
49
|
aria-busy="false" aria-expanded="false"
|
|
50
|
-
aria-atomic="false" class="search-modal-results initially-hidden"></ul>
|
|
50
|
+
aria-atomic="false" class="search-results search-modal-results initially-hidden"></ul>
|
|
51
51
|
<div class="search-modal-empty">
|
|
52
52
|
<p>No recent searches</p>
|
|
53
53
|
</div>
|