rdoc 6.14.2 → 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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +196 -0
  3. data/History.rdoc +1 -1
  4. data/LEGAL.rdoc +6 -0
  5. data/README.md +195 -0
  6. data/RI.md +1 -1
  7. data/doc/markup_reference/markdown.md +558 -0
  8. data/doc/markup_reference/rdoc.rdoc +1169 -0
  9. data/lib/rdoc/code_object/any_method.rb +15 -7
  10. data/lib/rdoc/code_object/class_module.rb +62 -11
  11. data/lib/rdoc/code_object/constant.rb +9 -0
  12. data/lib/rdoc/code_object/context/section.rb +20 -1
  13. data/lib/rdoc/code_object/method_attr.rb +13 -1
  14. data/lib/rdoc/code_object/top_level.rb +31 -26
  15. data/lib/rdoc/comment.rb +190 -8
  16. data/lib/rdoc/cross_reference.rb +31 -22
  17. data/lib/rdoc/generator/aliki.rb +183 -0
  18. data/lib/rdoc/generator/darkfish.rb +8 -2
  19. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  20. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  21. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  22. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  23. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  24. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  25. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  26. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
  27. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
  28. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  29. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  30. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  31. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  32. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  33. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  34. data/lib/rdoc/generator/template/aliki/class.rhtml +220 -0
  35. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1963 -0
  36. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  37. data/lib/rdoc/generator/template/aliki/js/aliki.js +505 -0
  38. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  39. data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  40. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  41. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  42. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  43. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  44. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  45. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  46. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  47. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -19
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +18 -18
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
  57. data/lib/rdoc/generator/template/darkfish/class.rhtml +70 -68
  58. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -0
  59. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
  60. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +21 -1
  61. data/lib/rdoc/generator/template/darkfish/js/search.js +11 -1
  62. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
  63. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
  64. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
  65. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
  66. data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
  67. data/lib/rdoc/generator.rb +1 -0
  68. data/lib/rdoc/markdown.kpeg +29 -22
  69. data/lib/rdoc/markdown.rb +366 -549
  70. data/lib/rdoc/markup/attribute_manager.rb +28 -1
  71. data/lib/rdoc/markup/blank_line.rb +25 -23
  72. data/lib/rdoc/markup/element.rb +21 -0
  73. data/lib/rdoc/markup/hard_break.rb +30 -27
  74. data/lib/rdoc/markup/heading.rb +166 -77
  75. data/lib/rdoc/markup/pre_process.rb +34 -10
  76. data/lib/rdoc/markup/raw.rb +52 -55
  77. data/lib/rdoc/markup/table.rb +48 -40
  78. data/lib/rdoc/markup/to_ansi.rb +4 -0
  79. data/lib/rdoc/markup/to_bs.rb +4 -0
  80. data/lib/rdoc/markup/to_html.rb +193 -25
  81. data/lib/rdoc/markup/to_html_crossref.rb +77 -28
  82. data/lib/rdoc/markup/to_label.rb +11 -1
  83. data/lib/rdoc/markup/to_rdoc.rb +11 -3
  84. data/lib/rdoc/markup/verbatim.rb +1 -1
  85. data/lib/rdoc/markup.rb +3 -2
  86. data/lib/rdoc/options.rb +22 -11
  87. data/lib/rdoc/parser/c.rb +15 -46
  88. data/lib/rdoc/parser/changelog.rb +8 -0
  89. data/lib/rdoc/parser/prism_ruby.rb +121 -113
  90. data/lib/rdoc/parser/ruby.rb +8 -8
  91. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  92. data/lib/rdoc/parser/simple.rb +4 -21
  93. data/lib/rdoc/rdoc.rb +1 -0
  94. data/lib/rdoc/ri/task.rb +2 -2
  95. data/lib/rdoc/rubygems_hook.rb +3 -3
  96. data/lib/rdoc/store.rb +2 -2
  97. data/lib/rdoc/task.rb +4 -4
  98. data/lib/rdoc/text.rb +16 -1
  99. data/lib/rdoc/token_stream.rb +17 -9
  100. data/lib/rdoc/tom_doc.rb +1 -1
  101. data/lib/rdoc/version.rb +1 -1
  102. data/rdoc.gemspec +6 -5
  103. metadata +53 -12
  104. data/CONTRIBUTING.rdoc +0 -219
  105. data/ExampleMarkdown.md +0 -39
  106. data/ExampleRDoc.rdoc +0 -210
  107. data/README.rdoc +0 -144
