rdoc 6.15.0 → 7.0.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +187 -0
  3. data/History.rdoc +1 -1
  4. data/LEGAL.rdoc +6 -0
  5. data/README.md +20 -3
  6. data/lib/rdoc/code_object/any_method.rb +15 -7
  7. data/lib/rdoc/code_object/class_module.rb +18 -3
  8. data/lib/rdoc/code_object/constant.rb +9 -0
  9. data/lib/rdoc/code_object/method_attr.rb +13 -1
  10. data/lib/rdoc/code_object/top_level.rb +31 -18
  11. data/lib/rdoc/comment.rb +190 -8
  12. data/lib/rdoc/generator/aliki.rb +183 -0
  13. data/lib/rdoc/generator/darkfish.rb +8 -2
  14. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  15. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  16. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  17. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  18. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  19. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  20. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  21. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
  22. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
  23. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  24. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  25. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  26. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  27. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  28. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  29. data/lib/rdoc/generator/template/aliki/class.rhtml +218 -0
  30. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1943 -0
  31. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  32. data/lib/rdoc/generator/template/aliki/js/aliki.js +505 -0
  33. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  34. data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  35. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  36. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  37. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  38. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  39. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  40. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  41. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  42. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -19
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
  52. data/lib/rdoc/generator/template/darkfish/class.rhtml +68 -68
  53. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
  54. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
  55. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
  56. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
  57. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
  58. data/lib/rdoc/generator/template/json_index/js/searcher.js +43 -6
  59. data/lib/rdoc/generator.rb +1 -0
  60. data/lib/rdoc/markup/pre_process.rb +34 -10
  61. data/lib/rdoc/markup/to_ansi.rb +4 -0
  62. data/lib/rdoc/markup/to_bs.rb +4 -0
  63. data/lib/rdoc/markup/to_html.rb +6 -4
  64. data/lib/rdoc/markup/to_rdoc.rb +11 -3
  65. data/lib/rdoc/options.rb +21 -10
  66. data/lib/rdoc/parser/c.rb +15 -46
  67. data/lib/rdoc/parser/prism_ruby.rb +121 -113
  68. data/lib/rdoc/parser/ruby.rb +8 -8
  69. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  70. data/lib/rdoc/parser/simple.rb +4 -21
  71. data/lib/rdoc/rdoc.rb +1 -0
  72. data/lib/rdoc/rubygems_hook.rb +3 -3
  73. data/lib/rdoc/text.rb +1 -1
  74. data/lib/rdoc/token_stream.rb +13 -1
  75. data/lib/rdoc/tom_doc.rb +1 -1
  76. data/lib/rdoc/version.rb +1 -1
  77. data/rdoc.gemspec +1 -1
  78. metadata +33 -5
  79. data/CONTRIBUTING.rdoc +0 -219
data/lib/rdoc/comment.rb CHANGED
@@ -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
 
