super-quick-rb 0.0.1

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 (218) hide show
  1. checksums.yaml +7 -0
  2. data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
  3. data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
  4. data/rdoc-8.0.0/History.rdoc +1668 -0
  5. data/rdoc-8.0.0/LEGAL.rdoc +56 -0
  6. data/rdoc-8.0.0/LICENSE.rdoc +63 -0
  7. data/rdoc-8.0.0/README.md +236 -0
  8. data/rdoc-8.0.0/RI.md +842 -0
  9. data/rdoc-8.0.0/TODO.rdoc +60 -0
  10. data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
  11. data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
  12. data/rdoc-8.0.0/exe/rdoc +43 -0
  13. data/rdoc-8.0.0/exe/ri +12 -0
  14. data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
  15. data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
  16. data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
  17. data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
  18. data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
  19. data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
  20. data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
  21. data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
  22. data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
  23. data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
  24. data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
  25. data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
  26. data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
  27. data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
  28. data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
  29. data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
  30. data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
  31. data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
  32. data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
  33. data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
  34. data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
  35. data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
  36. data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
  37. data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
  38. data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
  39. data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
  40. data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
  41. data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  42. data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
  43. data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
  44. data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
  45. data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
  46. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  47. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  48. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  49. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  50. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  51. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  52. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  53. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  54. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  55. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  56. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  57. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  58. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  59. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  60. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  61. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  62. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  63. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  64. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  65. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  66. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  67. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  68. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  69. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  70. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  71. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  72. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  73. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  74. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  75. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  76. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
  77. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
  78. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
  79. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
  80. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
  81. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
  82. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  83. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
  84. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
  85. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
  86. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  87. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
  88. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  89. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
  90. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  91. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
  92. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  93. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  94. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  95. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  96. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  97. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  98. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  99. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  100. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  101. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  102. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  103. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  104. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  105. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  106. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  107. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  108. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  109. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  110. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  111. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  112. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  113. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  114. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  115. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  116. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  117. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  118. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  119. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  120. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  121. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  122. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  123. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
  124. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
  125. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
  126. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
  127. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
  128. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
  129. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
  130. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  131. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
  132. data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
  133. data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
  134. data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
  135. data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
  136. data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
  137. data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
  138. data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
  139. data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
  140. data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
  141. data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
  142. data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
  143. data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
  144. data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
  145. data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
  146. data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
  147. data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
  148. data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
  149. data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
  150. data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
  151. data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
  152. data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
  153. data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
  154. data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
  155. data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
  156. data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
  157. data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
  158. data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
  159. data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
  160. data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
  161. data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
  162. data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
  163. data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
  164. data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
  165. data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
  166. data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
  167. data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
  168. data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
  169. data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
  170. data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
  171. data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
  172. data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
  173. data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
  174. data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
  175. data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
  176. data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
  177. data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
  178. data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
  179. data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
  180. data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
  181. data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  182. data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
  183. data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
  184. data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
  185. data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
  186. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
  187. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
  188. data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
  189. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
  190. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
  191. data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
  192. data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
  193. data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
  194. data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
  195. data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
  196. data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
  197. data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
  198. data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
  199. data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
  200. data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
  201. data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
  202. data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
  203. data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
  204. data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
  205. data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
  206. data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
  207. data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
  208. data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
  209. data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
  210. data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
  211. data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
  212. data/rdoc-8.0.0/lib/rdoc.rb +239 -0
  213. data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
  214. data/rdoc-8.0.0/man/ri.1 +249 -0
  215. data/rdoc-8.0.0/rdoc-logo.svg +43 -0
  216. data/rdoc-8.0.0/rdoc.gemspec +74 -0
  217. data/super-quick-rb.gemspec +12 -0
  218. metadata +257 -0