@@ -29,7 +29,7 @@ Searcher.prototype = new function() {
29
29
 
30
30
  var results =
31
31
  performSearch(_this.data, regexps, queries, highlighters, state);
32
- var hasMore = (state.limit > 0 && state.pass < 4);
32
+ var hasMore = (state.limit > 0 && state.pass < 6);
33
33
 
34
34
  triggerResults.call(_this, results, !hasMore);
35
35
  if (hasMore) {
@@ -57,8 +57,17 @@ Searcher.prototype = new function() {
57
57
  }
58
58
 
59
59
  function buildRegexps(queries) {
60
+ // A small minority of older browsers don't have RegExp.escape
61
+ // but it's not worth including a complex polyfill.
62
+ var escape = RegExp.escape || function(s) { return s };
63
+
60
64
  return queries.map(function(query) {
61
- return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
65
+ var pattern = [];
66
+ for (var i = 0; i < query.length; i++) {
67
+ var char = escape(query[i]);
68
+ pattern.push('([' + char + '])([^' + char + ']*?)');
69
+ }
70
+ return new RegExp(pattern.join(''), 'i');
62
71
  });
63
72
  }
64
73
 
@@ -80,6 +89,30 @@ Searcher.prototype = new function() {
80
89
 
81
90
  /* ----- Mathchers ------ */
82
91
 
92
+ /*
93
+ * This record matches if both the index and longIndex exactly equal queries[0]
94
+ * and the record matches all of the regexps. This ensures top-level exact matches
95
+ * like "String" are prioritized over nested classes like "Gem::Module::String".
96
+ */
97
+ function matchPassExact(index, longIndex, queries) {
98
+ return index == queries[0] && longIndex == queries[0];
99
+ }
100
+
101
+ /*
102
+ * This record matches if the index without "()" exactly equals queries[0].
103
+ * This prioritizes methods like "attribute()" when searching for "attribute".
104
+ */
105
+ function matchPassExactMethod(index, longIndex, queries, regexps) {
106
+ var indexWithoutParens = index.replace(/\(\)$/, '');
107
+ if (indexWithoutParens != queries[0]) return false;
108
+ if (index === indexWithoutParens) return false; // Not a method (no parens to remove)
109
+ for (var i=1, l = regexps.length; i < l; i++) {
110
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
111
+ return false;
112
+ };
113
+ return true;
114
+ }
115
+
83
116
  /*
84
117
  * This record matches if the index starts with queries[0] and the record
85
118
  * matches all of the regexps
@@ -187,17 +220,26 @@ Searcher.prototype = new function() {
187
220
  var togo = CHUNK_SIZE;
188
221
  var matchFunc, hltFunc;
189
222
 
190
- while (state.pass < 4 && state.limit > 0 && togo > 0) {
223
+ var isLowercaseQuery = queries[0] === queries[0].toLowerCase();
224
+
225
+ while (state.pass < 6 && state.limit > 0 && togo > 0) {
226
+ // When query is lowercase, prioritize methods over classes
191
227
  if (state.pass == 0) {
192
- matchFunc = matchPassBeginning;
228
+ matchFunc = isLowercaseQuery ? matchPassExactMethod : matchPassExact;
193
229
  hltFunc = highlightQuery;
194
230
  } else if (state.pass == 1) {
195
- matchFunc = matchPassLongIndex;
231
+ matchFunc = isLowercaseQuery ? matchPassExact : matchPassExactMethod;
196
232
  hltFunc = highlightQuery;
197
233
  } else if (state.pass == 2) {
198
- matchFunc = matchPassContains;
234
+ matchFunc = matchPassBeginning;
199
235
  hltFunc = highlightQuery;
200
236
  } else if (state.pass == 3) {
237
+ matchFunc = matchPassLongIndex;
238
+ hltFunc = highlightQuery;
239
+ } else if (state.pass == 4) {
240
+ matchFunc = matchPassContains;
241
+ hltFunc = highlightQuery;
242
+ } else if (state.pass == 5) {
201
243
  matchFunc = matchPassRegexp;
202
244
  hltFunc = highlightRegexp;
203
245
  }
@@ -43,6 +43,7 @@ module RDoc::Generator
43
43
 
44
44
  autoload :Markup, "#{__dir__}/generator/markup"
45
45
 
46
+ autoload :Aliki, "#{__dir__}/generator/aliki"
46
47
  autoload :Darkfish, "#{__dir__}/generator/darkfish"
47
48
  autoload :JsonIndex, "#{__dir__}/generator/json_index"
48
49
  autoload :RI, "#{__dir__}/generator/ri"
@@ -490,11 +490,18 @@
490
490
  # Wraps `text` in strike markup for rdoc inline formatting
491
491
 
492
492
  def strike text
493
- if text =~ /\A[a-z\d.\/-]+\z/i then
494
- "~#{text}~"
495
- else
496
- "<s>#{text}</s>"
497
- end
493
+ "<del>#{text}</del>"
494
+ end
495
+
496
+ ##
497
+ # Wraps `text` in code markup for rdoc inline formatting
498
+
499
+ def code text
500
+ # trim even spaces
501
+ text = $2 while /\A( +|\t+)(.*)\1\z/ =~ text
502
+ # escape unescaped backslash at the end
503
+ backslash_at_end = "\\" if /(?<!\\)(?:\\\\)*\\\z/.match?(text)
504
+ "<code>#{text}#{backslash_at_end}</code>"
498
505
  end
499
506
 
500
507
  ##
@@ -1104,32 +1111,32 @@ Ticks3 = "```" !"`"
1104
1111
  Ticks4 = "````" !"`"
1105
1112
  Ticks5 = "`````" !"`"
1106
1113
 
1107
- Code = ( Ticks1 @Sp < (
1114
+ Code = ( Ticks1 < (
1108
1115
  ( !"`" Nonspacechar )+ | !Ticks1 /`+/ |
1109
- !( @Sp Ticks1 ) ( @Spacechar | @Newline !@BlankLine )
1110
- )+ > @Sp Ticks1 |
1111
- Ticks2 @Sp < (
1116
+ !Ticks1 ( @Spacechar | @Newline !@BlankLine )
1117
+ )+ > Ticks1 |
1118
+ Ticks2 < (
1112
1119
  ( !"`" Nonspacechar )+ |
1113
1120
  !Ticks2 /`+/ |
1114
- !( @Sp Ticks2 ) ( @Spacechar | @Newline !@BlankLine )
1115
- )+ > @Sp Ticks2 |
1116
- Ticks3 @Sp < (
1121
+ !Ticks2 ( @Spacechar | @Newline !@BlankLine )
1122
+ )+ > Ticks2 |
1123
+ Ticks3 < (
1117
1124
  ( !"`" Nonspacechar )+ |
1118
1125
  !Ticks3 /`+/ |
1119
- !( @Sp Ticks3 ) ( @Spacechar | @Newline !@BlankLine )
1120
- )+ > @Sp Ticks3 |
1121
- Ticks4 @Sp < (
1126
+ !Ticks3 ( @Spacechar | @Newline !@BlankLine )
1127
+ )+ > Ticks3 |
1128
+ Ticks4 < (
1122
1129
  ( !"`" Nonspacechar )+ |
1123
1130
  !Ticks4 /`+/ |
1124
- !( @Sp Ticks4 ) ( @Spacechar | @Newline !@BlankLine )
1125
- )+ > @Sp Ticks4 |
1126
- Ticks5 @Sp < (
1131
+ !Ticks4 ( @Spacechar | @Newline !@BlankLine )
1132
+ )+ > Ticks4 |
1133
+ Ticks5 < (
1127
1134
  ( !"`" Nonspacechar )+ |
1128
1135
  !Ticks5 /`+/ |
1129
- !( @Sp Ticks5 ) ( @Spacechar | @Newline !@BlankLine )
1130
- )+ > @Sp Ticks5
1136
+ !Ticks5 ( @Spacechar | @Newline !@BlankLine )
1137
+ )+ > Ticks5
1131
1138
  )
1132
- { "<code>#{text}</code>" }
1139
+ { code text }
1133
1140
 
1134
1141
  RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) >
1135
1142
  { if html? then text else '' end }
@@ -1253,7 +1260,7 @@ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | Tab
1253
1260
  { row }
1254
1261
  TableItem2 = "|" TableItem
1255
1262
  TableItem = < /(?:\\.|[^|\n])+/ >
1256
- { text.strip.gsub(/\\(.)/, '\1') }
1263
+ { text.strip.gsub(/\\([|])/, '\1') }
1257
1264
 
1258
1265
  TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1259
1266
  { line }