@@ -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
- def self.from_document(document) # :nodoc:
230
- comment = RDoc::Comment.new('')
231
- comment.document = document
232
- comment.location = RDoc::TopLevel.new(document.file) if document.file
233
- comment
234
- end
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
@@ -0,0 +1,183 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ ##
6
+ # Aliki theme for RDoc documentation
7
+ #
8
+ # Author: Stan Lo
9
+ #
10
+
11
+ class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
12
+ RDoc::RDoc.add_generator self
13
+
14
+ def initialize(store, options)
15
+ super
16
+ aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki'))
17
+ @template_dir = Pathname.new(aliki_template_dir)
18
+ end
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
+
44
+ ##
45
+ # Copy only the static assets required by the Aliki theme. Unlike Darkfish we
46
+ # don't ship embedded fonts or image sprites, so limit the asset list to keep
47
+ # generated documentation lightweight.
48
+
49
+ def write_style_sheet
50
+ debug_msg "Copying Aliki static files"
51
+ options = { verbose: $DEBUG_RDOC, noop: @dry_run }
52
+
53
+ install_rdoc_static_file @template_dir + 'css/rdoc.css', "./css/rdoc.css", options
54
+
55
+ unless @options.template_stylesheets.empty?
56
+ FileUtils.cp @options.template_stylesheets, '.', **options
57
+ end
58
+
59
+ Dir[(@template_dir + 'js/**/*').to_s].each do |path|
60
+ next if File.directory?(path)
61
+ next if File.basename(path).start_with?('.')
62
+
63
+ dst = Pathname.new(path).relative_path_from(@template_dir)
64
+
65
+ install_rdoc_static_file @template_dir + path, dst, options
66
+ end
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
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
- @classes.each do |klass|
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]
@@ -0,0 +1,8 @@
1
+ <aside class="table-of-contents" role="complementary" aria-label="Table of Contents">
2
+ <div class="toc-sticky">
3
+ <h3 class="toc-heading">On This Page</h3>
4
+ <nav class="toc-nav" id="toc-nav" aria-label="Page sections">
5
+ <!-- Generated by JavaScript based on page headings -->
6
+ </nav>
7
+ </div>
8
+ </aside>
@@ -0,0 +1,23 @@
1
+ <footer class="site-footer">
2
+ <% if @options.footer_content && !@options.footer_content.empty? %>
3
+ <div class="footer-content">
4
+ <% @options.footer_content.each do |column_title, links| %>
5
+ <div>
6
+ <h3><%= h column_title %></h3>
7
+ <ul>
8
+ <% links.each do |text, url| %>
9
+ <li><a href="<%= h resolve_url(rel_prefix, url) %>"><%= h text %></a></li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% end %>
14
+ </div>
15
+ <% end %>
16
+
17
+ <div class="footer-bottom">
18
+ <p>
19
+ Generated by <a href="https://ruby.github.io/rdoc/">RDoc <%= RDoc::VERSION %></a>
20
+ using the Aliki theme by <a href="http://st0012.dev">Stan Lo</a>
21
+ </p>
22
+ </div>
23
+ </footer>
@@ -0,0 +1,158 @@
1
+ <meta charset="<%= @options.charset %>">
2
+ <meta name="viewport" content="width=device-width, initial-scale=1">
3
+
4
+ <title><%= h @title %></title>
5
+
6
+ <%- if defined?(klass) %>
7
+ <meta
8
+ name="keywords"
9
+ content="ruby,<%= h "#{klass.type},#{klass.full_name}" %>"
10
+ >
11
+ <%- if klass.comment.empty? %>
12
+ <meta
13
+ name="description"
14
+ content="Documentation for the <%= h "#{klass.full_name} #{klass.type}" %>"
15
+ >
16
+ <%- else %>
17
+ <meta
18
+ name="description"
19
+ content="<%= h "#{klass.type} #{klass.full_name}: #{excerpt(klass.comment)}" %>"
20
+ >
21
+ <%- end %>
22
+ <%- elsif defined?(file) %>
23
+ <meta name="keywords" content="ruby,documentation,<%= h file.page_name %>">
24
+ <meta
25
+ name="description"
26
+ content="<%= h "#{file.page_name}: #{excerpt(file.comment)}" %>"
27
+ >
28
+ <%- elsif @title %>
29
+ <meta name="keywords" content="ruby,documentation,<%= h @title %>">
30
+ <%- if @options.main_page and
31
+ main_page = @files.find { |f| f.full_name == @options.main_page } then %>
32
+ <meta
33
+ name="description"
34
+ content="<%= h "#{@title}: #{excerpt(main_page.comment)}" %>"
35
+ >
36
+ <%- else %>
37
+ <meta name="description" content="Documentation for <%= h @title %>">
38
+ <%- end %>
39
+ <%- end %>
40
+
41
+ <%- if canonical_url = @options.canonical_root %>
42
+ <% canonical_url = current.canonical_url if defined?(current) %>
43
+ <link rel="canonical" href="<%= canonical_url %>">
44
+ <%- end %>
45
+
46
+ <!-- Open Graph / Facebook -->
47
+ <meta property="og:type" content="website">
48
+ <meta property="og:title" content="<%= h @title %>">
49
+
50
+ <%- if defined?(klass) %>
51
+ <%- if klass.comment.empty? %>
52
+ <meta
53
+ property="og:description"
54
+ content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples"
55
+ >
56
+ <%- else %>
57
+ <meta property="og:description" content="<%= h excerpt(klass.comment) %>">
58
+ <%- end %>
59
+ <%- elsif defined?(file) %>
60
+ <%- if file.comment.empty? %>
61
+ <meta
62
+ property="og:description"
63
+ content="<%= h file.page_name %> - <%= h @title %> documentation"
64
+ >
65
+ <%- else %>
66
+ <meta property="og:description" content="<%= h excerpt(file.comment) %>">
67
+ <%- end %>
68
+ <%- else %>
69
+ <meta
70
+ property="og:description"
71
+ content="API documentation for <%= h @title %> - Browse classes, modules, and methods"
72
+ >
73
+ <%- end %>
74
+
75
+ <%- if canonical_url = @options.canonical_root %>
76
+ <% canonical_url = current.canonical_url if defined?(current) %>
77
+ <meta property="og:url" content="<%= canonical_url %>">
78
+ <%- end %>
79
+
80
+ <!-- Twitter -->
81
+ <meta name="twitter:card" content="summary">
82
+ <meta name="twitter:title" content="<%= h @title %>">
83
+
84
+ <%- if defined?(klass) %>
85
+ <%- if klass.comment.empty? %>
86
+ <meta
87
+ name="twitter:description"
88
+ content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples"
89
+ >
90
+ <%- else %>
91
+ <meta name="twitter:description" content="<%= h excerpt(klass.comment) %>">
92
+ <%- end %>
93
+ <%- elsif defined?(file) %>
94
+ <%- if file.comment.empty? %>
95
+ <meta
96
+ name="twitter:description"
97
+ content="<%= h file.page_name %> - <%= h @title %> documentation"
98
+ >
99
+ <%- else %>
100
+ <meta name="twitter:description" content="<%= h excerpt(file.comment) %>">
101
+ <%- end %>
102
+ <%- else %>
103
+ <meta
104
+ name="twitter:description"
105
+ content="API documentation for <%= h @title %> - Browse classes, modules, and methods"
106
+ >
107
+ <%- end %>
108
+
109
+ <script type="text/javascript">
110
+ var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
111
+ var index_rel_prefix = "<%= h rel_prefix %>/";
112
+ </script>
113
+
114
+ <script
115
+ src="<%= h asset_rel_prefix %>/js/theme-toggle.js?v=<%= h RDoc::VERSION %>"
116
+ ></script>
117
+
118
+ <script
119
+ src="<%= h asset_rel_prefix %>/js/search_navigation.js?v=<%= h RDoc::VERSION %>"
120
+ defer
121
+ ></script>
122
+
123
+ <script
124
+ src="<%= h asset_rel_prefix %>/js/search_data.js?v=<%= h RDoc::VERSION %>"
125
+ defer
126
+ ></script>
127
+
128
+ <script
129
+ src="<%= h asset_rel_prefix %>/js/search_ranker.js?v=<%= h RDoc::VERSION %>"
130
+ defer
131
+ ></script>
132
+
133
+ <script
134
+ src="<%= h asset_rel_prefix %>/js/search_controller.js?v=<%= h RDoc::VERSION %>"
135
+ defer
136
+ ></script>
137
+
138
+ <script
139
+ src="<%= h asset_rel_prefix %>/js/c_highlighter.js?v=<%= h RDoc::VERSION %>"
140
+ defer
141
+ ></script>
142
+
143
+ <script
144
+ src="<%= h asset_rel_prefix %>/js/aliki.js?v=<%= h RDoc::VERSION %>"
145
+ defer
146
+ ></script>
147
+
148
+ <link
149
+ href="<%= h asset_rel_prefix %>/css/rdoc.css?v=<%= h RDoc::VERSION %>"
150
+ rel="stylesheet"
151
+ >
152
+
153
+ <%- @options.template_stylesheets.each do |stylesheet| %>
154
+ <link
155
+ href="<%= h asset_rel_prefix %>/<%= h File.basename stylesheet %>?v=<%= h RDoc::VERSION %>"
156
+ rel="stylesheet"
157
+ >
158
+ <%- end %>
@@ -0,0 +1,56 @@
1
+ <header class="top-navbar">
2
+ <a href="<%= rel_prefix %>/index.html" class="navbar-brand">
3
+ <%= h @options.title %>
4
+ </a>
5
+
6
+ <!-- Desktop search bar -->
7
+ <div class="navbar-search navbar-search-desktop" role="search">
8
+ <form action="#" method="get" accept-charset="utf-8">
9
+ <input id="search-field" role="combobox" aria-label="Search"
10
+ aria-autocomplete="list" aria-controls="search-results-desktop"
11
+ type="text" name="search" placeholder="Search (/) for a class, method..."
12
+ spellcheck="false" autocomplete="off"
13
+ title="Type to search, Up and Down to navigate, Enter to load">
14
+ <ul id="search-results-desktop" aria-label="Search Results"
15
+ aria-busy="false" aria-expanded="false"
16
+ aria-atomic="false" class="initially-hidden search-results"></ul>
17
+ </form>
18
+ </div>
19
+
20
+ <!-- Mobile search icon button -->
21
+ <button id="search-toggle" class="navbar-search-mobile" aria-label="Open search" type="button">
22
+ <span aria-hidden="true">🔍</span>
23
+ </button>
24
+
25
+ <!-- Theme toggle button -->
26
+ <button id="theme-toggle" class="theme-toggle" aria-label="Switch to dark mode" type="button">
27
+ <span class="theme-toggle-icon" aria-hidden="true">🌙</span>
28
+ </button>
29
+ </header>
30
+
31
+ <!-- Search Modal (Mobile) -->
32
+ <div id="search-modal" class="search-modal" hidden aria-modal="true" role="dialog" aria-label="Search">
33
+ <div class="search-modal-backdrop"></div>
34
+ <div class="search-modal-content">
35
+ <div class="search-modal-header">
36
+ <form class="search-modal-form" action="#" method="get" accept-charset="utf-8">
37
+ <span class="search-modal-icon" aria-hidden="true">🔍</span>
38
+ <input id="search-field-mobile" role="combobox" aria-label="Search"
39
+ aria-autocomplete="list" aria-controls="search-results-mobile"
40
+ type="text" name="search" placeholder="Search documentation"
41
+ spellcheck="false" autocomplete="off">
42
+ <button type="button" class="search-modal-close" aria-label="Close search" id="search-modal-close">
43
+ <span aria-hidden="true">esc</span>
44
+ </button>
45
+ </form>
46
+ </div>
47
+ <div class="search-modal-body">
48
+ <ul id="search-results-mobile" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="search-results search-modal-results initially-hidden"></ul>
51
+ <div class="search-modal-empty">
52
+ <p>No recent searches</p>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </div>