@@ -0,0 +1,1238 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A Context is something that can hold modules, classes, methods, attributes,
4
+ # aliases, requires, and includes. Classes, modules, and files are all
5
+ # Contexts.
6
+
7
+ class RDoc::Context < RDoc::CodeObject
8
+
9
+ include Comparable
10
+
11
+ ##
12
+ # Types of methods
13
+
14
+ TYPES = %w[class instance]
15
+
16
+ ##
17
+ # If a context has these titles it will be sorted in this order.
18
+
19
+ TOMDOC_TITLES = [nil, 'Public', 'Internal', 'Deprecated'] # :nodoc:
20
+ TOMDOC_TITLES_SORT = TOMDOC_TITLES.sort_by { |title| title.to_s } # :nodoc:
21
+
22
+ ##
23
+ # Class/module aliases
24
+
25
+ attr_reader :aliases
26
+
27
+ ##
28
+ # All attr* methods
29
+
30
+ attr_reader :attributes
31
+
32
+ ##
33
+ # Block params to be used in the next MethodAttr parsed under this context
34
+
35
+ attr_accessor :block_params
36
+
37
+ ##
38
+ # Constants defined
39
+
40
+ attr_reader :constants
41
+
42
+ ##
43
+ # Sets the current documentation section of documentation
44
+
45
+ attr_writer :current_section
46
+
47
+ ##
48
+ # Files this context is found in
49
+
50
+ attr_reader :in_files
51
+
52
+ ##
53
+ # Modules this context includes
54
+
55
+ attr_reader :includes
56
+
57
+ ##
58
+ # Modules this context is extended with
59
+
60
+ attr_reader :extends
61
+
62
+ ##
63
+ # Methods defined in this context
64
+
65
+ attr_reader :method_list
66
+
67
+ ##
68
+ # Name of this class excluding namespace. See also full_name
69
+
70
+ attr_reader :name
71
+
72
+ ##
73
+ # Files this context requires
74
+
75
+ attr_reader :requires
76
+
77
+ ##
78
+ # Use this section for the next method, attribute or constant added.
79
+
80
+ attr_accessor :temporary_section
81
+
82
+ ##
83
+ # Hash <tt>old_name => [aliases]</tt>, for aliases
84
+ # that haven't (yet) been resolved to a method/attribute.
85
+ # (Not to be confused with the aliases of the context.)
86
+
87
+ attr_accessor :unmatched_alias_lists
88
+
89
+ ##
90
+ # Aliases that could not be resolved.
91
+
92
+ attr_reader :external_aliases
93
+
94
+ ##
95
+ # Current visibility of this context
96
+
97
+ attr_accessor :visibility
98
+
99
+ ##
100
+ # Current visibility of this line
101
+
102
+ attr_writer :current_line_visibility
103
+
104
+ ##
105
+ # Hash of registered methods. Attributes are also registered here,
106
+ # twice if they are RW.
107
+
108
+ attr_reader :methods_hash
109
+
110
+ ##
111
+ # Params to be used in the next MethodAttr parsed under this context
112
+
113
+ attr_accessor :params
114
+
115
+ ##
116
+ # Hash of registered constants.
117
+
118
+ attr_reader :constants_hash
119
+
120
+ ##
121
+ # Creates an unnamed empty context with public current visibility
122
+
123
+ def initialize
124
+ super
125
+
126
+ @in_files = []
127
+
128
+ @name ||= "unknown"
129
+ @parent = nil
130
+ @visibility = :public
131
+
132
+ @current_section = Section.new self, nil, nil
133
+ @sections = { nil => @current_section }
134
+ @temporary_section = nil
135
+
136
+ @classes = {}
137
+ @modules = {}
138
+
139
+ initialize_methods_etc
140
+ end
141
+
142
+ ##
143
+ # Sets the defaults for methods and so-forth
144
+
145
+ def initialize_methods_etc
146
+ @method_list = []
147
+ @attributes = []
148
+ @aliases = []
149
+ @requires = []
150
+ @includes = []
151
+ @extends = []
152
+ @constants = []
153
+ @external_aliases = []
154
+ @current_line_visibility = nil
155
+
156
+ # This Hash maps a method name to a list of unmatched aliases (aliases of
157
+ # a method not yet encountered).
158
+ @unmatched_alias_lists = {}
159
+
160
+ @methods_hash = {}
161
+ @constants_hash = {}
162
+
163
+ @params = nil
164
+
165
+ @store ||= nil
166
+ end
167
+
168
+ ##
169
+ # Contexts are sorted by full_name
170
+
171
+ def <=>(other)
172
+ return nil unless RDoc::CodeObject === other
173
+
174
+ full_name <=> other.full_name
175
+ end
176
+
177
+ ##
178
+ # Adds an item of type +klass+ with the given +name+ and +comment+ to the
179
+ # context.
180
+ #
181
+ # Currently only RDoc::Extend and RDoc::Include are supported.
182
+
183
+ def add(klass, name, comment)
184
+ if RDoc::Extend == klass then
185
+ ext = RDoc::Extend.new name, comment
186
+ add_extend ext
187
+ elsif RDoc::Include == klass then
188
+ incl = RDoc::Include.new name, comment
189
+ add_include incl
190
+ else
191
+ raise NotImplementedError, "adding a #{klass} is not implemented"
192
+ end
193
+ end
194
+
195
+ ##
196
+ # Adds +an_alias+ that is automatically resolved
197
+
198
+ def add_alias(an_alias)
199
+ return an_alias unless @document_self
200
+
201
+ method_attr = find_method(an_alias.old_name, an_alias.singleton) ||
202
+ find_attribute(an_alias.old_name, an_alias.singleton)
203
+
204
+ if method_attr then
205
+ method_attr.add_alias an_alias, self
206
+ else
207
+ add_to @external_aliases, an_alias
208
+ unmatched_alias_list =
209
+ @unmatched_alias_lists[an_alias.pretty_old_name] ||= []
210
+ unmatched_alias_list.push an_alias
211
+ end
212
+
213
+ an_alias
214
+ end
215
+
216
+ ##
217
+ # Adds +attribute+ if not already there. If it is (as method(s) or attribute),
218
+ # updates the comment if it was empty.
219
+ #
220
+ # The attribute is registered only if it defines a new method.
221
+ # For instance, <tt>attr_reader :foo</tt> will not be registered
222
+ # if method +foo+ exists, but <tt>attr_accessor :foo</tt> will be registered
223
+ # if method +foo+ exists, but <tt>foo=</tt> does not.
224
+
225
+ def add_attribute(attribute)
226
+ return attribute unless @document_self
227
+
228
+ # mainly to check for redefinition of an attribute as a method
229
+ # TODO find a policy for 'attr_reader :foo' + 'def foo=()'
230
+ register = false
231
+
232
+ key = nil
233
+
234
+ if attribute.rw.index 'R' then
235
+ key = attribute.pretty_name
236
+ known = @methods_hash[key]
237
+
238
+ if known then
239
+ known.comment = attribute.comment if known.comment.empty?
240
+ elsif registered = @methods_hash[attribute.pretty_name + '='] and
241
+ RDoc::Attr === registered then
242
+ registered.rw = 'RW'
243
+ else
244
+ @methods_hash[key] = attribute
245
+ register = true
246
+ end
247
+ end
248
+
249
+ if attribute.rw.index 'W' then
250
+ key = attribute.pretty_name + '='
251
+ known = @methods_hash[key]
252
+
253
+ if known then
254
+ known.comment = attribute.comment if known.comment.empty?
255
+ elsif registered = @methods_hash[attribute.pretty_name] and
256
+ RDoc::Attr === registered then
257
+ registered.rw = 'RW'
258
+ else
259
+ @methods_hash[key] = attribute
260
+ register = true
261
+ end
262
+ end
263
+
264
+ if register then
265
+ attribute.visibility = @visibility
266
+ add_to @attributes, attribute
267
+ resolve_aliases attribute
268
+ end
269
+
270
+ attribute
271
+ end
272
+
273
+ ##
274
+ # Adds a class named +given_name+ with +superclass+.
275
+ #
276
+ # Both +given_name+ and +superclass+ may contain '::', and are
277
+ # interpreted relative to the +self+ context. This allows handling correctly
278
+ # examples like these:
279
+ # class RDoc::Gauntlet < Gauntlet
280
+ # module Mod
281
+ # class Object # implies < ::Object
282
+ # class SubObject < Object # this is _not_ ::Object
283
+ #
284
+ # Given <tt>class Container::Item</tt> RDoc assumes +Container+ is a module
285
+ # unless it later sees <tt>class Container</tt>. +add_class+ automatically
286
+ # upgrades +given_name+ to a class in this case.
287
+
288
+ def add_class(class_type, given_name, superclass = '::Object')
289
+ # superclass +nil+ is passed by the C parser in the following cases:
290
+ # - registering Object in 1.8 (correct)
291
+ # - registering BasicObject in 1.9 (correct)
292
+ # - registering RubyVM in 1.9 in iseq.c (incorrect: < Object in vm.c)
293
+ #
294
+ # If we later find a superclass for a registered class with a nil
295
+ # superclass, we must honor it.
296
+
297
+ # find the name & enclosing context
298
+ if given_name =~ /^:+(\w+)$/ then
299
+ full_name = $1
300
+ enclosing = top_level
301
+ name = full_name.split(/:+/).last
302
+ else
303
+ full_name = child_name given_name
304
+
305
+ if full_name =~ /^(.+)::(\w+)$/ then
306
+ name = $2
307
+ ename = $1
308
+ enclosing = @store.classes_hash[ename] || @store.modules_hash[ename]
309
+ # HACK: crashes in actionpack/lib/action_view/helpers/form_helper.rb (metaprogramming)
310
+ unless enclosing then
311
+ # try the given name at top level (will work for the above example)
312
+ enclosing = @store.classes_hash[given_name] ||
313
+ @store.modules_hash[given_name]
314
+ return enclosing if enclosing
315
+ # not found: create the parent(s)
316
+ enclosing = find_or_create_namespace_path ename
317
+ end
318
+ else
319
+ name = full_name
320
+ enclosing = self
321
+ end
322
+ end
323
+
324
+ # fix up superclass
325
+ if full_name == 'BasicObject' then
326
+ superclass = nil
327
+ elsif full_name == 'Object' then
328
+ superclass = '::BasicObject'
329
+ end
330
+
331
+ # find the superclass full name
332
+ if superclass then
333
+ if superclass =~ /^:+/ then
334
+ superclass = $' #'
335
+ else
336
+ if superclass =~ /^(\w+):+(.+)$/ then
337
+ suffix = $2
338
+ mod = find_module_named($1)
339
+ superclass = mod.full_name + '::' + suffix if mod
340
+ else
341
+ mod = find_module_named(superclass)
342
+ superclass = mod.full_name if mod
343
+ end
344
+ end
345
+
346
+ # did we believe it was a module?
347
+ mod = @store.modules_hash.delete superclass
348
+
349
+ upgrade_to_class mod, RDoc::NormalClass, mod.parent if mod
350
+
351
+ # e.g., Object < Object
352
+ superclass = nil if superclass == full_name
353
+ end
354
+
355
+ klass = @store.classes_hash[full_name]
356
+
357
+ if klass then
358
+ # if TopLevel, it may not be registered in the classes:
359
+ enclosing.classes_hash[name] = klass
360
+
361
+ # update the superclass if needed
362
+ if superclass then
363
+ existing = klass.superclass
364
+ existing = existing.full_name unless existing.is_a?(String) if existing
365
+ if existing.nil? ||
366
+ (existing == 'Object' && superclass != 'Object') then
367
+ klass.superclass = superclass
368
+ end
369
+ end
370
+ else
371
+ # this is a new class
372
+ mod = @store.modules_hash.delete full_name
373
+
374
+ if mod then
375
+ klass = upgrade_to_class mod, RDoc::NormalClass, enclosing
376
+
377
+ klass.superclass = superclass unless superclass.nil?
378
+ else
379
+ klass = class_type.new name, superclass
380
+
381
+ enclosing.add_class_or_module(klass, enclosing.classes_hash,
382
+ @store.classes_hash)
383
+ end
384
+ end
385
+
386
+ klass.parent = self
387
+
388
+ klass
389
+ end
390
+
391
+ ##
392
+ # Adds the class or module +mod+ to the modules or
393
+ # classes Hash +self_hash+, and to +all_hash+ (either
394
+ # <tt>TopLevel::modules_hash</tt> or <tt>TopLevel::classes_hash</tt>),
395
+ # unless #done_documenting is +true+. Sets the #parent of +mod+
396
+ # to +self+, and its #section to #current_section. Returns +mod+.
397
+
398
+ def add_class_or_module(mod, self_hash, all_hash)
399
+ mod.section = current_section # TODO declaring context? something is
400
+ # wrong here...
401
+ mod.parent = self
402
+ mod.full_name = nil
403
+ mod.store = @store
404
+
405
+ unless @done_documenting then
406
+ self_hash[mod.name] = mod
407
+ # this must be done AFTER adding mod to its parent, so that the full
408
+ # name is correct:
409
+ all_hash[mod.full_name] = mod
410
+ if @store.unmatched_constant_alias[mod.full_name] then
411
+ to, file = @store.unmatched_constant_alias[mod.full_name]
412
+ add_module_alias mod, mod.name, to, file
413
+ end
414
+ end
415
+
416
+ mod
417
+ end
418
+
419
+ ##
420
+ # Adds +constant+ if not already there. If it is, updates the comment,
421
+ # value and/or is_alias_for of the known constant if they were empty/nil.
422
+
423
+ def add_constant(constant)
424
+ return constant unless @document_self
425
+
426
+ # HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)
427
+ # (this is a #ifdef: should be handled by the C parser)
428
+ known = @constants_hash[constant.name]
429
+
430
+ if known then
431
+ known.comment = constant.comment if known.comment.empty?
432
+
433
+ known.value = constant.value if
434
+ known.value.nil? or known.value.strip.empty?
435
+
436
+ constant.parent = self
437
+ known.is_alias_for ||= constant.is_alias_for
438
+ else
439
+ @constants_hash[constant.name] = constant
440
+ add_to @constants, constant
441
+ end
442
+
443
+ constant
444
+ end
445
+
446
+ ##
447
+ # Adds included module +include+ which should be an RDoc::Include
448
+
449
+ def add_include(include)
450
+ add_to @includes, include
451
+
452
+ include
453
+ end
454
+
455
+ ##
456
+ # Adds extension module +ext+ which should be an RDoc::Extend
457
+
458
+ def add_extend(ext)
459
+ add_to @extends, ext
460
+
461
+ ext
462
+ end
463
+
464
+ ##
465
+ # Adds +method+ if not already there. If it is (as method or attribute),
466
+ # updates the comment if it was empty.
467
+
468
+ def add_method(method)
469
+ return method unless @document_self
470
+
471
+ # HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code)
472
+ key = method.pretty_name
473
+ known = @methods_hash[key]
474
+
475
+ if known then
476
+ if @store then # otherwise we are loading
477
+ known.comment = method.comment if known.comment.empty?
478
+ previously = ", previously in #{known.file}" unless
479
+ method.file == known.file
480
+ @store.options.warn \
481
+ "Duplicate method #{known.full_name} in #{method.file}#{previously}"
482
+ end
483
+ else
484
+ @methods_hash[key] = method
485
+ if @current_line_visibility
486
+ method.visibility, @current_line_visibility = @current_line_visibility, nil
487
+ else
488
+ method.visibility = @visibility
489
+ end
490
+ add_to @method_list, method
491
+ resolve_aliases method
492
+ end
493
+
494
+ method
495
+ end
496
+
497
+ ##
498
+ # Returns the owner context and local name for +constant_path+, creating
499
+ # missing namespace modules. A leading +::+ resolves from the top-level.
500
+ # This only resolves explicit context-tree paths; RDoc::Parser::Ruby has
501
+ # parser-local lexical helpers for Ruby's nesting-dependent lookup.
502
+
503
+ def find_or_create_constant_owner_for_path(constant_path) # :nodoc:
504
+ constant_path = constant_path.to_s
505
+ owner = constant_path.start_with?('::') ? top_level : self
506
+ constant_path = constant_path.delete_prefix('::')
507
+
508
+ owner_path, separator, name = constant_path.rpartition('::')
509
+ owner = owner.find_or_create_namespace_path owner_path unless separator.empty?
510
+
511
+ [owner, name]
512
+ end
513
+
514
+ ##
515
+ # Finds or creates the module namespace path under this context.
516
+
517
+ def find_or_create_namespace_path(path) # :nodoc:
518
+ path.to_s.split('::').inject(self) do |owner, name|
519
+ owner.classes_hash[name] ||
520
+ owner.modules_hash[name] ||
521
+ owner.add_module(RDoc::NormalModule, name)
522
+ end
523
+ end
524
+
525
+ ##
526
+ # Adds a module named +name+. If RDoc already knows +name+ is a class then
527
+ # that class is returned instead. See also #add_class.
528
+
529
+ def add_module(class_type, name)
530
+ if name.to_s.include?('::')
531
+ owner, name = find_or_create_constant_owner_for_path name
532
+ return owner.add_module class_type, name unless owner == self
533
+ end
534
+
535
+ mod = @classes[name] || @modules[name]
536
+ return mod if mod
537
+
538
+ full_name = child_name name
539
+ mod = @store.modules_hash[full_name] || class_type.new(name)
540
+
541
+ add_class_or_module mod, @modules, @store.modules_hash
542
+ end
543
+
544
+ ##
545
+ # Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
546
+
547
+ def add_module_by_normal_module(mod)
548
+ add_class_or_module mod, @modules, @store.modules_hash
549
+ end
550
+
551
+ ##
552
+ # Adds an alias from +from+ (a class or module) to +name+ which was defined
553
+ # in +file+.
554
+
555
+ def add_module_alias(from, from_name, to, file)
556
+ return from if @done_documenting
557
+
558
+ to_full_name = child_name to.name
559
+
560
+ # if we already know this name, don't register an alias:
561
+ # see the metaprogramming in lib/active_support/basic_object.rb,
562
+ # where we already know BasicObject is a class when we find
563
+ # BasicObject = BlankSlate
564
+ return from if @store.find_class_or_module to_full_name
565
+
566
+ unless from
567
+ @store.unmatched_constant_alias[child_name(from_name)] = [to, file]
568
+ return to
569
+ end
570
+
571
+ new_to = from.dup
572
+ new_to.name = to.name
573
+ new_to.full_name = nil
574
+ new_to.is_alias_for = from
575
+
576
+ if new_to.module? then
577
+ @store.modules_hash[to_full_name] = new_to
578
+ @modules[to.name] = new_to
579
+ else
580
+ @store.classes_hash[to_full_name] = new_to
581
+ @classes[to.name] = new_to
582
+ end
583
+
584
+ # Registers a constant for this alias. The constant value and comment
585
+ # will be updated later, when the Ruby parser adds the constant
586
+ const = RDoc::Constant.new to.name, nil, new_to.comment
587
+ const.record_location file
588
+ const.is_alias_for = from
589
+ add_constant const
590
+
591
+ new_to
592
+ end
593
+
594
+ ##
595
+ # Adds +require+ to this context's top level
596
+
597
+ def add_require(require)
598
+ return require unless @document_self
599
+
600
+ if RDoc::TopLevel === self then
601
+ add_to @requires, require
602
+ else
603
+ parent.add_require require
604
+ end
605
+ end
606
+
607
+ ##
608
+ # Returns a section with +title+, creating it if it doesn't already exist.
609
+ # +comment+ will be appended to the section's comment.
610
+ #
611
+ # A section with a +title+ of +nil+ will return the default section.
612
+ #
613
+ # See also RDoc::Context::Section
614
+
615
+ def add_section(title, comment = nil)
616
+ if section = @sections[title] then
617
+ section.add_comment comment if comment
618
+ else
619
+ section = Section.new self, title, comment, @store
620
+ @sections[title] = section
621
+ end
622
+
623
+ section
624
+ end
625
+
626
+ ##
627
+ # Adds +thing+ to the collection +array+
628
+
629
+ def add_to(array, thing)
630
+ array << thing if @document_self
631
+
632
+ thing.parent = self
633
+ thing.store = @store if @store
634
+ thing.section = current_section
635
+ end
636
+
637
+ ##
638
+ # Is there any content?
639
+ #
640
+ # This means any of: comment, aliases, methods, attributes, external
641
+ # aliases, require, constant.
642
+ #
643
+ # Includes and extends are also checked unless <tt>includes == false</tt>.
644
+
645
+ def any_content(includes = true)
646
+ @any_content ||= !(
647
+ @comment.empty? &&
648
+ @method_list.empty? &&
649
+ @attributes.empty? &&
650
+ @aliases.empty? &&
651
+ @external_aliases.empty? &&
652
+ @requires.empty? &&
653
+ @constants.empty?
654
+ )
655
+ @any_content || (includes && !(@includes + @extends).empty? )
656
+ end
657
+
658
+ ##
659
+ # Creates the full name for a child with +name+
660
+
661
+ def child_name(name)
662
+ if name =~ /^:+/
663
+ $' #'
664
+ elsif RDoc::TopLevel === self then
665
+ name
666
+ else
667
+ "#{self.full_name}::#{name}"
668
+ end
669
+ end
670
+
671
+ ##
672
+ # Class methods
673
+
674
+ def class_method_list
675
+ method_list.select { |a| a.singleton }
676
+ end
677
+
678
+ ##
679
+ # Array of classes in this context
680
+
681
+ def classes
682
+ @classes.values
683
+ end
684
+
685
+ ##
686
+ # All classes and modules in this namespace
687
+
688
+ def classes_and_modules
689
+ classes + modules
690
+ end
691
+
692
+ ##
693
+ # Hash of classes keyed by class name
694
+
695
+ def classes_hash
696
+ @classes
697
+ end
698
+
699
+ ##
700
+ # The current documentation section that new items will be added to. If
701
+ # temporary_section is available it will be used.
702
+
703
+ def current_section
704
+ if section = @temporary_section then
705
+ @temporary_section = nil
706
+ else
707
+ section = @current_section
708
+ end
709
+
710
+ section
711
+ end
712
+
713
+ def display(method_attr) # :nodoc:
714
+ if method_attr.is_a? RDoc::Attr
715
+ "#{method_attr.definition} #{method_attr.pretty_name}"
716
+ else
717
+ "method #{method_attr.pretty_name}"
718
+ end
719
+ end
720
+
721
+ ##
722
+ # Iterator for ancestors for duck-typing. Does nothing. See
723
+ # RDoc::ClassModule#each_ancestor.
724
+ #
725
+ # This method exists to make it easy to work with Context subclasses that
726
+ # aren't part of RDoc.
727
+
728
+ def each_ancestor(&_) # :nodoc:
729
+ end
730
+
731
+ ##
732
+ # Iterator for classes and modules
733
+
734
+ def each_classmodule(&block) # :yields: module
735
+ classes_and_modules.sort.each(&block)
736
+ end
737
+
738
+ ##
739
+ # Iterator for methods
740
+
741
+ def each_method # :yields: method
742
+ return enum_for __method__ unless block_given?
743
+
744
+ @method_list.sort.each { |m| yield m }
745
+ end
746
+
747
+ ##
748
+ # Iterator for each section's contents sorted by title. The +section+, the
749
+ # section's +constants+ and the sections +attributes+ are yielded. The
750
+ # +constants+ and +attributes+ collections are sorted.
751
+ #
752
+ # To retrieve methods in a section use #methods_by_type with the optional
753
+ # +section+ parameter.
754
+ #
755
+ # NOTE: Do not edit collections yielded by this method
756
+
757
+ def each_section # :yields: section, constants, attributes
758
+ return enum_for __method__ unless block_given?
759
+
760
+ constants = @constants.group_by do |constant| constant.section end
761
+ attributes = @attributes.group_by do |attribute| attribute.section end
762
+
763
+ constants.default = []
764
+ attributes.default = []
765
+
766
+ sort_sections.each do |section|
767
+ yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
768
+ end
769
+ end
770
+
771
+ ##
772
+ # Finds an attribute +name+ with singleton value +singleton+.
773
+
774
+ def find_attribute(name, singleton)
775
+ name = $1 if name =~ /^(.*)=$/
776
+ @attributes.find { |a| a.name == name && a.singleton == singleton }
777
+ end
778
+
779
+ ##
780
+ # Finds an attribute with +name+ in this context
781
+
782
+ def find_attribute_named(name)
783
+ case name
784
+ when /\A#/ then
785
+ find_attribute name[1..-1], false
786
+ when /\A::/ then
787
+ find_attribute name[2..-1], true
788
+ else
789
+ @attributes.find { |a| a.name == name }
790
+ end
791
+ end
792
+
793
+ ##
794
+ # Finds a class method with +name+ in this context
795
+
796
+ def find_class_method_named(name)
797
+ @method_list.find { |meth| meth.singleton && meth.name == name }
798
+ end
799
+
800
+ ##
801
+ # Finds a constant with +name+ in this context
802
+
803
+ def find_constant_named(name)
804
+ @constants.find do |m|
805
+ m.name == name || m.full_name == name
806
+ end
807
+ end
808
+
809
+ ##
810
+ # Tries to find a module at a higher scope.
811
+ # But parent is not always a higher module nesting scope, so the result is not correct.
812
+ # Parent chain can only represent last-opened nesting, and may be broken in some cases.
813
+ # The Ruby parser does not represent module nesting with the parent chain.
814
+
815
+ def find_enclosing_module_named(name)
816
+ parent && parent.find_module_named(name)
817
+ end
818
+
819
+ ##
820
+ # Finds an external alias +name+ with singleton value +singleton+.
821
+
822
+ def find_external_alias(name, singleton)
823
+ @external_aliases.find { |m| m.name == name && m.singleton == singleton }
824
+ end
825
+
826
+ ##
827
+ # Finds an external alias with +name+ in this context
828
+
829
+ def find_external_alias_named(name)
830
+ case name
831
+ when /\A#/ then
832
+ find_external_alias name[1..-1], false
833
+ when /\A::/ then
834
+ find_external_alias name[2..-1], true
835
+ else
836
+ @external_aliases.find { |a| a.name == name }
837
+ end
838
+ end
839
+
840
+ ##
841
+ # Finds an instance method with +name+ in this context
842
+
843
+ def find_instance_method_named(name)
844
+ @method_list.find { |meth| !meth.singleton && meth.name == name }
845
+ end
846
+
847
+ ##
848
+ # Finds a method, constant, attribute, external alias, module or file
849
+ # named +symbol+ in this context.
850
+
851
+ def find_local_symbol(symbol)
852
+ find_method_named(symbol) or
853
+ find_constant_named(symbol) or
854
+ find_attribute_named(symbol) or
855
+ find_external_alias_named(symbol) or
856
+ find_module_named(symbol) or
857
+ @store.find_file_named(symbol)
858
+ end
859
+
860
+ ##
861
+ # Finds a method named +name+ with singleton value +singleton+.
862
+
863
+ def find_method(name, singleton)
864
+ @method_list.find { |m|
865
+ if m.singleton
866
+ m.name == name && m.singleton == singleton
867
+ else
868
+ m.name == name && !m.singleton && !singleton
869
+ end
870
+ }
871
+ end
872
+
873
+ ##
874
+ # Finds a instance or module method with +name+ in this context
875
+
876
+ def find_method_named(name)
877
+ case name
878
+ when /\A#/ then
879
+ find_method name[1..-1], false
880
+ when /\A::/ then
881
+ find_method name[2..-1], true
882
+ else
883
+ @method_list.find { |meth| meth.name == name }
884
+ end
885
+ end
886
+
887
+ ##
888
+ # Find a module with +name+ trying to using ruby's scoping rules.
889
+ # find_enclosing_module_named cannot use ruby's scoping so the result is not correct.
890
+
891
+ def find_module_named(name)
892
+ res = get_module_named(name)
893
+ return res if res
894
+ return self if self.name == name
895
+ find_enclosing_module_named name
896
+ end
897
+
898
+ # Get a module named +name+ in this context
899
+ # Don't look up for higher module nesting scopes. RDoc::Context doesn't have that information.
900
+
901
+ def get_module_named(name)
902
+ @modules[name] || @classes[name]
903
+ end
904
+
905
+ ##
906
+ # Look up +symbol+, first as a module, then as a local symbol.
907
+
908
+ def find_symbol(symbol)
909
+ find_symbol_module(symbol) || find_local_symbol(symbol)
910
+ end
911
+
912
+ ##
913
+ # Look up a module named +symbol+.
914
+
915
+ def find_symbol_module(symbol)
916
+ result = nil
917
+
918
+ # look for a class or module 'symbol'
919
+ case symbol
920
+ when /^::/ then
921
+ result = @store.find_class_or_module symbol
922
+ when /^(\w+):+(.+)$/
923
+ suffix = $2
924
+ top = $1
925
+ searched = self
926
+ while searched do
927
+ mod = searched.find_module_named(top)
928
+ break unless mod
929
+ result = @store.find_class_or_module "#{mod.full_name}::#{suffix}"
930
+ break if result || searched.is_a?(RDoc::TopLevel)
931
+ searched = searched.parent
932
+ end
933
+ else
934
+ searched = self
935
+ while searched do
936
+ result = searched.find_module_named(symbol)
937
+ break if result || searched.is_a?(RDoc::TopLevel)
938
+ searched = searched.parent
939
+ end
940
+ end
941
+
942
+ result
943
+ end
944
+
945
+ ##
946
+ # The full name for this context. This method is overridden by subclasses.
947
+
948
+ def full_name
949
+ '(unknown)'
950
+ end
951
+
952
+ ##
953
+ # Does this context and its methods and constants all have documentation?
954
+ #
955
+ # (Yes, fully documented doesn't mean everything.)
956
+
957
+ def fully_documented?
958
+ documented? and
959
+ attributes.all? { |a| a.documented? } and
960
+ method_list.all? { |m| m.documented? } and
961
+ constants.all? { |c| c.documented? }
962
+ end
963
+
964
+ ##
965
+ # URL for this with a +prefix+
966
+
967
+ def http_url
968
+ path = name_for_path
969
+ path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<</
970
+ path = path.split('::')
971
+
972
+ File.join(*path.compact) + '.html'
973
+ end
974
+
975
+ ##
976
+ # Instance methods
977
+
978
+ def instance_methods
979
+ method_list.reject { |a| a.singleton }
980
+ end
981
+
982
+ ##
983
+ # Breaks method_list into a nested hash by type (<tt>'class'</tt> or
984
+ # <tt>'instance'</tt>) and visibility (+:public+, +:protected+, +:private+).
985
+ #
986
+ # If +section+ is provided only methods in that RDoc::Context::Section will
987
+ # be returned.
988
+
989
+ def methods_by_type(section = nil)
990
+ methods = {}
991
+
992
+ TYPES.each do |type|
993
+ visibilities = {}
994
+ RDoc::VISIBILITIES.each do |vis|
995
+ visibilities[vis] = []
996
+ end
997
+
998
+ methods[type] = visibilities
999
+ end
1000
+
1001
+ each_method do |method|
1002
+ next if section and not method.section == section
1003
+ methods[method.type][method.visibility] << method
1004
+ end
1005
+
1006
+ methods
1007
+ end
1008
+
1009
+ ##
1010
+ # Yields AnyMethod and Attr entries matching the list of names in +methods+.
1011
+
1012
+ def methods_matching(methods, singleton = false, &block)
1013
+ (@method_list + @attributes).each do |m|
1014
+ yield m if methods.include?(m.name) and m.singleton == singleton
1015
+ end
1016
+
1017
+ each_ancestor do |parent|
1018
+ parent.methods_matching(methods, singleton, &block)
1019
+ end
1020
+ end
1021
+
1022
+ ##
1023
+ # Array of modules in this context
1024
+
1025
+ def modules
1026
+ @modules.values
1027
+ end
1028
+
1029
+ ##
1030
+ # Hash of modules keyed by module name
1031
+
1032
+ def modules_hash
1033
+ @modules
1034
+ end
1035
+
1036
+ ##
1037
+ # Name to use to generate the url.
1038
+ # <tt>#full_name</tt> by default.
1039
+
1040
+ def name_for_path
1041
+ full_name
1042
+ end
1043
+
1044
+ ##
1045
+ # Changes the visibility for new methods to +visibility+
1046
+
1047
+ def ongoing_visibility=(visibility)
1048
+ @visibility = visibility
1049
+ end
1050
+
1051
+ ##
1052
+ # Record +top_level+ as a file +self+ is in.
1053
+
1054
+ def record_location(top_level)
1055
+ @in_files << top_level unless @in_files.include?(top_level)
1056
+ end
1057
+
1058
+ ##
1059
+ # Should we remove this context from the documentation?
1060
+ #
1061
+ # The answer is yes if:
1062
+ # * #received_nodoc is +true+
1063
+ # * #any_content is +false+ (not counting includes)
1064
+ # * All #includes are modules (not a string), and their module has
1065
+ # <tt>#remove_from_documentation? == true</tt>
1066
+ # * All classes and modules have <tt>#remove_from_documentation? == true</tt>
1067
+
1068
+ def remove_from_documentation?
1069
+ @remove_from_documentation ||=
1070
+ @received_nodoc &&
1071
+ !any_content(false) &&
1072
+ @includes.all? { |i| !i.module.is_a?(String) && i.module.remove_from_documentation? } &&
1073
+ classes_and_modules.all? { |cm| cm.remove_from_documentation? }
1074
+ end
1075
+
1076
+ ##
1077
+ # Removes methods and attributes with a visibility less than +min_visibility+.
1078
+ #--
1079
+ # TODO mark the visibility of attributes in the template (if not public?)
1080
+
1081
+ def remove_invisible(min_visibility)
1082
+ return if [:private, :nodoc].include? min_visibility
1083
+ remove_invisible_in @method_list, min_visibility
1084
+ remove_invisible_in @attributes, min_visibility
1085
+ remove_invisible_in @constants, min_visibility
1086
+ end
1087
+
1088
+ ##
1089
+ # Only called when min_visibility == :public or :private
1090
+
1091
+ def remove_invisible_in(array, min_visibility) # :nodoc:
1092
+ if min_visibility == :public then
1093
+ array.reject! { |e|
1094
+ e.visibility != :public and not e.force_documentation
1095
+ }
1096
+ else
1097
+ array.reject! { |e|
1098
+ e.visibility == :private and not e.force_documentation
1099
+ }
1100
+ end
1101
+ end
1102
+
1103
+ ##
1104
+ # Tries to resolve unmatched aliases when a method or attribute has just
1105
+ # been added.
1106
+
1107
+ def resolve_aliases(added)
1108
+ # resolve any pending unmatched aliases
1109
+ key = added.pretty_name
1110
+ unmatched_alias_list = @unmatched_alias_lists[key]
1111
+ return unless unmatched_alias_list
1112
+ unmatched_alias_list.each do |unmatched_alias|
1113
+ added.add_alias unmatched_alias, self
1114
+ @external_aliases.delete unmatched_alias
1115
+ end
1116
+ @unmatched_alias_lists.delete key
1117
+ end
1118
+
1119
+ ##
1120
+ # Returns RDoc::Context::Section objects referenced in this context for use
1121
+ # in a table of contents.
1122
+
1123
+ def section_contents
1124
+ used_sections = {}
1125
+
1126
+ each_method do |method|
1127
+ next unless method.display?
1128
+
1129
+ used_sections[method.section] = true
1130
+ end
1131
+
1132
+ # order found sections
1133
+ sections = sort_sections.select do |section|
1134
+ used_sections[section]
1135
+ end
1136
+
1137
+ # only the default section is used
1138
+ return [] if
1139
+ sections.length == 1 and not sections.first.title
1140
+
1141
+ sections
1142
+ end
1143
+
1144
+ ##
1145
+ # Sections in this context
1146
+
1147
+ def sections
1148
+ @sections.values
1149
+ end
1150
+
1151
+ def sections_hash # :nodoc:
1152
+ @sections
1153
+ end
1154
+
1155
+ ##
1156
+ # Sets the current section to a section with +title+. See also #add_section
1157
+
1158
+ def set_current_section(title, comment)
1159
+ @current_section = add_section title, comment
1160
+ end
1161
+
1162
+ ##
1163
+ # Given an array +methods+ of method names, set the visibility of each to
1164
+ # +visibility+
1165
+
1166
+ def set_visibility_for(methods, visibility, singleton = false)
1167
+ methods_matching methods, singleton do |m|
1168
+ m.visibility = visibility
1169
+ end
1170
+ end
1171
+
1172
+ ##
1173
+ # Given an array +names+ of constants, set the visibility of each constant to
1174
+ # +visibility+
1175
+
1176
+ def set_constant_visibility_for(names, visibility)
1177
+ names.each do |name|
1178
+ constant = @constants_hash[name] or next
1179
+ constant.visibility = visibility
1180
+ end
1181
+ end
1182
+
1183
+ ##
1184
+ # Sorts sections alphabetically (default) or in TomDoc fashion (none,
1185
+ # Public, Internal, Deprecated)
1186
+
1187
+ def sort_sections
1188
+ titles = @sections.map { |title, _| title }
1189
+
1190
+ if titles.length > 1 and
1191
+ TOMDOC_TITLES_SORT ==
1192
+ (titles | TOMDOC_TITLES).sort_by { |title| title.to_s } then
1193
+ @sections.values_at(*TOMDOC_TITLES).compact
1194
+ else
1195
+ @sections.sort_by { |title, _|
1196
+ title.to_s
1197
+ }.map { |_, section|
1198
+ section
1199
+ }
1200
+ end
1201
+ end
1202
+
1203
+ def to_s # :nodoc:
1204
+ "#{self.class.name} #{self.full_name}"
1205
+ end
1206
+
1207
+ ##
1208
+ # Return the TopLevel that owns us
1209
+ #--
1210
+ # FIXME we can be 'owned' by several TopLevel (see #record_location &
1211
+ # #in_files)
1212
+
1213
+ def top_level
1214
+ return @top_level if defined? @top_level
1215
+ @top_level = self
1216
+ @top_level = @top_level.parent until RDoc::TopLevel === @top_level
1217
+ @top_level
1218
+ end
1219
+
1220
+ ##
1221
+ # Upgrades NormalModule +mod+ in +enclosing+ to a +class_type+
1222
+
1223
+ def upgrade_to_class(mod, class_type, enclosing)
1224
+ enclosing.modules_hash.delete mod.name
1225
+
1226
+ klass = RDoc::ClassModule.from_module class_type, mod
1227
+ klass.store = @store
1228
+
1229
+ # if it was there, then we keep it even if done_documenting
1230
+ @store.classes_hash[mod.full_name] = klass
1231
+ enclosing.classes_hash[mod.name] = klass
1232
+
1233
+ klass
1234
+ end
1235
+
1236
+ autoload :Section, "#{__dir__}/context/section"
1237
+
1238
+ end